Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ def generate_response(prompt):
|
|
12 |
"Authorization": f"Bearer {API_KEY}",
|
13 |
}
|
14 |
data = {
|
15 |
-
"model": "gpt-3.5-turbo",
|
16 |
"prompt": prompt,
|
17 |
"temperature": 0.7,
|
18 |
"max_tokens": 150,
|
@@ -21,7 +21,6 @@ def generate_response(prompt):
|
|
21 |
response = requests.post(endpoint, headers=headers, json=data)
|
22 |
return response.json()["choices"][0]["text"]
|
23 |
|
24 |
-
# Определение функций для взаимодействия с чатом
|
25 |
def send_message(messages, new_message):
|
26 |
messages.append(new_message)
|
27 |
return messages
|
@@ -44,10 +43,9 @@ iface = gr.Interface(
|
|
44 |
theme="compact",
|
45 |
)
|
46 |
|
47 |
-
|
48 |
-
iface.
|
49 |
-
iface.
|
50 |
-
iface.
|
51 |
-
iface.add(gr.Button("Изменить", lambda edit_params: edit_message(iface.data.input_message, *map(str.strip, edit_params.split(','))), key="edit_button"))
|
52 |
|
53 |
iface.launch()
|
|
|
12 |
"Authorization": f"Bearer {API_KEY}",
|
13 |
}
|
14 |
data = {
|
15 |
+
"model": "gpt-3.5-turbo",
|
16 |
"prompt": prompt,
|
17 |
"temperature": 0.7,
|
18 |
"max_tokens": 150,
|
|
|
21 |
response = requests.post(endpoint, headers=headers, json=data)
|
22 |
return response.json()["choices"][0]["text"]
|
23 |
|
|
|
24 |
def send_message(messages, new_message):
|
25 |
messages.append(new_message)
|
26 |
return messages
|
|
|
43 |
theme="compact",
|
44 |
)
|
45 |
|
46 |
+
iface.text("Удалить сообщение (индекс):")
|
47 |
+
iface.button("Удалить", lambda delete_index: delete_message(iface.data.input_message, int(delete_index)))
|
48 |
+
iface.text("Изменить сообщение (индекс, новое сообщение):")
|
49 |
+
iface.button("Изменить", lambda edit_params: edit_message(iface.data.input_message, *map(str.strip, edit_params.split(','))))
|
|
|
50 |
|
51 |
iface.launch()
|