Spaces:
Sleeping
Sleeping
Tim Seufert commited on
Commit ·
691080c
1
Parent(s): 4defe67
blargh
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ def respond(message, history):
|
|
| 22 |
"""Einfache Antwortfunktion für das Gradio-Chatinterface"""
|
| 23 |
try:
|
| 24 |
|
| 25 |
-
|
| 26 |
model='command-r-plus-08-2024',
|
| 27 |
message=f"{prompt} '{message}'",
|
| 28 |
temperature=0.3,
|
|
@@ -30,8 +30,17 @@ def respond(message, history):
|
|
| 30 |
prompt_truncation='AUTO',
|
| 31 |
connectors=[{"id": "web-search"}]
|
| 32 |
)
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
except Exception as e:
|
| 36 |
print(f"Fehler: {str(e)}")
|
| 37 |
return f"Es ist ein Fehler aufgetreten: {str(e)}"
|
|
|
|
| 22 |
"""Einfache Antwortfunktion für das Gradio-Chatinterface"""
|
| 23 |
try:
|
| 24 |
|
| 25 |
+
stream = co.chat_stream(
|
| 26 |
model='command-r-plus-08-2024',
|
| 27 |
message=f"{prompt} '{message}'",
|
| 28 |
temperature=0.3,
|
|
|
|
| 30 |
prompt_truncation='AUTO',
|
| 31 |
connectors=[{"id": "web-search"}]
|
| 32 |
)
|
| 33 |
+
# Collect response from stream
|
| 34 |
+
response = "".join([
|
| 35 |
+
event.text
|
| 36 |
+
for event in stream
|
| 37 |
+
if event.event_type == "text-generation"
|
| 38 |
+
])
|
| 39 |
+
|
| 40 |
+
# Update chat history
|
| 41 |
+
history.append((message, response))
|
| 42 |
+
return "", history
|
| 43 |
+
|
| 44 |
except Exception as e:
|
| 45 |
print(f"Fehler: {str(e)}")
|
| 46 |
return f"Es ist ein Fehler aufgetreten: {str(e)}"
|