Spaces:
Runtime error
Runtime error
Update chatllm.py
Browse filesfix bug: add api key
- chatllm.py +1 -8
chatllm.py
CHANGED
@@ -73,14 +73,6 @@ class ChatLLM(LLM):
|
|
73 |
|
74 |
if self.model == 'ChatGPT':
|
75 |
|
76 |
-
OPENAI_API_KEY = os.getenv('openai_api_key')
|
77 |
-
OPENAI_URL = "https://api.openai.com/v1/chat/completions"
|
78 |
-
|
79 |
-
headers = {
|
80 |
-
"Authorization": f"Bearer {OPENAI_API_KEY}",
|
81 |
-
"Content-Type": "application/json"
|
82 |
-
}
|
83 |
-
|
84 |
# 添加过往问答记录,实现连贯多轮对话
|
85 |
messages = [{"role": "system", "content": "You are a helpful assistant."}]
|
86 |
for data in self.history:
|
@@ -88,6 +80,7 @@ class ChatLLM(LLM):
|
|
88 |
messages.append({"role": "user", "content": prompt})
|
89 |
|
90 |
# 配置OPENAI模型参数
|
|
|
91 |
response = openai.Completion.create(
|
92 |
model = 'gpt-3.5-turbo',
|
93 |
messages = messages,
|
|
|
73 |
|
74 |
if self.model == 'ChatGPT':
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
# 添加过往问答记录,实现连贯多轮对话
|
77 |
messages = [{"role": "system", "content": "You are a helpful assistant."}]
|
78 |
for data in self.history:
|
|
|
80 |
messages.append({"role": "user", "content": prompt})
|
81 |
|
82 |
# 配置OPENAI模型参数
|
83 |
+
openai.api_key = os.getenv('openai_api_key')
|
84 |
response = openai.Completion.create(
|
85 |
model = 'gpt-3.5-turbo',
|
86 |
messages = messages,
|