Upload 2 files
Browse files- app.py +40 -3
- config.json +2 -2
app.py
CHANGED
@@ -14,7 +14,7 @@ SPACE_NAME = "AI Assistant"
|
|
14 |
SPACE_DESCRIPTION = "A customizable AI assistant"
|
15 |
|
16 |
# Default configuration values
|
17 |
-
DEFAULT_SYSTEM_PROMPT = """You are a research aid specializing in academic literature search and analysis. Your expertise spans discovering peer-reviewed sources, assessing research methodologies, synthesizing findings across studies, and delivering properly formatted citations. When responding, anchor claims in specific sources from provided URL contexts, differentiate between direct evidence and interpretive analysis, and note any limitations or contradictory results. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation.
|
18 |
DEFAULT_TEMPERATURE = 0.7
|
19 |
DEFAULT_MAX_TOKENS = 750
|
20 |
|
@@ -549,7 +549,7 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
|
|
549 |
fn=store_and_generate_response, # Use wrapper function to store history
|
550 |
title="", # Title already shown above
|
551 |
description="", # Description already shown above
|
552 |
-
examples=['
|
553 |
type="messages" # Use modern message format for better compatibility
|
554 |
)
|
555 |
|
@@ -788,7 +788,44 @@ with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
|
|
788 |
# Reload all configuration values
|
789 |
reload_config_values()
|
790 |
|
791 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
except Exception as e:
|
793 |
return f"❌ Error saving configuration: {str(e)}"
|
794 |
|
|
|
14 |
SPACE_DESCRIPTION = "A customizable AI assistant"
|
15 |
|
16 |
# Default configuration values
|
17 |
+
DEFAULT_SYSTEM_PROMPT = """You are a research aid specializing in academic literature search and analysis. Your expertise spans discovering peer-reviewed sources, assessing research methodologies, synthesizing findings across studies, and delivering properly formatted citations. When responding, anchor claims in specific sources from provided URL contexts, differentiate between direct evidence and interpretive analysis, and note any limitations or contradictory results. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation."""
|
18 |
DEFAULT_TEMPERATURE = 0.7
|
19 |
DEFAULT_MAX_TOKENS = 750
|
20 |
|
|
|
549 |
fn=store_and_generate_response, # Use wrapper function to store history
|
550 |
title="", # Title already shown above
|
551 |
description="", # Description already shown above
|
552 |
+
examples=['Hello! How can you help me?', 'Tell me something interesting', 'What can you do?'],
|
553 |
type="messages" # Use modern message format for better compatibility
|
554 |
)
|
555 |
|
|
|
788 |
# Reload all configuration values
|
789 |
reload_config_values()
|
790 |
|
791 |
+
# Determine which changes require restart
|
792 |
+
restart_required = False
|
793 |
+
restart_reasons = []
|
794 |
+
|
795 |
+
# Check if theme changed (requires restart)
|
796 |
+
if 'theme' in current_full_config and current_full_config.get('theme') != THEME:
|
797 |
+
restart_required = True
|
798 |
+
restart_reasons.append("Theme change")
|
799 |
+
|
800 |
+
# Check if name/description changed (requires restart for interface title)
|
801 |
+
if new_name != SPACE_NAME or new_description != SPACE_DESCRIPTION:
|
802 |
+
restart_required = True
|
803 |
+
restart_reasons.append("Assistant name or description")
|
804 |
+
|
805 |
+
# Check if examples changed (requires restart for ChatInterface)
|
806 |
+
old_examples = config.get('examples', [])
|
807 |
+
if examples_list != old_examples:
|
808 |
+
restart_required = True
|
809 |
+
restart_reasons.append("Example prompts")
|
810 |
+
|
811 |
+
# Build response message
|
812 |
+
response_msg = f"✅ Configuration saved successfully at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
813 |
+
|
814 |
+
# Add restart instructions if needed
|
815 |
+
if restart_required:
|
816 |
+
response_msg += f"\n\n🔄 **Restart Required**\n"
|
817 |
+
response_msg += f"The following changes require a Space restart to take effect:\n"
|
818 |
+
for reason in restart_reasons:
|
819 |
+
response_msg += f"• {reason}\n"
|
820 |
+
response_msg += "\n**To restart your Space:**\n"
|
821 |
+
response_msg += "1. Go to your Space settings (⚙️ icon)\n"
|
822 |
+
response_msg += "2. Click 'Factory reboot' for a complete restart\n"
|
823 |
+
response_msg += "3. Wait ~30 seconds for the Space to reload\n"
|
824 |
+
response_msg += "\n*Note: System prompt, model, temperature, and URL changes take effect immediately for new conversations.*"
|
825 |
+
else:
|
826 |
+
response_msg += "\n\n✅ All changes will take effect immediately for new conversations."
|
827 |
+
|
828 |
+
return response_msg
|
829 |
except Exception as e:
|
830 |
return f"❌ Error saving configuration: {str(e)}"
|
831 |
|
config.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
{
|
2 |
"name": "AI Assistant",
|
3 |
"description": "A customizable AI assistant",
|
4 |
-
"system_prompt": "You are a research aid specializing in academic literature search and analysis. Your expertise spans discovering peer-reviewed sources, assessing research methodologies, synthesizing findings across studies, and delivering properly formatted citations. When responding, anchor claims in specific sources from provided URL contexts, differentiate between direct evidence and interpretive analysis, and note any limitations or contradictory results. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation.
|
5 |
"model": "google/gemini-2.0-flash-001",
|
6 |
"api_key_var": "API_KEY",
|
7 |
"temperature": 0.7,
|
8 |
"max_tokens": 750,
|
9 |
-
"examples": "['
|
10 |
"grounding_urls": "[]",
|
11 |
"enable_dynamic_urls": true,
|
12 |
"theme": "Default"
|
|
|
1 |
{
|
2 |
"name": "AI Assistant",
|
3 |
"description": "A customizable AI assistant",
|
4 |
+
"system_prompt": "You are a research aid specializing in academic literature search and analysis. Your expertise spans discovering peer-reviewed sources, assessing research methodologies, synthesizing findings across studies, and delivering properly formatted citations. When responding, anchor claims in specific sources from provided URL contexts, differentiate between direct evidence and interpretive analysis, and note any limitations or contradictory results. Employ clear, accessible language that demystifies complex research, and propose connected research directions when appropriate. Your purpose is to serve as an informed research tool supporting users through initial concept development, exploratory investigation, information collection, and source compilation.",
|
5 |
"model": "google/gemini-2.0-flash-001",
|
6 |
"api_key_var": "API_KEY",
|
7 |
"temperature": 0.7,
|
8 |
"max_tokens": 750,
|
9 |
+
"examples": "['Hello! How can you help me?', 'Tell me something interesting', 'What can you do?']",
|
10 |
"grounding_urls": "[]",
|
11 |
"enable_dynamic_urls": true,
|
12 |
"theme": "Default"
|