shravbx commited on
Commit
2554a5e
·
verified ·
1 Parent(s): befe52d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -1,8 +1,17 @@
1
  import gradio as gr #importing gradio
2
- import random
3
- def respond_y_or_n_randomly(message, history):
4
- responses = ["yes","no"]
5
- return random.choice(responses)
 
 
 
 
 
 
 
 
 
6
  #all print statements will be shown in the log after committing the changes to the main.
7
- chatbot = gr.ChatInterface(respond_y_or_n_randomly, type = 'messages', title="Yes no bot") #builds chatbot UI - conversation history and user input
8
  chatbot.launch() # launches the chatbot.
 
1
  import gradio as gr #importing gradio
2
+ import random as rn
3
+ from huggingface_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(
11
+ messages,
12
+ max_tokens=100
13
+ )
14
+ return response['choices'][0]['message']['content'].strip()
15
  #all print statements will be shown in the log after committing the changes to the main.
16
+ chatbot = gr.ChatInterface(respond, type = 'messages', title="Chatbot V2.0") #builds chatbot UI - conversation history and user input
17
  chatbot.launch() # launches the chatbot.