https://github.com/hupe1980/go-promptlayer
🍰 PromptLayer API client written in Go
https://github.com/hupe1980/go-promptlayer
Last synced: 3 months ago
JSON representation
🍰 PromptLayer API client written in Go
- Host: GitHub
- URL: https://github.com/hupe1980/go-promptlayer
- Owner: hupe1980
- License: mit
- Created: 2023-06-29T16:26:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-02T10:15:50.000Z (over 2 years ago)
- Last Synced: 2025-02-10T02:14:38.090Z (8 months ago)
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🍰 go-promptlayer

[](https://pkg.go.dev/github.com/hupe1980/go-promptlayer)
> The Go PromptLayer API client enables seamless integration of the PromptLayer platform in your Go projects. With this client, you can effortlessly incorporate PromptLayer's features and streamline your prompt engineering workflow.## Installation
```
go get github.com/hupe1980/go-promptlayer
```## Example Usage
Here's a quick example of how you can use the Go PromptLayer API client:
```go
package mainimport (
"context"
"fmt"
"log"
"os"
"time""github.com/hupe1980/go-promptlayer"
)func main() {
client := promptlayer.NewClient(os.Getenv("PROMPTLAYER_API_KEY"))startTime := time.Now()
endTime := startTime.Add(3 * time.Second)output, err := client.TrackRequest(context.Background(), &promptlayer.TrackRequestInput{
FunctionName: "openai.Completion.create",
// kwargs will need messages if using chat-based completion
Kwargs: map[string]any{
"engine": "text-ada-001",
"prompt": "My name is",
},
Tags: []string{"hello", "world"},
RequestResponse: map[string]any{
"id": "cmpl-6TEeJCRVlqQSQqhD8CYKd1HdCcFxM",
"object": "text_completion",
"created": 1672425843,
"model": "text-ada-001",
"choices": []map[string]any{
{
"text": " advocacy\"\n\nMy name is advocacy.",
"index": 0,
"logprobs": nil,
"finish_reason": "stop",
},
},
},
RequestStartTime: startTime,
RequestEndTime: endTime,
})
if err != nil {
log.Fatal(err)
}fmt.Println("ID:", output.RequestID)
}
```
Output:
```
ID: 6368262
```
For more example usage, see [_examples](./_examples).## License
[MIT](LICENCE)