Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3job/anthropic-sdk-go
(Need to be maintained) Golang SDK for AnthRopic Claude AI. Provide complete encapsulated interfaces that are easy to quickly get started with.
https://github.com/3job/anthropic-sdk-go
ai anthropic claude claude-ai golang golang-library sdk sdk-go
Last synced: about 1 month ago
JSON representation
(Need to be maintained) Golang SDK for AnthRopic Claude AI. Provide complete encapsulated interfaces that are easy to quickly get started with.
- Host: GitHub
- URL: https://github.com/3job/anthropic-sdk-go
- Owner: 3JoB
- License: mit
- Created: 2023-03-23T09:18:20.000Z (almost 2 years ago)
- Default Branch: v2
- Last Pushed: 2024-04-18T10:45:39.000Z (8 months ago)
- Last Synced: 2024-05-13T14:05:53.290Z (7 months ago)
- Topics: ai, anthropic, claude, claude-ai, golang, golang-library, sdk, sdk-go
- Language: Go
- Homepage: https://pkg.go.dev/github.com/3JoB/anthropic-sdk-go/v2
- Size: 209 KB
- Stars: 36
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
Anthropic-SDK-Go
Golang SDK for AnthRopic Claude AI
## Features
- Contextual sequential memory
- Prompt automatically handles / Contextual automated processing
- Concise and easy-to-use API
- Fast data processingClaude Docs: [https://console.anthropic.com/docs](https://console.anthropic.com/docs)
## Start
Usage:
```sh
$ go get github.com/3JoB/anthropic-sdk-go/[email protected]
```
Example usage:```go
package mainimport (
"fmt""github.com/3JoB/anthropic-sdk-go/v2"
"github.com/3JoB/anthropic-sdk-go/v2/data"
"github.com/3JoB/anthropic-sdk-go/v2/resp"
)func main() {
c, err := anthropic.New(&anthropic.Config{Key: "your keys", DefaultModel: data.ModelFullInstant})
if err != nil {
panic(err)
}d, err := c.Send(&anthropic.Sender{
Message: data.MessageModule{
Human: "Do you know Golang, please answer me in the shortest possible way.",
},
Sender: &resp.Sender{MaxToken: 1200},
})if err != nil {
panic(err)
}fmt.Println(d.Response.String())
}
```Return:
```json
{"detail":null,"completion":"Hello world! \nfmt.Println(\"Hello world!\")\n\nDone.","stop_reason":"stop_sequence","stop":"\n\nHuman:","log_id":"nop","exception":"","model":"claude-instant-v1.2","truncated":false}
```
Context Example:
```go
package mainimport (
"fmt""github.com/3JoB/anthropic-sdk-go/v2"
"github.com/3JoB/anthropic-sdk-go/v2/resp"
"github.com/3JoB/anthropic-sdk-go/v2/data"
)func main() {
c, err := anthropic.New(&anthropic.Config{Key: "your keys", DefaultModel: data.ModelFullInstant})
if err != nil {
panic(err)
}d, err := c.Send(&anthropic.Sender{
Message: data.MessageModule{
Human: "Do you know Golang, please answer me in the shortest possible way.",
},
Sender: &resp.Sender{MaxToken: 1200},
})if err != nil {
panic(err)
}fmt.Println(d.Response.String())
ds, err := c.Send(&anthropic.Sender{
Message: data.MessageModule{
Human: "What is its current version number?",
},
SessionID: d.ID,
Sender: &resp.Sender{MaxToken: 1200},
})if err != nil {
panic(err)
}fmt.Println(ds.Response.String())
}
```Return:
```json
{"detail":null,"completion":"Hello world! \nfmt.Println(\"Hello world!\")\n\nDone.","stop_reason":"stop_sequence","stop":"\n\nHuman:","log_id":"nop","exception":"","model":"claude-instant-v1","truncated":false}
{"detail":null,"completion":"1.14.4 ","stop_reason":"stop_sequence","stop":"\n\nHuman:","log_id":"nop","exception":"","model":"claude-instant-v1.2","truncated":false}
```### Delete the session in an ID
```golang
c, err := anthropic.New(&anthropic.Config{Key: "your keys", DefaultModel: data.Model_FullInstant_1_0})
if err != nil {
panic(err)
}d, err := c.Send(&anthropic.Sender{
Message: data.MessageModule{
Human: "Do you know Golang, please answer me in the shortest possible way.",
},
Sender: &resp.Sender{MaxToken: 1200},
})if err != nil {
panic(err)
}c.CloseSession(d)
```
# Contribute
Move => [CONTRIBUTING](/CONTRIBUTING.md)# Contact
Organize EMAIL: `admin#zxda.top` [# => @]
# License
This software is distributed under MIT license.