Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -147,7 +147,7 @@ def chatgpt_respond(
|
|
| 147 |
|
| 148 |
try:
|
| 149 |
response = openai.ChatCompletion.create(
|
| 150 |
-
model="gpt-
|
| 151 |
messages=messages,
|
| 152 |
max_tokens=max_tokens,
|
| 153 |
temperature=temperature,
|
|
@@ -178,24 +178,24 @@ def claude_respond(
|
|
| 178 |
api_key=anthropic_api_key,
|
| 179 |
)
|
| 180 |
|
| 181 |
-
# 대화 기록을 하나의
|
| 182 |
-
|
| 183 |
for human, assistant in chat_history:
|
| 184 |
if human:
|
| 185 |
-
|
| 186 |
if assistant:
|
| 187 |
-
|
| 188 |
-
|
| 189 |
|
| 190 |
try:
|
| 191 |
-
response = client.
|
| 192 |
-
model="claude-3
|
| 193 |
-
|
| 194 |
-
max_tokens_to_sample=max_tokens,
|
| 195 |
temperature=temperature,
|
| 196 |
top_p=top_p,
|
|
|
|
| 197 |
)
|
| 198 |
-
assistant_message = response
|
| 199 |
chat_history.append((message, assistant_message))
|
| 200 |
return chat_history
|
| 201 |
except Exception as e:
|
|
|
|
| 147 |
|
| 148 |
try:
|
| 149 |
response = openai.ChatCompletion.create(
|
| 150 |
+
model="gpt-4", # 올바른 모델 ID로 수정 (예: "gpt-4")
|
| 151 |
messages=messages,
|
| 152 |
max_tokens=max_tokens,
|
| 153 |
temperature=temperature,
|
|
|
|
| 178 |
api_key=anthropic_api_key,
|
| 179 |
)
|
| 180 |
|
| 181 |
+
# 대화 기록을 하나의 메시지 리스트로 변환
|
| 182 |
+
messages = [{"role": "system", "content": system_message}]
|
| 183 |
for human, assistant in chat_history:
|
| 184 |
if human:
|
| 185 |
+
messages.append({"role": "user", "content": human})
|
| 186 |
if assistant:
|
| 187 |
+
messages.append({"role": "assistant", "content": assistant})
|
| 188 |
+
messages.append({"role": "user", "content": message})
|
| 189 |
|
| 190 |
try:
|
| 191 |
+
response = client.messages.create(
|
| 192 |
+
model="claude-3.0", # 사용 가능한 Claude 모델로 수정
|
| 193 |
+
max_tokens=max_tokens,
|
|
|
|
| 194 |
temperature=temperature,
|
| 195 |
top_p=top_p,
|
| 196 |
+
messages=messages,
|
| 197 |
)
|
| 198 |
+
assistant_message = response['completion']
|
| 199 |
chat_history.append((message, assistant_message))
|
| 200 |
return chat_history
|
| 201 |
except Exception as e:
|