Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
print("Hello,world!")
|
| 9 |
|
| 10 |
-
chatbot = gr.ChatInterface(
|
| 11 |
|
| 12 |
chatbot.launch()
|
| 13 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
client = InferenceClient("microsoft/phi-4")
|
| 5 |
+
|
| 6 |
+
def respond(message, history):
|
| 7 |
+
messages({"role": "system", "content": "You are a friendly chatbot."})
|
| 8 |
+
if history:
|
| 9 |
+
messages.extend(history)
|
| 10 |
+
|
| 11 |
+
messages.append({"role":,"user","content": message})
|
| 12 |
+
response = client.chat_completion(
|
| 13 |
+
messages,
|
| 14 |
+
max_tokens=100
|
| 15 |
+
)
|
| 16 |
+
return response['choices'][0]['message']['content'].strip()
|
| 17 |
|
| 18 |
print("Hello,world!")
|
| 19 |
|
| 20 |
+
chatbot = gr.ChatInterface(respond, type = "messages", title = "Answer Machine") #chatbot UI - conversation history and user input
|
| 21 |
|
| 22 |
chatbot.launch()
|
| 23 |
|