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