From f61a9ad6e6fd4574d1cd0f70b365c5222dbe661c Mon Sep 17 00:00:00 2001 From: 0Xiao0 <511201264@qq.com> Date: Thu, 30 May 2024 11:25:57 +0800 Subject: [PATCH] Header changed --- src/blackbox/chat.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/blackbox/chat.py b/src/blackbox/chat.py index a0bc1bd..d996065 100644 --- a/src/blackbox/chat.py +++ b/src/blackbox/chat.py @@ -24,7 +24,7 @@ class Chat(Blackbox): return isinstance(data, list) # model_name有 Qwen1.5-14B-Chat , internlm2-chat-20b - @logging_time() + #@logging_time() def processing(self, prompt: str, context: list, settings: dict) -> str: if settings is None: @@ -121,11 +121,17 @@ class Chat(Blackbox): url = 'https://api.openai.com/v1/completions' # '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' key = user_model_key - + header = { + 'Content-Type': 'application/json', + 'Authorization': "Bearer " + key + } # 自定义model else: url = user_model_url key = user_model_key + header = { + 'Content-Type': 'application/json', + } prompt_template = [ @@ -149,11 +155,6 @@ class Chat(Blackbox): "stop": str(user_stop) } - header = { - 'Content-Type': 'application/json', - 'Authorization': "Bearer " + key - } - fastchat_response = requests.post(url, json=chat_inputs, headers=header) return fastchat_response.json()["choices"][0]["message"]["content"]