Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -102,7 +102,7 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 102 |
# Return the list of most relevant chunks
|
| 103 |
return top_chunks
|
| 104 |
|
| 105 |
-
def respond(message, history):
|
| 106 |
response = ""
|
| 107 |
best_recipes_chunk = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 108 |
print(best_recipes_chunk)
|
|
@@ -142,6 +142,24 @@ def respond(message, history):
|
|
| 142 |
|
| 143 |
#temperature and top_p control randomness
|
| 144 |
return response['choices'][0]['message']['content'].strip()
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
chatbot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
# Return the list of most relevant chunks
|
| 103 |
return top_chunks
|
| 104 |
|
| 105 |
+
def respond(message, selected_options, history):
|
| 106 |
response = ""
|
| 107 |
best_recipes_chunk = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 108 |
print(best_recipes_chunk)
|
|
|
|
| 142 |
|
| 143 |
#temperature and top_p control randomness
|
| 144 |
return response['choices'][0]['message']['content'].strip()
|
| 145 |
+
|
| 146 |
+
with gr.Blocks() as demo:
|
| 147 |
+
chatbot = gr.Chatbot(label="NutriAssist")
|
| 148 |
+
chatbot.like(vote, None, None)
|
| 149 |
+
with gr.Row():
|
| 150 |
+
msg = gr.Textbox(placeholder="Ask about an item (e.g., banana peel)", label="Your Question")
|
| 151 |
+
checkboxes = gr.CheckboxGroup(
|
| 152 |
+
choices=["Show fun facts", "Explain why", "Summarize rules"],
|
| 153 |
+
label="Customize your response",
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
send_btn = gr.Button("Send")
|
| 157 |
+
history_state = gr.State([])
|
| 158 |
+
send_btn.click(
|
| 159 |
+
fn=respond,
|
| 160 |
+
inputs=[msg, checkboxes, history_state],
|
| 161 |
+
outputs=[chatbot]
|
| 162 |
+
)
|
| 163 |
+
demo.launch()
|
| 164 |
+
#chatbot = gr.ChatInterface(respond, type="messages")
|
| 165 |
+
#chatbot.launch()
|