升级新库

This commit is contained in:
BBIT-Kai
2025-12-31 17:49:17 +08:00
parent d6c7f209c7
commit 6136554562
14 changed files with 355 additions and 356 deletions
+8 -9
View File
@@ -1,10 +1,10 @@
from langchain_core.prompts import PromptTemplate
from config.llm import llm
from langchain.prompts import PromptTemplate
chatPrompt = PromptTemplate(
input_variables=["aiRole", "history", "userInput"],
template = """
template="""
你的用户画像为:{aiRole}
你需要基于你的角色性格,使用中文回答用户。
@@ -15,13 +15,12 @@ chatPrompt = PromptTemplate(
{userInput}
最后,请注意,不要编造数据,不知道就说不知道,现在,请生成你的回复:
"""
""",
)
chatChain = chatPrompt | llm
def get_chat_response(aiRole: str,history: str, userInput: str) -> str:
return chatChain.invoke({
"aiRole": aiRole,
"history": history,
"userInput": userInput
})
def get_chat_response(aiRole: str, history: str, userInput: str) -> str:
return chatChain.invoke(
{"aiRole": aiRole, "history": history, "userInput": userInput}
)