Spaces:
Runtime error
Runtime error
Commit Β·
bb73263
1
Parent(s): e3863f9
commit 000435
Browse files
app.py
CHANGED
|
@@ -79,9 +79,12 @@ chain = RunnableBranch(
|
|
| 79 |
|
| 80 |
# Reply generator
|
| 81 |
@GPU
|
| 82 |
-
def
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
# Flask routes
|
| 87 |
@app.route("/")
|
|
|
|
| 79 |
|
| 80 |
# Reply generator
|
| 81 |
@GPU
|
| 82 |
+
def generate_full_reply(message, history):
|
| 83 |
+
system_prompt = "You are a helpful and concise AI assistant. Answer briefly and politely, in one or two sentences."
|
| 84 |
+
messages = [{"role": "system", "content": system_prompt}] + history + [{"role": "user", "content": message}]
|
| 85 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 86 |
+
output = pipe(prompt, max_new_tokens=512, do_sample=True, temperature=0.7)[0]['generated_text']
|
| 87 |
+
return output.split(prompt)[-1].strip()
|
| 88 |
|
| 89 |
# Flask routes
|
| 90 |
@app.route("/")
|