python
import os
from langchain_community.llms import QianfanLLMEndpoint
os.environ["QIANFAN_AK"] = ""
os.environ["QIANFAN_SK"] = ""
llm_wenxin = QianfanLLMEndpoint()
res = llm_wenxin.invoke("中国国庆日是哪一天?")
print(res)
1、安装langchain
python
#安装langchain环境
pip install langchain==0.3.3 openai -i https://mirrors.aliyun.com/pypi/simple
#灵积模型服务
pip install dashscope -i https://mirrors.aliyun.com/pypi/simple
#安装第三方集成,就是各种大语言模型
pip install langchain-community==0.3.2 -i https://mirrors.aliyun.com/pypi/simple
#加载环境的工具
pip install python-dotenv
2、前期准备工作
**第一个准备工作:**文新一言的key值申请
传送门:百度智能云-云智一体深入产业
2.1.登录或者注册
2.2 实名认证
登录后进行实名认证

2.3 创建建新应用




2.4 获取key
选择自己想要的应用,获取key

3、使用langchain
pip install qianfan -i https://mirrors.aliyun.com/pypi/simple
python
import os
from langchain_community.llms import QianfanLLMEndpoint
os.environ["QIANFAN_AK"] = ""
os.environ["QIANFAN_SK"] = ""
llm_wenxin = QianfanLLMEndpoint()
res = llm_wenxin.invoke("中国国庆日是哪一天?")
print(res)