首先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