Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random #added here
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
print("hello, Princess")
|
| 7 |
-
chatbot = gr.ChatInterface(
|
| 8 |
|
| 9 |
chatbot.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random #added here
|
| 3 |
+
from huggingfaceface_hub import InferenceClient
|
| 4 |
+
client = InferenceClient("microsoft/phi-4")
|
| 5 |
+
def respond(message,history):
|
| 6 |
+
messages = [{"role":"system", "content": "You are a friendly chatbot!"}]
|
| 7 |
+
if history:
|
| 8 |
+
messages.extend(history)
|
| 9 |
+
messages.append({"role": "user", "content":message})
|
| 10 |
+
response = client.chat_completion(messages, max_token=100)
|
| 11 |
+
returnresponse['choices'][0]['message']['content'].strip()
|
| 12 |
print("hello, Princess")
|
| 13 |
+
chatbot = gr.ChatInterface(respond, type="messages", title="Personal ChatWoman")
|
| 14 |
|
| 15 |
chatbot.launch()
|