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