Spaces:
Sleeping
Sleeping
Commit
β’
14782c9
1
Parent(s):
dd9edd5
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
import ollama
|
3 |
|
4 |
-
def
|
5 |
-
|
6 |
-
for query, response in history:
|
7 |
-
chat_history.append({"role": "user", "content": query})
|
8 |
-
chat_history.append({"role": "assistant", "content": response})
|
9 |
-
chat_history.append({"role": "user", "content": msg})
|
10 |
-
return chat_history
|
11 |
|
12 |
-
|
13 |
-
chat_history = format_history(msg, history, system_prompt)
|
14 |
-
response = ollama.chat(model='llama2', stream=True, messages=chat_history)
|
15 |
-
message = ""
|
16 |
-
for partial_resp in response:
|
17 |
-
token = partial_resp["message"]["content"]
|
18 |
-
message += token
|
19 |
-
yield message
|
20 |
|
21 |
-
|
22 |
-
generate_response,
|
23 |
-
chatbot=gr.Chatbot(
|
24 |
-
avatar_images=["cx.jpg", "agent.jpg"],
|
25 |
-
height="64vh"
|
26 |
-
),
|
27 |
-
additional_inputs=[
|
28 |
-
gr.Textbox(
|
29 |
-
"Behave as if you are order placer agent.",
|
30 |
-
label="System Prompt"
|
31 |
-
)
|
32 |
-
],
|
33 |
-
title="Door Treats",
|
34 |
-
description="Please ask any questions you may have about your order.π€",
|
35 |
-
theme="soft",
|
36 |
-
submit_btn="β¬
Send",
|
37 |
-
retry_btn="π Regenerate Response",
|
38 |
-
undo_btn="β© Delete Previous",
|
39 |
-
clear_btn="ποΈ Clear Chat"
|
40 |
-
)
|
41 |
-
|
42 |
-
chatbot.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
def greet(name):
|
4 |
+
return "Hello " + name + "!"
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|