KatieKhamarkhanova commited on
Commit
d62c7b0
·
verified ·
1 Parent(s): 2806cd5
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -1,8 +1,16 @@
1
  import random
2
  import gradio as gr
 
3
 
4
- # def echo(message, history):
5
- # return message
 
 
 
 
 
 
 
6
 
7
  def magic_ball(message, history):
8
  return random.choice(["Yes, definitely.",
@@ -16,6 +24,6 @@ def magic_ball(message, history):
16
 
17
  print("Hello, world!")
18
 
19
- chatbot = gr.ChatInterface(magic_ball, type="messages", description="Ask me any question!", title="Magic 8 Ball")
20
 
21
  chatbot.launch()
 
1
  import random
2
  import gradio as gr
3
+ from huggingface_hub import InferenceClient
4
 
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
+ messages.append({"role": "user", "content": message})
12
+ response = client.chat_completion(messages, max_tokens = 100)
13
+ return response['choices'][0]['message']['content'].strip()
14
 
15
  def magic_ball(message, history):
16
  return random.choice(["Yes, definitely.",
 
24
 
25
  print("Hello, world!")
26
 
27
+ chatbot = gr.ChatInterface(respond, type="messages", description="Ask me any question!", title="Magic 8 Ball")
28
 
29
  chatbot.launch()