Spaces:
Running
Running
milwright
commited on
Commit
·
d68f6d0
1
Parent(s):
3b399f8
update gradio to 5.42.0 and fix export conversation functionality
Browse files- updated gradio requirement from 5.39.0 to 5.42.0 in both requirements.txt and deployment packages
- fixed export conversation not working on first click by passing chatbot state directly
- fixed clear button to properly reset chat history store
- removed tts integration guide file and all tts-related references
- .gitignore +2 -1
- app.py +22 -4
- space_template.py +11 -4
.gitignore
CHANGED
@@ -59,4 +59,5 @@ test_complete_system.py
|
|
59 |
test_grounding.py
|
60 |
|
61 |
# Markdown files
|
62 |
-
tts_integration_guide.md
|
|
|
|
59 |
test_grounding.py
|
60 |
|
61 |
# Markdown files
|
62 |
+
tts_integration_guide.md
|
63 |
+
stem_adventure_games_conversation_20250813_215243.md
|
app.py
CHANGED
@@ -9,6 +9,8 @@ import zipfile
|
|
9 |
import io
|
10 |
import os
|
11 |
import requests
|
|
|
|
|
12 |
from datetime import datetime
|
13 |
from dotenv import load_dotenv
|
14 |
from pathlib import Path
|
@@ -647,11 +649,27 @@ class SpaceGenerator:
|
|
647 |
clear_btn.click(lambda: ([], ""), outputs=[preview_chatbot, msg])
|
648 |
|
649 |
# Export handler
|
650 |
-
def prepare_export():
|
651 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
652 |
|
653 |
export_btn.click(
|
654 |
prepare_export,
|
|
|
655 |
outputs=[export_btn]
|
656 |
)
|
657 |
|
@@ -925,7 +943,7 @@ class SpaceGenerator:
|
|
925 |
template = get_template()
|
926 |
app_content = template.format(**config)
|
927 |
|
928 |
-
requirements_content = """gradio>=5.
|
929 |
requests>=2.32.3
|
930 |
beautifulsoup4>=4.12.3
|
931 |
python-dotenv>=1.0.0
|
@@ -1043,7 +1061,7 @@ emoji: {emoji}
|
|
1043 |
colorFrom: blue
|
1044 |
colorTo: green
|
1045 |
sdk: gradio
|
1046 |
-
sdk_version: 5.
|
1047 |
app_file: app.py
|
1048 |
pinned: false
|
1049 |
license: mit
|
|
|
9 |
import io
|
10 |
import os
|
11 |
import requests
|
12 |
+
import re
|
13 |
+
import tempfile
|
14 |
from datetime import datetime
|
15 |
from dotenv import load_dotenv
|
16 |
from pathlib import Path
|
|
|
649 |
clear_btn.click(lambda: ([], ""), outputs=[preview_chatbot, msg])
|
650 |
|
651 |
# Export handler
|
652 |
+
def prepare_export(chat_history):
|
653 |
+
if not chat_history:
|
654 |
+
return None
|
655 |
+
|
656 |
+
# Export conversation
|
657 |
+
content = export_conversation_to_markdown(chat_history)
|
658 |
+
|
659 |
+
# Create filename
|
660 |
+
space_name_safe = re.sub(r'[^a-zA-Z0-9]+', '_', config.get('name', 'AI_Assistant')).lower()
|
661 |
+
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
662 |
+
filename = f"{space_name_safe}_conversation_{timestamp}.md"
|
663 |
+
|
664 |
+
# Save to temp file
|
665 |
+
temp_path = Path(tempfile.gettempdir()) / filename
|
666 |
+
temp_path.write_text(content, encoding='utf-8')
|
667 |
+
|
668 |
+
return str(temp_path)
|
669 |
|
670 |
export_btn.click(
|
671 |
prepare_export,
|
672 |
+
inputs=[preview_chatbot],
|
673 |
outputs=[export_btn]
|
674 |
)
|
675 |
|
|
|
943 |
template = get_template()
|
944 |
app_content = template.format(**config)
|
945 |
|
946 |
+
requirements_content = """gradio>=5.42.0
|
947 |
requests>=2.32.3
|
948 |
beautifulsoup4>=4.12.3
|
949 |
python-dotenv>=1.0.0
|
|
|
1061 |
colorFrom: blue
|
1062 |
colorTo: green
|
1063 |
sdk: gradio
|
1064 |
+
sdk_version: 5.42.0
|
1065 |
app_file: app.py
|
1066 |
pinned: false
|
1067 |
license: mit
|
space_template.py
CHANGED
@@ -596,11 +596,11 @@ def create_interface():
|
|
596 |
)
|
597 |
|
598 |
# Export handler
|
599 |
-
def prepare_export():
|
600 |
-
if not
|
601 |
return None
|
602 |
|
603 |
-
content = export_conversation_to_markdown(
|
604 |
|
605 |
# Create filename
|
606 |
space_name_safe = re.sub(r'[^a-zA-Z0-9]+', '_', SPACE_NAME).lower()
|
@@ -615,6 +615,7 @@ def create_interface():
|
|
615 |
|
616 |
export_btn.click(
|
617 |
prepare_export,
|
|
|
618 |
outputs=[export_btn]
|
619 |
)
|
620 |
|
@@ -654,7 +655,13 @@ def create_interface():
|
|
654 |
# Wire up the interface
|
655 |
msg.submit(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
656 |
submit_btn.click(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
657 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
|
659 |
# File upload accordion
|
660 |
if ENABLE_FILE_UPLOAD:
|
|
|
596 |
)
|
597 |
|
598 |
# Export handler
|
599 |
+
def prepare_export(chat_history):
|
600 |
+
if not chat_history:
|
601 |
return None
|
602 |
|
603 |
+
content = export_conversation_to_markdown(chat_history)
|
604 |
|
605 |
# Create filename
|
606 |
space_name_safe = re.sub(r'[^a-zA-Z0-9]+', '_', SPACE_NAME).lower()
|
|
|
615 |
|
616 |
export_btn.click(
|
617 |
prepare_export,
|
618 |
+
inputs=[chatbot],
|
619 |
outputs=[export_btn]
|
620 |
)
|
621 |
|
|
|
655 |
# Wire up the interface
|
656 |
msg.submit(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
657 |
submit_btn.click(respond, [msg, chatbot, uploaded_files, access_granted], [chatbot, msg, access_granted])
|
658 |
+
|
659 |
+
def clear_chat():
|
660 |
+
global chat_history_store
|
661 |
+
chat_history_store = []
|
662 |
+
return [], ""
|
663 |
+
|
664 |
+
clear_btn.click(clear_chat, outputs=[chatbot, msg])
|
665 |
|
666 |
# File upload accordion
|
667 |
if ENABLE_FILE_UPLOAD:
|