Upload 3 files
Browse files- app.py +11 -8
- config.json +8 -7
app.py
CHANGED
@@ -10,15 +10,16 @@ import urllib.parse
|
|
10 |
|
11 |
|
12 |
# Configuration
|
13 |
-
SPACE_NAME = "
|
14 |
-
SPACE_DESCRIPTION = "
|
15 |
-
SYSTEM_PROMPT = """You are
|
16 |
-
MODEL = "anthropic/claude-3.5-
|
17 |
-
|
|
|
18 |
# Get access code from environment variable for security
|
19 |
# If SPACE_ACCESS_CODE is not set, no access control is applied
|
20 |
ACCESS_CODE = os.environ.get("SPACE_ACCESS_CODE")
|
21 |
-
ENABLE_DYNAMIC_URLS =
|
22 |
|
23 |
# Get API key from environment - customizable variable name with validation
|
24 |
API_KEY = os.environ.get("OPENROUTER_API_KEY")
|
@@ -501,7 +502,9 @@ def get_configuration_status():
|
|
501 |
return "\n".join(status_parts)
|
502 |
|
503 |
# Create interface with access code protection
|
504 |
-
|
|
|
|
|
505 |
gr.Markdown(f"# {SPACE_NAME}")
|
506 |
gr.Markdown(SPACE_DESCRIPTION)
|
507 |
|
@@ -524,7 +527,7 @@ with gr.Blocks(title=SPACE_NAME) as demo:
|
|
524 |
fn=store_and_generate_response, # Use wrapper function to store history
|
525 |
title="", # Title already shown above
|
526 |
description="", # Description already shown above
|
527 |
-
examples=['
|
528 |
type="messages" # Use modern message format for better compatibility
|
529 |
)
|
530 |
|
|
|
10 |
|
11 |
|
12 |
# Configuration
|
13 |
+
SPACE_NAME = "AI Assistant"
|
14 |
+
SPACE_DESCRIPTION = "A customizable AI assistant"
|
15 |
+
SYSTEM_PROMPT = """You are an AI assistant specialized in mathematics and statistics who guides users through problem-solving rather than providing direct answers. You help users discover solutions by asking strategic questions ('What do we know so far?' 'What method might apply here?' 'Can you identify a pattern?'), prompting them to explain their reasoning, and offering hints that build on their current understanding. Format all mathematical expressions in LaTeX (inline: $x^2 + y^2 = r^2$, display: $$\int_a^b f(x)dx$$). When users are stuck, provide scaffolded support: suggest examining simpler cases, identifying relevant formulas or theorems, or breaking the problem into smaller parts. Use multiple representations to illuminate different aspects of the problem, validate partial progress to build confidence, and help users recognize and correct their own errors through targeted questions rather than corrections. Your goal is to develop problem-solving skills and mathematical reasoning, not just arrive at answers."""
|
16 |
+
MODEL = "anthropic/claude-3.5-sonnet"
|
17 |
+
THEME = "Monochrome" # Gradio theme name
|
18 |
+
GROUNDING_URLS = ["https://www.cmor-faculty.rice.edu/~heinken/latex/symbols.pdf"]
|
19 |
# Get access code from environment variable for security
|
20 |
# If SPACE_ACCESS_CODE is not set, no access control is applied
|
21 |
ACCESS_CODE = os.environ.get("SPACE_ACCESS_CODE")
|
22 |
+
ENABLE_DYNAMIC_URLS = False
|
23 |
|
24 |
# Get API key from environment - customizable variable name with validation
|
25 |
API_KEY = os.environ.get("OPENROUTER_API_KEY")
|
|
|
502 |
return "\n".join(status_parts)
|
503 |
|
504 |
# Create interface with access code protection
|
505 |
+
# Dynamically set theme based on configuration
|
506 |
+
theme_class = getattr(gr.themes, THEME, gr.themes.Default)
|
507 |
+
with gr.Blocks(title=SPACE_NAME, theme=theme_class()) as demo:
|
508 |
gr.Markdown(f"# {SPACE_NAME}")
|
509 |
gr.Markdown(SPACE_DESCRIPTION)
|
510 |
|
|
|
527 |
fn=store_and_generate_response, # Use wrapper function to store history
|
528 |
title="", # Title already shown above
|
529 |
description="", # Description already shown above
|
530 |
+
examples=["I'm stuck on a math problem. Can you help?", 'What is Bayesian statistics and can you provide an example?'],
|
531 |
type="messages" # Use modern message format for better compatibility
|
532 |
)
|
533 |
|
config.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
{
|
2 |
-
"name": "
|
3 |
-
"description": "
|
4 |
-
"system_prompt": "You are
|
5 |
-
"model": "anthropic/claude-3.5-
|
6 |
"api_key_var": "OPENROUTER_API_KEY",
|
7 |
"temperature": 0.7,
|
8 |
"max_tokens": 750,
|
9 |
-
"examples": "['
|
10 |
-
"grounding_urls": "[]",
|
11 |
-
"enable_dynamic_urls":
|
|
|
12 |
}
|
|
|
1 |
{
|
2 |
+
"name": "AI Assistant",
|
3 |
+
"description": "A customizable AI assistant",
|
4 |
+
"system_prompt": "You are an AI assistant specialized in mathematics and statistics who guides users through problem-solving rather than providing direct answers. You help users discover solutions by asking strategic questions ('What do we know so far?' 'What method might apply here?' 'Can you identify a pattern?'), prompting them to explain their reasoning, and offering hints that build on their current understanding. Format all mathematical expressions in LaTeX (inline: $x^2 + y^2 = r^2$, display: $$\\int_a^b f(x)dx$$). When users are stuck, provide scaffolded support: suggest examining simpler cases, identifying relevant formulas or theorems, or breaking the problem into smaller parts. Use multiple representations to illuminate different aspects of the problem, validate partial progress to build confidence, and help users recognize and correct their own errors through targeted questions rather than corrections. Your goal is to develop problem-solving skills and mathematical reasoning, not just arrive at answers.",
|
5 |
+
"model": "anthropic/claude-3.5-sonnet",
|
6 |
"api_key_var": "OPENROUTER_API_KEY",
|
7 |
"temperature": 0.7,
|
8 |
"max_tokens": 750,
|
9 |
+
"examples": "[\"I'm stuck on a math problem. Can you help?\", 'What is Bayesian statistics and can you provide an example?']",
|
10 |
+
"grounding_urls": "[\"https://www.cmor-faculty.rice.edu/~heinken/latex/symbols.pdf\"]",
|
11 |
+
"enable_dynamic_urls": false,
|
12 |
+
"theme": "Monochrome"
|
13 |
}
|