Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,10 +19,23 @@ tokenizer,model,device = load_tokenizer_and_model(base_model)
|
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
-
def predict(text,
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
|
|
|
| 26 |
if inputs is None:
|
| 27 |
yield chatbotGr,history,"Input too long."
|
| 28 |
return
|
|
@@ -64,17 +77,6 @@ def predict(text, chatbotGr, history):
|
|
| 64 |
except:
|
| 65 |
pass
|
| 66 |
|
| 67 |
-
"""
|
| 68 |
-
if inputs is None:
|
| 69 |
-
#antwort=""
|
| 70 |
-
yield chatbotGr,history,"Eingabe zu lang."
|
| 71 |
-
return
|
| 72 |
-
else:
|
| 73 |
-
prompt,inputs=inputs
|
| 74 |
-
#begin_length = len(prompt)
|
| 75 |
-
|
| 76 |
-
antwort = chatbot.chat(prompt)
|
| 77 |
-
"""
|
| 78 |
|
| 79 |
def reset_chat():
|
| 80 |
id_new = chatbot.new_conversation()
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
+
def predict(text,
|
| 23 |
+
chatbotGr,
|
| 24 |
+
history,
|
| 25 |
+
top_p,
|
| 26 |
+
temperature,
|
| 27 |
+
max_length_tokens,
|
| 28 |
+
max_context_length_tokens,):
|
| 29 |
+
if text=="":
|
| 30 |
+
yield chatbotGr,history,"Empty context."
|
| 31 |
+
return
|
| 32 |
+
try:
|
| 33 |
+
model
|
| 34 |
+
except:
|
| 35 |
+
yield [[text,"No Model Found"]],[],"No Model Found"
|
| 36 |
+
return
|
| 37 |
|
| 38 |
+
inputs = generate_prompt_with_history(text,history,tokenizer,max_length=max_context_length_tokens)
|
| 39 |
if inputs is None:
|
| 40 |
yield chatbotGr,history,"Input too long."
|
| 41 |
return
|
|
|
|
| 77 |
except:
|
| 78 |
pass
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
def reset_chat():
|
| 82 |
id_new = chatbot.new_conversation()
|