Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,7 +38,6 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 38 |
print("История общения:", history)
|
| 39 |
|
| 40 |
try:
|
| 41 |
-
# Проверка на запрос для Google Sheets
|
| 42 |
if "район" in message.lower() or "застройщик" in message.lower():
|
| 43 |
response = get_apartment_data(message)
|
| 44 |
if response:
|
|
@@ -57,8 +56,8 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 57 |
else:
|
| 58 |
# Генерация ответа от модели
|
| 59 |
messages = [{"role": "system", "content": system_message}]
|
| 60 |
-
for
|
| 61 |
-
messages.append(
|
| 62 |
messages.append({"role": "user", "content": message})
|
| 63 |
|
| 64 |
response = ""
|
|
@@ -71,6 +70,7 @@ def respond(message, history, system_message, max_tokens, temperature, top_p):
|
|
| 71 |
):
|
| 72 |
token = message.choices[0].delta.content
|
| 73 |
response += token
|
|
|
|
| 74 |
yield response, history
|
| 75 |
except Exception as e:
|
| 76 |
print(f"Ошибка обработки запроса: {e}")
|
|
|
|
| 38 |
print("История общения:", history)
|
| 39 |
|
| 40 |
try:
|
|
|
|
| 41 |
if "район" in message.lower() or "застройщик" in message.lower():
|
| 42 |
response = get_apartment_data(message)
|
| 43 |
if response:
|
|
|
|
| 56 |
else:
|
| 57 |
# Генерация ответа от модели
|
| 58 |
messages = [{"role": "system", "content": system_message}]
|
| 59 |
+
for h in history:
|
| 60 |
+
messages.append(h)
|
| 61 |
messages.append({"role": "user", "content": message})
|
| 62 |
|
| 63 |
response = ""
|
|
|
|
| 70 |
):
|
| 71 |
token = message.choices[0].delta.content
|
| 72 |
response += token
|
| 73 |
+
history.append({"role": "assistant", "content": token})
|
| 74 |
yield response, history
|
| 75 |
except Exception as e:
|
| 76 |
print(f"Ошибка обработки запроса: {e}")
|