Update app.py
Browse files
app.py
CHANGED
|
@@ -50,7 +50,37 @@ def greet(name):
|
|
| 50 |
print(res)
|
| 51 |
return res
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 56 |
-
iface.launch()
|
|
|
|
| 50 |
print(res)
|
| 51 |
return res
|
| 52 |
|
| 53 |
+
with gr.Blocks() as demo:
|
| 54 |
+
chatbot = gr.Chatbot()
|
| 55 |
+
msg = gr.Textbox()
|
| 56 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 57 |
+
|
| 58 |
+
def respond(message, chat_history):
|
| 59 |
+
print(message)
|
| 60 |
+
print("ok")
|
| 61 |
+
print(chat_history)
|
| 62 |
+
res = llm(f"""
|
| 63 |
+
Use the following pieces of context to answer the query at the end.
|
| 64 |
+
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
| 65 |
+
|
| 66 |
+
${c}
|
| 67 |
+
|
| 68 |
+
Query: ${name}
|
| 69 |
+
|
| 70 |
+
Helpful Answer:
|
| 71 |
+
system_prompt: |
|
| 72 |
+
Agis en tant qu'assistant juridique gabonais Répons au question en français et en citant les articles .
|
| 73 |
+
|
| 74 |
+
""")
|
| 75 |
+
bot_message = res
|
| 76 |
+
chat_history.append((message))
|
| 77 |
+
time.sleep(2)
|
| 78 |
+
return "", chat_history
|
| 79 |
+
|
| 80 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 81 |
+
|
| 82 |
+
demo.launch()
|
| 83 |
|
| 84 |
|
| 85 |
+
#iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 86 |
+
#iface.launch()
|