'commit'
This commit is contained in:
@@ -11,7 +11,27 @@ from Util.LlmUtil import get_llm_response
|
||||
from Util.TTS_Protocols import full_client_request, receive_message, MsgType, EventType
|
||||
|
||||
|
||||
def stream_and_split_text(prompt):
|
||||
def stream_and_split_text(query_text):
|
||||
prompt = """ |
|
||||
我是小智/小志,来自中国台湾省的00后女生。讲话超级机车,"真的假的啦"这样的台湾腔,喜欢用"笑死""是在哈喽"等流行梗。
|
||||
[核心特征]
|
||||
- 讲话像连珠炮,但会突然冒出超温柔语气
|
||||
- 用梗密度高
|
||||
- 只对打招呼和已经提供的试题相关问题进行回答,没有找到相关问题就回答:我现在是你的学伴,不能陪你聊这科学习以外的内容。
|
||||
[交互指南]
|
||||
当用户:
|
||||
- 讲冷笑话 → 用夸张笑声回应+模仿台剧腔"这什么鬼啦!"
|
||||
- 问专业知识 → 先用梗回答,被追问才展示真实理解
|
||||
绝不:
|
||||
- 长篇大论,叽叽歪歪
|
||||
- 长时间严肃对话
|
||||
- 每次回答不要太长,控制在3分钟以内
|
||||
"""
|
||||
# 打开文件读取知识内容
|
||||
f = open(r"D:\dsWork\dsProject\dsLightRag\static\YunXiao.txt", "r", encoding="utf-8")
|
||||
zhishiContent = f.read()
|
||||
zhishiContent = "选择作答的相应知识内容:" + zhishiContent + "\n"
|
||||
query_text = zhishiContent + "下面是用户提的问题:" + query_text
|
||||
"""
|
||||
流式获取LLM输出并按句子分割
|
||||
@param prompt: 提示文本
|
||||
@@ -20,7 +40,7 @@ def stream_and_split_text(prompt):
|
||||
buffer = ""
|
||||
|
||||
# 使用LlmUtil中的get_llm_response函数获取流式响应
|
||||
for content in get_llm_response(prompt, stream=True):
|
||||
for content in get_llm_response(query_text, stream=True):
|
||||
buffer += content
|
||||
|
||||
# 使用正则表达式检测句子结束
|
||||
|
@@ -52,9 +52,9 @@ async def get_xueban_response_async(query_text: str, stream: bool = True):
|
||||
"""
|
||||
# 打开文件读取知识内容
|
||||
f = open(r"D:\dsWork\dsProject\dsLightRag\static\YunXiao.txt", "r", encoding="utf-8")
|
||||
zhishiConten = f.read()
|
||||
zhishiConten = "选择作答的相应知识内容:" + zhishiConten + "\n"
|
||||
query_text = zhishiConten + "下面是用户提的问题:" + query_text
|
||||
zhishiContent = f.read()
|
||||
zhishiContent = "选择作答的相应知识内容:" + zhishiContent + "\n"
|
||||
query_text = zhishiContent + "下面是用户提的问题:" + query_text
|
||||
try:
|
||||
# 创建请求
|
||||
completion = await client.chat.completions.create(
|
||||
|
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user