LangChainGo入门指南:Go语言实现与OpenAI/Qwen模型集成实战

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 (
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值