VJ-Rising commited on
Commit
66b3535
·
verified ·
1 Parent(s): de46bf7

MY FIRST EVER PROPER CHATBOT (HOPEFULLYYY)

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -1,8 +1,22 @@
1
  import gradio as gr
2
  import random
 
 
 
3
 
4
  def random_response(message, history):
5
- response_options = ["nope", "yeah", "no", "yes", "absolutely not", "absolutely"]
 
 
 
 
 
 
 
 
 
 
 
6
  return random.choice(response_options)
7
 
8
  chatbot = gr.ChatInterface(random_response, title = "Random yes/no Echo Dot")
 
1
  import gradio as gr
2
  import random
3
+ from huggingface_hub import InferenceClient
4
+
5
+ client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
6
 
7
  def random_response(message, history):
8
+ messages = [{"role":"system", "content" : "You are a friendly chatbot."}]
9
+
10
+ if history:
11
+ messages.extend(history)
12
+ messages.append(["role":"user", "content":message])
13
+
14
+ response = client.chat_completion(
15
+ messages,
16
+ max_tokens = 100
17
+ )
18
+ return response.choices[0].message.content.strip()
19
+ #response_options = ["nope", "yeah", "no", "yes", "absolutely not", "absolutely"]
20
  return random.choice(response_options)
21
 
22
  chatbot = gr.ChatInterface(random_response, title = "Random yes/no Echo Dot")