Spaces:
Build error
Build error
Fix chat history
Browse files
app.py
CHANGED
@@ -42,6 +42,7 @@ class FromageChatBot:
|
|
42 |
def generate_for_prompt(self, input_text, state, ret_scale_factor, max_nm_rets, num_words, temperature):
|
43 |
input_prompt = 'Q: ' + input_text + '\nA:'
|
44 |
self.chat_history += input_prompt
|
|
|
45 |
|
46 |
# If an image was uploaded, prepend it to the model.
|
47 |
model_inputs = None
|
@@ -72,13 +73,13 @@ class FromageChatBot:
|
|
72 |
filename = self.save_image_to_local(output)
|
73 |
response += f'<img src="/file={filename}">'
|
74 |
|
75 |
-
self.chat_history += ' '.join(
|
76 |
if self.chat_history[-1] != '\n':
|
77 |
self.chat_history += '\n'
|
78 |
self.input_image = None
|
79 |
|
80 |
state.append((input_text, response))
|
81 |
-
return state, state
|
82 |
|
83 |
|
84 |
def launch(self):
|
@@ -101,6 +102,7 @@ class FromageChatBot:
|
|
101 |
clear_btn = gr.Button("Clear History")
|
102 |
|
103 |
text_input.submit(self.generate_for_prompt, [text_input, gr_state, ret_scale_factor, max_ret_images, gr_max_len, gr_temperature], [gr_state, chatbot])
|
|
|
104 |
image_btn.upload(self.upload_image, [gr_state, image_btn], [gr_state, chatbot])
|
105 |
clear_btn.click(self.reset, [], [gr_state, chatbot])
|
106 |
|
|
|
42 |
def generate_for_prompt(self, input_text, state, ret_scale_factor, max_nm_rets, num_words, temperature):
|
43 |
input_prompt = 'Q: ' + input_text + '\nA:'
|
44 |
self.chat_history += input_prompt
|
45 |
+
print('Generating for', self.chat_history)
|
46 |
|
47 |
# If an image was uploaded, prepend it to the model.
|
48 |
model_inputs = None
|
|
|
73 |
filename = self.save_image_to_local(output)
|
74 |
response += f'<img src="/file={filename}">'
|
75 |
|
76 |
+
self.chat_history += ' '.join(text_outputs)
|
77 |
if self.chat_history[-1] != '\n':
|
78 |
self.chat_history += '\n'
|
79 |
self.input_image = None
|
80 |
|
81 |
state.append((input_text, response))
|
82 |
+
return state, state
|
83 |
|
84 |
|
85 |
def launch(self):
|
|
|
102 |
clear_btn = gr.Button("Clear History")
|
103 |
|
104 |
text_input.submit(self.generate_for_prompt, [text_input, gr_state, ret_scale_factor, max_ret_images, gr_max_len, gr_temperature], [gr_state, chatbot])
|
105 |
+
text_input.submit(lambda :"", None, txt)
|
106 |
image_btn.upload(self.upload_image, [gr_state, image_btn], [gr_state, chatbot])
|
107 |
clear_btn.click(self.reset, [], [gr_state, chatbot])
|
108 |
|