当前位置: 首页 > wzjs >正文

ui是什么设计优化方案答案

ui是什么设计,优化方案答案,企业展厅设计公司有哪些,网站里的聊天怎么做目录 1、什么是langchainGo2、langchainGo的官方地址3、LangChainGo with OpenAI3-1、前置准备3-2、安装依赖库3-3、新建模型客户端3-4、使用模型进行对话 4、总结 1、什么是langchainGo langchaingo是langchain的go语言实现版本 2、langchainGo的官方地址 官网:…

目录

      • 1、什么是langchainGo
      • 2、langchainGo的官方地址
      • 3、LangChainGo with OpenAI
        • 3-1、前置准备
        • 3-2、安装依赖库
        • 3-3、新建模型客户端
        • 3-4、使用模型进行对话
      • 4、总结

1、什么是langchainGo

langchaingo是langchain的go语言实现版本

2、langchainGo的官方地址

官网:[https://tmc.github.io/langchaingo/docs/getting-started/guide-openai][https://tmc.github.io/langchaingo/docs/getting-started/guide-openai]

github:[https://github.com/tmc/langchaingo/tree/main][https://github.com/tmc/langchaingo/tree/main]

3、LangChainGo with OpenAI

3-1、前置准备
  • 下载并安装好Go [https://go.dev/doc/install][https://go.dev/doc/install]

  • 获取到openAi的key(这里可以使用其他大模型提供的能力,如阿里的百炼平台[百炼的apiKey获取方式][https://bailian.console.aliyun.com/?utm_content=se_1021226628&tab=api#/api/?type=model&url=https%3A%2F%2Fhelp.aliyun.com%2Fdocument_detail%2F2712195.html&renderType=iframe])

  • 创建.env文件

    这里以百炼的地址和apiKey为例

    OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
    OPENAI_API_KEY=sk-xxxx  //you api key
    
3-2、安装依赖库
go get github.com/tmc/langchaingo
go get github.com/joho/godotenv
3-3、新建模型客户端
package modelimport ("github.com/joho/godotenv""github.com/tmc/langchaingo/llms/openai""log""os"
)func GetLlm(model string, embeddingModel string) *openai.LLM {if embeddingModel == "" {embeddingModel = "text-embedding-v3"}if model == "" {model = "qwen-max"}// 加载 .env 文件err := godotenv.Load()if err != nil {log.Println("Error loading .env file:", err)}// 读取环境变量baseUrl := os.Getenv("OPENAI_BASE_URL")apiKey := os.Getenv("OPENAI_API_KEY")llm, err := openai.New(openai.WithBaseURL(baseUrl),openai.WithToken(apiKey), openai.WithModel(model),openai.WithEmbeddingModel(embeddingModel))if err != nil {log.Fatal(err)}return llm
}

配置参数和环境变量,创建一个连接到 OpenAI 或阿里云 Qwen 的语言模型实例。

3-4、使用模型进行对话
package mainimport ("context""fmt""github.com/tmc/langchaingo/llms""langchain-go-demo/model""log"
)// 演示使用langchain-go的llms包,调用qwen-max模型,生成文本
func main() {llm := model.GetLlm("qwen-max", "")ctx := context.Background()completion, err := llms.GenerateFromSinglePrompt(ctx, llm, "Hi qwen, write a poem about golang powered AI systems",llms.WithTemperature(0.8),// 流式输出llms.WithStreamingFunc(func(ctx context.Context, chunk []byte) error {fmt.Print(string(chunk))return nil}),)if err != nil {log.Fatal(err)}_ = completion
}

上面的代码通过LangChain-Go 库调用 Qwen-Max 模型 生成诗歌。这里使用了流式输出的,

chunk:每次模型生成的新文本片段。

4、总结

LangChainGo是LangChain的Go语言实现,本文演示如果通过LangChain-Go 与大模型进行交互。


文章转载自:

http://b8IHJoic.psxcr.cn
http://dRpmUwq6.psxcr.cn
http://rvM0QvuY.psxcr.cn
http://rO6sVzwo.psxcr.cn
http://98053fis.psxcr.cn
http://xtL2yTO2.psxcr.cn
http://lkZIFEDM.psxcr.cn
http://WuiNecFp.psxcr.cn
http://z6wr1rns.psxcr.cn
http://LhrizOfJ.psxcr.cn
http://yBO6moJp.psxcr.cn
http://9WJZv1Ul.psxcr.cn
http://s8wH5C8g.psxcr.cn
http://MxIwi0b6.psxcr.cn
http://QixSsZp6.psxcr.cn
http://vN4fXxZ2.psxcr.cn
http://pzsIMjRx.psxcr.cn
http://sCNOG0Oc.psxcr.cn
http://irElnvPL.psxcr.cn
http://UFjfv0Oy.psxcr.cn
http://y9WGn4r6.psxcr.cn
http://16h3x2nr.psxcr.cn
http://SlWZI7La.psxcr.cn
http://LWZ21585.psxcr.cn
http://pvr2qnf4.psxcr.cn
http://4bNZiepW.psxcr.cn
http://b2Dxhc2h.psxcr.cn
http://faddFwQK.psxcr.cn
http://kZtS1Vqc.psxcr.cn
http://pn72UD9o.psxcr.cn
http://www.dtcms.com/wzjs/777348.html

相关文章:

  • 网站建设怎样找客户巴顿品牌设计
  • 创业谷网站建设方案公司建设网站流程
  • 做网站的外包能学到什么做淘宝客需要建网站吗
  • 德国设计网站大全网站建网站建设企业电话
  • 济南精品建站外包公司价格做列表的网站
  • 旅游攻略网站DW怎么做电商网站
  • 如何上传网站到凡科网下载河北公众号官方版安装
  • 宁金诚信建设网站织梦转WordPress插件
  • 拼客多网站多少钱可以做网站组建
  • 莒县建设局门户网站浙江东阳市网站建设公司
  • 自己做的网站怎么赚钱吗荥阳建设网站
  • 怎么自己搭建一个博客网站wordpress下载面板美化
  • 接兼职建设网站软件定制开发网站建设
  • 做ppt的图片素材网站有哪些建设网站建设哪里好
  • wordpress网站后台要怎么登陆上海口碑最好的家装
  • 南阳网站建设赛科另类投资公司网站建设规定
  • 网页设计师网站网站开发端
  • 建设网站参数在合肥做网站前端月薪大概多少钱
  • 河北三河建设局网站能翻到国外的浏览器
  • 做网站公司关键词嘉兴论坛网站建设
  • 千助网站公司红酒营销型网站建设
  • 工体做网站的公司产品详情页模板免费
  • 做网站是不是要模板旅行社建设网站
  • 深圳网站建设网站优化服务网站优化 月付费
  • 有啦域名网站怎么做中山祥云做的网站怎么样百度百科
  • 开封专业做网站公司wordpress图片上传慢
  • 苏州网站推广服务沈阳商城网站开发
  • error 403 网站拒绝显示django网站开发视频教程
  • 人社门户网站建设方案网站开发设计流程时间表
  • 贵州网站制作公司建立网站的元素有哪些