目录
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 model
import (

最低0.47元/天 解锁文章
1227

被折叠的 条评论
为什么被折叠?



