ysharma HF staff commited on
Commit
19a9806
1 Parent(s): 0662778

added like/dislike, avatar and bubble_width

Browse files
Files changed (1) hide show
  1. app.py +41 -7
app.py CHANGED
@@ -114,6 +114,37 @@ additional_inputs=[
114
  ]
115
 
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  with gr.Blocks() as demo:
118
  with gr.Row():
119
  with gr.Column(scale=0.4):
@@ -135,12 +166,15 @@ with gr.Blocks() as demo:
135
  ⚠️ **Limitations**: the model can and will produce factually incorrect information, hallucinating facts and actions. As it has not undergone any advanced tuning/alignment, it can produce problematic outputs, especially if prompted to do so. Finally, this demo is limited to a session length of about 1,000 words.
136
  """
137
  )
138
-
139
- gr.ChatInterface(
140
- generate,
141
- examples=EXAMPLES,
142
- additional_inputs=additional_inputs,
143
- avatar_images = ('user.png', 'bot.png')
144
- )
 
 
 
145
 
146
  demo.queue(concurrency_count=100, api_open=False).launch(show_api=False)
 
114
  ]
115
 
116
 
117
+
118
+ def vote(data: gr.LikeData):
119
+ if data.liked:
120
+ print("You upvoted this response: " + data.value)
121
+ else:
122
+ print("You downvoted this response: " + data.value)
123
+
124
+
125
+ chatbot = gr.Chatbot(avatar_images=('user.png', 'bot.png'),bubble_full_width = False)
126
+
127
+ #chat = gr.ChatInterface(fn = random_response, chatbot = chatbot,
128
+ # #chatbot = gr.Chatbot(avatar_images=('user.png', 'bot.png'),bubble_full_width = False),
129
+ # textbox = gr.Textbox(placeholder="Ask me a yes or no question", container=False, scale=7),)
130
+
131
+ chat_interface = gr.ChatInterface(
132
+ generate,
133
+ chatbot = chatbot,
134
+ examples=EXAMPLES,
135
+ additional_inputs=additional_inputs,
136
+ )
137
+
138
+ #with gr.Blocks() as demo:
139
+ # chatbot.like(vote, None, None)
140
+ # chat.render()
141
+ #additional_inputs = chatbot.like(vote, None, None))
142
+ #chatbot.like(vote, None, None)
143
+
144
+ #demo.like(vote, None, None)
145
+ #demo.launch()
146
+
147
+
148
  with gr.Blocks() as demo:
149
  with gr.Row():
150
  with gr.Column(scale=0.4):
 
166
  ⚠️ **Limitations**: the model can and will produce factually incorrect information, hallucinating facts and actions. As it has not undergone any advanced tuning/alignment, it can produce problematic outputs, especially if prompted to do so. Finally, this demo is limited to a session length of about 1,000 words.
167
  """
168
  )
169
+
170
+ chatbot.like(vote, None, None)
171
+ chat_interface.render()
172
+
173
+ #gr.ChatInterface(
174
+ # generate,
175
+ # examples=EXAMPLES,
176
+ # additional_inputs=additional_inputs,
177
+ # avatar_images = ('user.png', 'bot.png')
178
+ #)
179
 
180
  demo.queue(concurrency_count=100, api_open=False).launch(show_api=False)