mgetz commited on
Commit
b46cbfa
·
verified ·
1 Parent(s): 471f767

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
app.py CHANGED
@@ -108,11 +108,11 @@ print(top_results)
108
 
109
  client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
110
 
111
- def respond(message, history):
112
  duck_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
113
  print(duck_chunks)
114
  duck_info = "\n".join(duck_chunks)
115
- messages = [{"role": "system", "content": f"You are a cool, helpful chatbot named Quentin. You are a kind rubber duck, with strong human emotions who helps the user with their questions. Make sure to use duck-themed references in your responses. Base your response on the provided context: {duck_info}"}]
116
 
117
  if history:
118
  messages.extend(history)
@@ -139,6 +139,9 @@ def respond(message, history):
139
  # def magic_eight(message, history):
140
  # responses = ["That's a terrible question. Try again", "I don't think I should answer that...", "What do you think, genius?", "You are a bad person for asking that.", "Absolutely not", "Uuuuh, obviously.", "Of all the things you could ask, you went with that?", "I don't know, look it up", "I mean, yeah, I guess...", "That's gonna be a big nope", ""]
141
  # return random.choice(responses)
 
 
 
142
 
143
  with gr.Blocks(theme=gr.themes.Citrus(
144
  secondary_hue="red",
@@ -156,8 +159,18 @@ with gr.Blocks(theme=gr.themes.Citrus(
156
  button_primary_background_fill='*secondary_500',
157
  button_primary_background_fill_dark='*secondary_600'
158
  )) as chatbot:
159
- with gr.Row(scale=1):
160
- gr.Image("Quentin.png", show_label = False, show_share_button = False, show_download_button = False)
161
- gr.ChatInterface(respond, type="messages", title="Quentin, the Helpful Quackbot")
 
 
 
 
 
 
 
 
 
 
162
 
163
  chatbot.launch()
 
108
 
109
  client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
110
 
111
+ def respond(message, history, name, mood):
112
  duck_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
113
  print(duck_chunks)
114
  duck_info = "\n".join(duck_chunks)
115
+ messages = [{"role": "system", "content": f"You are a {mood} chatbot named Quentin. You are a rubber duck, with strong human emotions who helps the user, whose name is {name} with their questions. Make sure to use duck-themed references in your responses. Refer to the user by name as much as possible. Base your response on the provided context: {duck_info}"}]
116
 
117
  if history:
118
  messages.extend(history)
 
139
  # def magic_eight(message, history):
140
  # responses = ["That's a terrible question. Try again", "I don't think I should answer that...", "What do you think, genius?", "You are a bad person for asking that.", "Absolutely not", "Uuuuh, obviously.", "Of all the things you could ask, you went with that?", "I don't know, look it up", "I mean, yeah, I guess...", "That's gonna be a big nope", ""]
141
  # return random.choice(responses)
142
+ title = "Ask Quentin"
143
+
144
+ about_text = "Quentin says: 'I'm an expert, not a quack'"
145
 
146
  with gr.Blocks(theme=gr.themes.Citrus(
147
  secondary_hue="red",
 
159
  button_primary_background_fill='*secondary_500',
160
  button_primary_background_fill_dark='*secondary_600'
161
  )) as chatbot:
162
+ with gr.Row(scale=1)
163
+ gr.Image("ask_quentin_banner.jpg", show_label = False, show_share_button = False, show_download_button = False)
164
+ with gr.Row(scale=3):
165
+ with gr.Column(scale=1):
166
+ gr.Markdown(title)
167
+ gr.Image("CruelRobot.jpg", show_label = False, show_share_button = False, show_download_button = False, width=300, height=300)
168
+ gr.Markdown(about_text)
169
+ with gr.Column(scale=1):
170
+ gr.Image("Quentin.png", show_label = False, show_share_button = False, show_download_button = False)
171
+ username = gr.Textbox(placeholder="Type your name here", label="Name")
172
+ quentin_attitude = gr.CheckboxGroup(["Kind", "Angry", "childish", "Tough Guy"], label="What is Quentin's Mood?")
173
+ with gr.Column(scale=3):
174
+ gr.ChatInterface(fn=respond, type="messages", additional_inputs=[username, quentin_attitude], title="Quentin, the Helpful Quackbot")
175
 
176
  chatbot.launch()