'commit'
This commit is contained in:
@@ -54,11 +54,12 @@ async def get_llm_response_async(query_text: str, stream: bool = True):
|
||||
yield f"处理请求时发生异常: {str(e)}"
|
||||
|
||||
# 保留原同步函数
|
||||
def get_llm_response(query_text: str, stream: bool = True):
|
||||
def get_llm_response(query_text: str, stream: bool = True, system_prompt: str = 'You are a helpful assistant.'):
|
||||
"""
|
||||
获取大模型的响应
|
||||
@param query_text: 查询文本
|
||||
@param stream: 是否使用流式输出
|
||||
@param system_prompt: 系统提示文本,默认为'You are a helpful assistant.'
|
||||
@return: 完整响应文本
|
||||
"""
|
||||
client = OpenAI(
|
||||
@@ -70,7 +71,7 @@ def get_llm_response(query_text: str, stream: bool = True):
|
||||
completion = client.chat.completions.create(
|
||||
model=LLM_MODEL_NAME,
|
||||
messages=[
|
||||
{'role': 'system', 'content': 'You are a helpful assistant.'},
|
||||
{'role': 'system', 'content': system_prompt},
|
||||
{'role': 'user', 'content': query_text}
|
||||
],
|
||||
stream=stream
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user