Spaces:
Runtime error
Runtime error
Commit ·
67061ec
1
Parent(s): ba2756c
Add DictaLM 2.0 instruct model 3
Browse files
app.py
CHANGED
|
@@ -85,21 +85,22 @@ def is_hebrew(text: str) -> bool:
|
|
| 85 |
threading.Thread(target=run_flask).start()
|
| 86 |
|
| 87 |
|
| 88 |
-
def model_chat(query: Optional[str], history: Optional[History]) ->
|
| 89 |
if query is None:
|
| 90 |
query = ''
|
| 91 |
if history is None:
|
| 92 |
history = []
|
| 93 |
if not query.strip():
|
| 94 |
-
return
|
| 95 |
|
| 96 |
response = requests.post("http://127.0.0.1:5000/predict", json={"text": query.strip()})
|
| 97 |
if response.status_code == 200:
|
| 98 |
prediction = response.json().get("prediction", "")
|
| 99 |
history.append((query, prediction))
|
| 100 |
-
|
| 101 |
else:
|
| 102 |
-
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
with gr.Blocks(css='''
|
|
@@ -169,6 +170,7 @@ with gr.Blocks(css='''
|
|
| 169 |
history, response = model_chat(query, history)
|
| 170 |
return history, ""
|
| 171 |
|
|
|
|
| 172 |
demo_state = gr.State([])
|
| 173 |
|
| 174 |
query.submit(respond, [query, demo_state], [chatbot, query, demo_state])
|
|
|
|
| 85 |
threading.Thread(target=run_flask).start()
|
| 86 |
|
| 87 |
|
| 88 |
+
def model_chat(query: Optional[str], history: Optional[History]) -> Tuple[History, str]:
|
| 89 |
if query is None:
|
| 90 |
query = ''
|
| 91 |
if history is None:
|
| 92 |
history = []
|
| 93 |
if not query.strip():
|
| 94 |
+
return history, ""
|
| 95 |
|
| 96 |
response = requests.post("http://127.0.0.1:5000/predict", json={"text": query.strip()})
|
| 97 |
if response.status_code == 200:
|
| 98 |
prediction = response.json().get("prediction", "")
|
| 99 |
history.append((query, prediction))
|
| 100 |
+
return history, prediction
|
| 101 |
else:
|
| 102 |
+
return history, "Error: Unable to get a response from the model."
|
| 103 |
+
|
| 104 |
|
| 105 |
|
| 106 |
with gr.Blocks(css='''
|
|
|
|
| 170 |
history, response = model_chat(query, history)
|
| 171 |
return history, ""
|
| 172 |
|
| 173 |
+
|
| 174 |
demo_state = gr.State([])
|
| 175 |
|
| 176 |
query.submit(respond, [query, demo_state], [chatbot, query, demo_state])
|