赞
踩
DASHSCOPE_API_KEY 需要自己去以下网站申请: https://help.aliyun.com/document_detail/611472.html?spm=a2c4g.2399481.0.0
from langchain.chains import LLMChain from langchain_core.prompts import ChatPromptTemplate from langchain_community.llms import Tongyi import os os.environ["DASHSCOPE_API_KEY"] = "sk-cc1c8314fdbd43ceaf26ec1824d5dd3b" llm = Tongyi() prompt = ChatPromptTemplate.from_template(""" {input} """ ) chain = LLMChain(llm=llm,prompt=prompt) print(chain.invoke("帮我写一幅中国春节的对联"))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。