Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ DEFAULT_CONFIG = {
|
|
24 |
'max_tokens': 750,
|
25 |
'model': 'qwen/qwen3-30b-a3b-instruct-2507',
|
26 |
'api_key_var': 'API_KEY',
|
27 |
-
'theme': '
|
28 |
'grounding_urls': ["https://en.wikipedia.org/wiki/List_of_experiments", "https://en.wikipedia.org/wiki/Scientific_method"],
|
29 |
'enable_dynamic_urls': True,
|
30 |
'enable_file_upload': True,
|
@@ -627,6 +627,38 @@ def create_interface():
|
|
627 |
)
|
628 |
|
629 |
# Examples section
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
630 |
# Wire up the interface
|
631 |
msg.submit(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
632 |
submit_btn.click(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
|
|
24 |
'max_tokens': 750,
|
25 |
'model': 'qwen/qwen3-30b-a3b-instruct-2507',
|
26 |
'api_key_var': 'API_KEY',
|
27 |
+
'theme': 'Default',
|
28 |
'grounding_urls': ["https://en.wikipedia.org/wiki/List_of_experiments", "https://en.wikipedia.org/wiki/Scientific_method"],
|
29 |
'enable_dynamic_urls': True,
|
30 |
'enable_file_upload': True,
|
|
|
627 |
)
|
628 |
|
629 |
# Examples section
|
630 |
+
if examples:
|
631 |
+
gr.Examples(examples=examples, inputs=msg)
|
632 |
+
|
633 |
+
# Chat functionality
|
634 |
+
def respond(message, chat_history, files_state, is_granted):
|
635 |
+
if not is_granted:
|
636 |
+
return chat_history, "", is_granted
|
637 |
+
|
638 |
+
if not message:
|
639 |
+
return chat_history, "", is_granted
|
640 |
+
|
641 |
+
# Format history for the generate_response function
|
642 |
+
formatted_history = []
|
643 |
+
for h in chat_history:
|
644 |
+
if isinstance(h, dict):
|
645 |
+
formatted_history.append(h)
|
646 |
+
|
647 |
+
# Get response
|
648 |
+
response = generate_response(message, formatted_history, files_state)
|
649 |
+
|
650 |
+
# Update chat history
|
651 |
+
chat_history = chat_history + [
|
652 |
+
{"role": "user", "content": message},
|
653 |
+
{"role": "assistant", "content": response}
|
654 |
+
]
|
655 |
+
|
656 |
+
# Update stored history for export
|
657 |
+
global chat_history_store
|
658 |
+
chat_history_store = chat_history
|
659 |
+
|
660 |
+
return chat_history, "", is_granted
|
661 |
+
|
662 |
# Wire up the interface
|
663 |
msg.submit(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
664 |
submit_btn.click(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|