You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from langchain_core . messages import HumanMessage
from langchain_core . prompts import ChatPromptTemplate , MessagesPlaceholder , \
FewShotChatMessagePromptTemplate , PromptTemplate
from langchain_openai import ChatOpenAI
from env_util import DASHSCOPE_API_KEY , DASHSCOPE_BASE_URL
# llm对象就是调用大模型的对象
llm = ChatOpenAI (
model = " qwen-plus " ,
base_url = DASHSCOPE_BASE_URL ,
api_key = DASHSCOPE_API_KEY ,
temperature = 0.8 ,
) ;
s = PromptTemplate . from_template ( " 你是个相声演员,给我来段 {topic} 。 " ) ;
print ( s )
prompt = (
PromptTemplate . from_template ( " 你是个相声演员,给我来段 {topic} 。 " )
+ " , 要求: 1、内容搞笑。"
+ " 2、输出采用 {language} "
)
print ( prompt )
chain = prompt | llm
resp = chain . invoke (
{ " topic " : " 贯口 " , " language " : " English " }
)
print ( resp )