Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/connectai-e/go-minimax
💸 MiniMax wrapper for Go SDK MINIMAX 大语言模型 golang SDK
https://github.com/connectai-e/go-minimax
connect-ai go golang minimax
Last synced: about 2 months ago
JSON representation
💸 MiniMax wrapper for Go SDK MINIMAX 大语言模型 golang SDK
- Host: GitHub
- URL: https://github.com/connectai-e/go-minimax
- Owner: ConnectAI-E
- License: mit
- Created: 2023-06-04T09:20:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-22T09:26:20.000Z (over 1 year ago)
- Last Synced: 2024-08-03T02:05:32.481Z (5 months ago)
- Topics: connect-ai, go, golang, minimax
- Language: Go
- Homepage: https://api.minimax.chat/
- Size: 42 KB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## MINIMAX-SDK
> 大语言模型 MiniMax API[😎点击查看官方文档](https://api.minimax.chat/)
### 功能及特点
1. 全接口字段注释
2. Chatcompletion 文本对话接口
3. Embeddings 向量化接口
4. T2A 文本转语音接口
5. 无缝对接官方文档:单轮问答、历史记忆问答、流返回
6. 支持Swagger文档 和 ApiFox 文档### Swagger 文档
- [打开在线Swagger编辑器](https://editor.swagger.io/)
- 导入[Swagger Api 文档](./output/apis.swagger.yaml)
### 使用方法
1. 访问 [MiniMax](https://api.minimax.chat/document/guides/example) 管理后台。
2. 获取取 [groupID](https://api.minimax.chat/basic-information) 和 [API_token](https://api.minimax.chat/basic-information/interface-key)
3. 参考下面示例### 示例
```go
package mainimport (
"context"
"fmt"
"os"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
)func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
SenderType: "USER",
Text: "hi~",
},
},
Model: "abab5-chat",
Temperature: 0.7,
}
res, _ := client.ChatCompletions(ctx, req)fmt.Println(res.Choices) // output: 你好!有什么我可以帮助你的吗?
}```
### 快速上手:
MiniMax completion
```go
package mainimport (
"context"
"fmt"
"os"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
)func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
SenderType: "USER",
Text: "hi~",
},
},
Model: "abab5-chat",
Temperature: 0.7,
}
res, _ := client.ChatCompletions(ctx, req)fmt.Println(res.Choices) // output: 你好!有什么我可以帮助你的吗?
}
```MiniMax stream completion
```go
package mainimport (
"context"
"errors"
"fmt"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
"io"
"os"
)func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
SenderType: "USER",
Text: "hi~",
},
},
Model: "abab5-chat",
Temperature: 0.7,
}stream, _ := client.ChatCompletionStream(ctx, req)
defer stream.CloseSend()
for {
response, err := stream.Recv()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
fmt.Println(err)
break
}
fmt.Printf(response.Choices[0].Delta + "\n") //嗨!有什么我可以帮助您的吗?
}
}```
MiniMax history stream completion
```go
package mainimport (
"context"
"errors"
"fmt"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
"io"
"os"
)func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)
//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
"sender_type": "USER",
"text": "路卡,今天在干什么呢?"
},
{
"sender_type": "BOT",
"text": "我今天在家里复习功课,准备期末考试呢!"
},
{
"sender_type": "USER",
"text": "期末考试怎么样,有把握吗?"
}
},
Model: "abab5-chat",
Temperature: 0.7,
}stream, _ := client.ChatCompletionStream(ctx, req)
defer stream.CloseSend()
for {
response, err := stream.Recv()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
fmt.Println(err)
break
}
fmt.Printf(response.Choices[0].Delta + "\n") //放轻松,一切尽在掌握中
}
}```