Ifeeab05 commited on
Commit
b9fd8e7
·
verified ·
1 Parent(s): f41069b

Turned Random into General ChatBot

Browse files

TOOK AWAY random output and replaces with relevant ig now its more generative and transformed

Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -1,9 +1,23 @@
1
  import gradio as gr
2
- import random as rn
3
- def respond_yes_no_randomly(message, history):
4
- responses = ["Yes", "No", "Maybe"]
5
- return rn.choices(responses) #added here
6
-
7
- print("hELLO World")
8
- chatbot = gr.ChatInterface(respond_yes_no_randomly, type="messages", title="Yes No Bot") #chatbot UI - convo history & user input
9
- chatbot.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ #import random as rn
3
+ from huggingface_hub import InterferenceClient
4
+
5
+ client = IterferenceClient("microsoft/phi-4")
6
+
7
+ def respond(message, history):
8
+ messages = [{"role": "system", "content": "You are a friendly chatbot."}]
9
+
10
+ if history:
11
+ message.extend(history)
12
+
13
+ messages.append ({"role": "user", "content":message})
14
+
15
+ responses = client.chat_completion(
16
+ messages,
17
+ max_token=100
18
+ )
19
+ return response['choices'][0]['message']['content'].strip() #added here
20
+
21
+ chatbot = gr.ChatInterface(respond, type="messages", title="Friendly ChatBot") #chatbot UI - convo history & user input
22
+
23
+ chatbot.launch()