sofiafraga commited on
Commit
54243d9
·
verified ·
1 Parent(s): a8d96fd

created a new chatbox-RAG

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,11 +1,28 @@
1
  import gradio as gr
2
  import random
 
 
 
 
 
3
 
4
  #Importing gradio for chatbox and random for responses
5
 
6
- def respond_yes_or_no(message, history):
7
- responses = ["Yes", "No", "All Signs Point to Yes", "Very doubtful"]
8
- return random.choice(responses)
 
 
 
 
9
 
10
- chatbot = gr.ChatInterface(respond_yes_or_no, type = "messages", theme='d8ahazard/material_design_rd', title = "Magic 8 Ball Bot", description = "This chatbox is a magic 8 ball")
 
 
 
 
 
 
 
 
11
  chatbot.launch()
 
1
  import gradio as gr
2
  import random
3
+ import os
4
+
5
+ from huggingface_hub import InferenceClient
6
+
7
+ client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
  #Importing gradio for chatbox and random for responses
10
 
11
+ def respond(message, history):
12
+ messages = [{"role": "system", "content": "You are a mean chatbox!"}]
13
+
14
+ if history:
15
+ messages.extend(history)
16
+
17
+ messages.append({"role": "user", "content": message})
18
 
19
+ response = client.chat_completion(
20
+ messages,
21
+ max_tokens=100
22
+ )
23
+ return response['choices'][0]['message']['content'].strip()
24
+
25
+
26
+ chatbot = gr.ChatInterface(respond, tupe="messages")
27
+
28
  chatbot.launch()