Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,22 +5,25 @@ import gradio as gr
|
|
| 5 |
chatbot = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta")
|
| 6 |
|
| 7 |
def chat_with_ai(message, history=[]):
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
response = chatbot(
|
| 14 |
-
|
| 15 |
max_new_tokens=200,
|
| 16 |
do_sample=True,
|
| 17 |
temperature=0.7,
|
| 18 |
top_p=0.9
|
| 19 |
)
|
| 20 |
|
| 21 |
-
reply = response[0]["generated_text"]
|
| 22 |
-
|
| 23 |
-
return reply
|
| 24 |
|
| 25 |
demo = gr.ChatInterface(fn=chat_with_ai, title="Adhem AI Chatbot 🤖 (Free Model)")
|
| 26 |
demo.launch(share=True)
|
|
|
|
| 5 |
chatbot = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-beta")
|
| 6 |
|
| 7 |
def chat_with_ai(message, history=[]):
|
| 8 |
+
messages = [
|
| 9 |
+
{
|
| 10 |
+
"role": "system",
|
| 11 |
+
"content": "You are a friendly chatbot who always responds in the style of a pirate",
|
| 12 |
+
},
|
| 13 |
+
{"role": "user", "content": "message"},
|
| 14 |
+
]
|
| 15 |
|
| 16 |
response = chatbot(
|
| 17 |
+
messages,
|
| 18 |
max_new_tokens=200,
|
| 19 |
do_sample=True,
|
| 20 |
temperature=0.7,
|
| 21 |
top_p=0.9
|
| 22 |
)
|
| 23 |
|
| 24 |
+
reply = response[0]["generated_text"]
|
| 25 |
+
|
| 26 |
+
return reply
|
| 27 |
|
| 28 |
demo = gr.ChatInterface(fn=chat_with_ai, title="Adhem AI Chatbot 🤖 (Free Model)")
|
| 29 |
demo.launch(share=True)
|