Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -178,27 +178,22 @@ def claude_respond(
|
|
| 178 |
api_key=anthropic_api_key,
|
| 179 |
)
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
]
|
| 184 |
-
|
| 185 |
for human, assistant in chat_history:
|
| 186 |
if human:
|
| 187 |
-
|
| 188 |
if assistant:
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
messages.append({"role": "user", "content": message})
|
| 192 |
|
| 193 |
try:
|
| 194 |
response = client.completions.create(
|
| 195 |
model="claude-3-haiku-20240307",
|
|
|
|
| 196 |
max_tokens_to_sample=max_tokens,
|
| 197 |
temperature=temperature,
|
| 198 |
top_p=top_p,
|
| 199 |
-
messages=[
|
| 200 |
-
{"role": "user", "content": message}
|
| 201 |
-
],
|
| 202 |
)
|
| 203 |
assistant_message = response.completion
|
| 204 |
chat_history.append((message, assistant_message))
|
|
|
|
| 178 |
api_key=anthropic_api_key,
|
| 179 |
)
|
| 180 |
|
| 181 |
+
# 대화 기록을 하나의 프롬프트 문자열로 변환
|
| 182 |
+
prompt = f"{system_message}\n"
|
|
|
|
|
|
|
| 183 |
for human, assistant in chat_history:
|
| 184 |
if human:
|
| 185 |
+
prompt += f"Human: {human}\n"
|
| 186 |
if assistant:
|
| 187 |
+
prompt += f"Assistant: {assistant}\n"
|
| 188 |
+
prompt += f"Human: {message}\nAssistant:"
|
|
|
|
| 189 |
|
| 190 |
try:
|
| 191 |
response = client.completions.create(
|
| 192 |
model="claude-3-haiku-20240307",
|
| 193 |
+
prompt=prompt,
|
| 194 |
max_tokens_to_sample=max_tokens,
|
| 195 |
temperature=temperature,
|
| 196 |
top_p=top_p,
|
|
|
|
|
|
|
|
|
|
| 197 |
)
|
| 198 |
assistant_message = response.completion
|
| 199 |
chat_history.append((message, assistant_message))
|