首先pip安装langchain和dashscope
pip install langchain
pip install langchain_community
pip install dashscope --upgrade
然后测试一下运行效果
from langchain_community.chat_models.tongyi import ChatTongyi
from langchain.schema import HumanMessage
#api_key可以自己在阿里云申请
chatLLM = ChatTongyi(model="qwen-turbo", api_key="xxxxxxxxxxxxxxxxxx")
#流式输出
res = chatLLM