V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
alone88
V2EX  ›  分享创造

[开源] Golang 文心千帆 sdk

  •  
  •   alone88 · 2023-07-30 11:07:06 +08:00 · 827 次点击
    这是一个创建于 421 天前的主题,其中的信息可能已经有所发展或是发生改变。

    文心千帆: https://cloud.baidu.com/product/wenxinworkshop 现在基本申请了就会审核通过

    项目地址: https://github.com/anhao/go-ernie

    支持接口:

    • ERNIE-Bot
    • ERNIE-Bot-turbo
    • BLOOMZ-7B
    • Llama-2
    • Embeddings

    使用

    package main
    
    import (
    	"context"
    	"fmt"
    	ernie "github.com/anhao/go-ernie"
    )
    
    func main() {
    
    	client := ernie.NewDefaultClient("API Key", "Secret Key")
    	completion, err := client.CreateErnieBotChatCompletion(context.Background(), ernie.ErnieBotRequest{
    		Messages: []ernie.ChatCompletionMessage{
    			{
    				Role:    ernie.MessageRoleUser,
    				Content: "你好呀",
    			},
    		},
    	})
    	if err != nil {
    		fmt.Printf("ernie bot error: %v\n", err)
    		return
    	}
    	fmt.Println(completion)
    }
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1469 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:17 · PVG 01:17 · LAX 10:17 · JFK 13:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.