Spaces:
Runtime error
Runtime error
Commit 路
33df004
1
Parent(s): 67061ec
Add DictaLM 2.0 instruct model 6
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ History = List[Tuple[str, str]]
|
|
| 24 |
Messages = List[Dict[str, str]]
|
| 25 |
|
| 26 |
def clear_session() -> History:
|
| 27 |
-
return
|
| 28 |
|
| 29 |
def history_to_messages(history: History) -> Messages:
|
| 30 |
messages = []
|
|
@@ -64,7 +64,6 @@ def predict():
|
|
| 64 |
do_sample=True,
|
| 65 |
pad_token_id=tokenizer.eos_token_id
|
| 66 |
)
|
| 67 |
-
|
| 68 |
|
| 69 |
# Decode the output
|
| 70 |
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(formatted_text, '').strip()
|
|
@@ -78,9 +77,6 @@ def predict():
|
|
| 78 |
def run_flask():
|
| 79 |
app.run(host='0.0.0.0', port=5000)
|
| 80 |
|
| 81 |
-
def is_hebrew(text: str) -> bool:
|
| 82 |
-
return bool(re.search(r'[\u0590-\u05FF]', text))
|
| 83 |
-
|
| 84 |
# Run Flask in a separate thread
|
| 85 |
threading.Thread(target=run_flask).start()
|
| 86 |
|
|
@@ -102,6 +98,10 @@ def model_chat(query: Optional[str], history: Optional[History]) -> Tuple[Histor
|
|
| 102 |
return history, "Error: Unable to get a response from the model."
|
| 103 |
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
with gr.Blocks(css='''
|
| 107 |
.gr-group {direction: rtl;}
|
|
@@ -166,11 +166,6 @@ with gr.Blocks(css='''
|
|
| 166 |
query = gr.Textbox(placeholder="讛讻谞住 砖讗诇讛 讘注讘专讬转 (讗讜 讘讗谞讙诇讬转!)", rtl=True)
|
| 167 |
clear_btn = gr.Button("谞拽讛 砖讬讞讛")
|
| 168 |
|
| 169 |
-
def respond(query: str, history: History) -> Tuple[History, str]:
|
| 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])
|
|
|
|
| 24 |
Messages = List[Dict[str, str]]
|
| 25 |
|
| 26 |
def clear_session() -> History:
|
| 27 |
+
return []
|
| 28 |
|
| 29 |
def history_to_messages(history: History) -> Messages:
|
| 30 |
messages = []
|
|
|
|
| 64 |
do_sample=True,
|
| 65 |
pad_token_id=tokenizer.eos_token_id
|
| 66 |
)
|
|
|
|
| 67 |
|
| 68 |
# Decode the output
|
| 69 |
prediction = tokenizer.decode(outputs[0], skip_special_tokens=True).replace(formatted_text, '').strip()
|
|
|
|
| 77 |
def run_flask():
|
| 78 |
app.run(host='0.0.0.0', port=5000)
|
| 79 |
|
|
|
|
|
|
|
|
|
|
| 80 |
# Run Flask in a separate thread
|
| 81 |
threading.Thread(target=run_flask).start()
|
| 82 |
|
|
|
|
| 98 |
return history, "Error: Unable to get a response from the model."
|
| 99 |
|
| 100 |
|
| 101 |
+
def respond(query: str, history: History) -> Tuple[History, str]:
|
| 102 |
+
history, _ = model_chat(query, history)
|
| 103 |
+
return history, "" # Only return history and clear the input box
|
| 104 |
+
|
| 105 |
|
| 106 |
with gr.Blocks(css='''
|
| 107 |
.gr-group {direction: rtl;}
|
|
|
|
| 166 |
query = gr.Textbox(placeholder="讛讻谞住 砖讗诇讛 讘注讘专讬转 (讗讜 讘讗谞讙诇讬转!)", rtl=True)
|
| 167 |
clear_btn = gr.Button("谞拽讛 砖讬讞讛")
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
demo_state = gr.State([])
|
| 170 |
|
| 171 |
query.submit(respond, [query, demo_state], [chatbot, query, demo_state])
|