'commit'
This commit is contained in:
@@ -11,7 +11,7 @@ class ModelInteractor:
|
||||
"Authorization": f"Bearer {self.api_key}"
|
||||
}
|
||||
|
||||
def stream_request(self, model, prompt, temperature=0.7):
|
||||
def stream_request(self, model, prompt, temperature=0.7, chat_history=None):
|
||||
"""
|
||||
发送流式请求到模型API
|
||||
|
||||
@@ -23,12 +23,20 @@ class ModelInteractor:
|
||||
返回:
|
||||
- 无返回值,直接打印流式响应
|
||||
"""
|
||||
# 构建消息列表
|
||||
messages = []
|
||||
# 添加对话历史
|
||||
if chat_history:
|
||||
messages.extend(chat_history)
|
||||
# 添加当前prompt
|
||||
messages.append({
|
||||
"role": "user",
|
||||
"content": prompt
|
||||
})
|
||||
|
||||
payload = {
|
||||
"model": model,
|
||||
"messages": [{
|
||||
"role": "user",
|
||||
"content": prompt
|
||||
}],
|
||||
"messages": messages,
|
||||
"temperature": temperature,
|
||||
"stream": True
|
||||
}
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user