Upload 4 files
Browse files- README.md +3 -20
- app.py +22 -5
- config.json +3 -3
README.md
CHANGED
@@ -40,39 +40,22 @@ Assistant for Foundations of Data Science at CCNY
|
|
40 |
5. Value: Your OpenRouter API key
|
41 |
6. Click "Add"
|
42 |
|
43 |
-
### Step 4: Configure Access Control
|
44 |
-
Your Space is configured with access code protection. Students will need to enter the access code to use the chatbot.
|
45 |
-
|
46 |
-
1. Go to Settings (gear icon)
|
47 |
-
2. Click "Variables and secrets"
|
48 |
-
3. Click "New secret"
|
49 |
-
4. Name: `SPACE_ACCESS_CODE`
|
50 |
-
5. Value: `TLC`
|
51 |
-
6. Click "Add"
|
52 |
-
|
53 |
-
**Important**: The access code is now stored securely as an environment variable and is not visible in your app code.
|
54 |
-
|
55 |
-
To disable access protection:
|
56 |
-
1. Go to Settings β Variables and secrets
|
57 |
-
2. Delete the `SPACE_ACCESS_CODE` secret
|
58 |
-
3. The Space will rebuild automatically with no access protection
|
59 |
-
|
60 |
|
61 |
|
62 |
-
### Step
|
63 |
1. Go to https://openrouter.ai/keys
|
64 |
2. Sign up/login if needed
|
65 |
3. Click "Create Key"
|
66 |
4. Copy the key (starts with `sk-or-`)
|
67 |
|
68 |
-
### Step
|
69 |
- Go back to "App" tab
|
70 |
- Your Space should be running!
|
71 |
- Try the example prompts or ask a question
|
72 |
|
73 |
## Configuration
|
74 |
|
75 |
-
- **Model**:
|
76 |
- **Temperature**: 0.7
|
77 |
- **Max Tokens**: 750
|
78 |
- **API Key Variable**: OPENROUTER_API_KEY
|
|
|
40 |
5. Value: Your OpenRouter API key
|
41 |
6. Click "Add"
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
|
45 |
+
### Step 4: Get Your API Key
|
46 |
1. Go to https://openrouter.ai/keys
|
47 |
2. Sign up/login if needed
|
48 |
3. Click "Create Key"
|
49 |
4. Copy the key (starts with `sk-or-`)
|
50 |
|
51 |
+
### Step 5: Test Your Space
|
52 |
- Go back to "App" tab
|
53 |
- Your Space should be running!
|
54 |
- Try the example prompts or ask a question
|
55 |
|
56 |
## Configuration
|
57 |
|
58 |
+
- **Model**: google/gemini-2.0-flash-001
|
59 |
- **Temperature**: 0.7
|
60 |
- **Max Tokens**: 750
|
61 |
- **API Key Variable**: OPENROUTER_API_KEY
|
app.py
CHANGED
@@ -52,8 +52,8 @@ Engagement Style:
|
|
52 |
* Celebrate student progress and effort
|
53 |
|
54 |
Remember: Your goal is to support student learning and success while maintaining the pedagogical integrity of the course. You are a learning facilitator, not an answer provider."""
|
55 |
-
MODEL = "
|
56 |
-
GROUNDING_URLS = ["https://zmuhls.github.io/ccny-data-science/schedule/", "https://zmuhls.github.io/ccny-data-science/
|
57 |
# Get access code from environment variable for security
|
58 |
# If SPACE_ACCESS_CODE is not set, no access control is applied
|
59 |
ACCESS_CODE = os.environ.get("SPACE_ACCESS_CODE")
|
@@ -510,18 +510,35 @@ def get_configuration_status():
|
|
510 |
status_parts.append(f"π‘οΈ **Temperature:** 0.7")
|
511 |
status_parts.append(f"π **Max Tokens:** 750")
|
512 |
|
|
|
513 |
if GROUNDING_URLS:
|
514 |
status_parts.append(f"π **URL Grounding:** {len(GROUNDING_URLS)} URLs configured")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
|
516 |
if ENABLE_DYNAMIC_URLS:
|
517 |
status_parts.append("π **Dynamic URLs:** Enabled")
|
|
|
|
|
518 |
|
519 |
if ACCESS_CODE is not None:
|
520 |
status_parts.append("π **Access Control:** Enabled")
|
521 |
else:
|
522 |
-
status_parts.append("π **Access:** Public")
|
|
|
|
|
|
|
|
|
|
|
523 |
|
524 |
-
return "
|
|
|
525 |
|
526 |
# Create interface with access code protection
|
527 |
with gr.Blocks(title=SPACE_NAME) as demo:
|
@@ -551,7 +568,7 @@ with gr.Blocks(title=SPACE_NAME) as demo:
|
|
551 |
fn=store_and_generate_response, # Use wrapper function to store history
|
552 |
title="", # Title already shown above
|
553 |
description="", # Description already shown above
|
554 |
-
examples=['When is the social coding portfolio due?',
|
555 |
type="messages" # Use modern message format for better compatibility
|
556 |
)
|
557 |
|
|
|
52 |
* Celebrate student progress and effort
|
53 |
|
54 |
Remember: Your goal is to support student learning and success while maintaining the pedagogical integrity of the course. You are a learning facilitator, not an answer provider."""
|
55 |
+
MODEL = "google/gemini-2.0-flash-001"
|
56 |
+
GROUNDING_URLS = ["https://zmuhls.github.io/ccny-data-science/schedule/", "https://zmuhls.github.io/ccny-data-science/syllabus/", "https://zmuhls.github.io/ccny-data-science/portfolio/", "https://zmuhls.github.io/ccny-data-science/activities/", "https://melaniewalsh.github.io/Intro-Cultural-Analytics/welcome.html"]
|
57 |
# Get access code from environment variable for security
|
58 |
# If SPACE_ACCESS_CODE is not set, no access control is applied
|
59 |
ACCESS_CODE = os.environ.get("SPACE_ACCESS_CODE")
|
|
|
510 |
status_parts.append(f"π‘οΈ **Temperature:** 0.7")
|
511 |
status_parts.append(f"π **Max Tokens:** 750")
|
512 |
|
513 |
+
# URL Grounding details
|
514 |
if GROUNDING_URLS:
|
515 |
status_parts.append(f"π **URL Grounding:** {len(GROUNDING_URLS)} URLs configured")
|
516 |
+
# Show first few URLs as examples
|
517 |
+
for i, url in enumerate(GROUNDING_URLS[:3], 1):
|
518 |
+
priority_label = "Primary" if i <= 2 else "Secondary"
|
519 |
+
status_parts.append(f" - [{priority_label}] {url}")
|
520 |
+
if len(GROUNDING_URLS) > 3:
|
521 |
+
status_parts.append(f" - ... and {len(GROUNDING_URLS) - 3} more URLs")
|
522 |
+
else:
|
523 |
+
status_parts.append("π **URL Grounding:** No URLs configured")
|
524 |
|
525 |
if ENABLE_DYNAMIC_URLS:
|
526 |
status_parts.append("π **Dynamic URLs:** Enabled")
|
527 |
+
else:
|
528 |
+
status_parts.append("π **Dynamic URLs:** Disabled")
|
529 |
|
530 |
if ACCESS_CODE is not None:
|
531 |
status_parts.append("π **Access Control:** Enabled")
|
532 |
else:
|
533 |
+
status_parts.append("π **Access:** Public Chatbot")
|
534 |
+
|
535 |
+
# System Prompt (add at the end)
|
536 |
+
status_parts.append("") # Empty line for spacing
|
537 |
+
status_parts.append("**System Prompt:**")
|
538 |
+
status_parts.append(f"{SYSTEM_PROMPT}")
|
539 |
|
540 |
+
return "
|
541 |
+
".join(status_parts)
|
542 |
|
543 |
# Create interface with access code protection
|
544 |
with gr.Blocks(title=SPACE_NAME) as demo:
|
|
|
568 |
fn=store_and_generate_response, # Use wrapper function to store history
|
569 |
title="", # Title already shown above
|
570 |
description="", # Description already shown above
|
571 |
+
examples=['When is the social coding portfolio due?', 'How can I reach Prof. Muhlbauer?', 'Explain Python data types to me'],
|
572 |
type="messages" # Use modern message format for better compatibility
|
573 |
)
|
574 |
|
config.json
CHANGED
@@ -2,11 +2,11 @@
|
|
2 |
"name": "CCNY Data Science Assistant",
|
3 |
"description": "Assistant for Foundations of Data Science at CCNY",
|
4 |
"system_prompt": "You are a supportive course assistant for Professor Zach Muhlbauer's Foundations of Data Science course (CSC 10800 R) at City College of New York.\n\nCore Responsibilities\n* Course Navigation: Help students locate and understand syllabus information, assignment details, schedules, readings, and course materials\n* Learning Facilitation: Guide students toward understanding concepts through Socratic questioning and scaffolding rather than providing direct answers\n* Administrative Support: Provide accurate information about deadlines, exam dates, office hours, and course policies\n\nResponse Guidelines\n* Precision First: Be exact with all dates, times, deadlines, and scheduling information\n* Warm Tone: Use encouraging, supportive language that builds student confidence\n* Pedagogical Approach: Never provide direct answers to assignments or assessments; instead, ask guiding questions that help students discover solutions independently\n* Scope Boundaries: Only address questions related to this specific course (CSC 10800 R) - syllabus, schedule, assignments, readings, and general data science learning support\n* Specific Protocols: For questions about grades, redirect students to contact Professor Muhlbauer at the email provided in the course materials for all related inquiries: [email protected]\n\nFor Scheduling/Deadlines:\n* Always cross-reference the most current course schedule\n* Provide specific dates and times\n* Remind students of upcoming deadlines proactively when relevant\n* NB: If {{today}} is after the last date of the course, then do NOT make up new dates based on Tue/Thu schedule of the class\n\nFor Conceptual Questions:\n* Use Socratic method to guide discovery\n* Provide analogies or real-world applications to clarify abstract concepts\n* Reference specific course materials where students can find more information\n* Encourage active engagement with the material\n\nUncertainty Protocol:\nWhen uncertain about any information:\n* Explicitly state your uncertainty\n* Direct students to verify information through official course materials\n* Suggest contacting Professor Muhlbauer for clarification\n* Provide general guidance on where to find authoritative information\n\nEngagement Style:\n* Begin responses with acknowledgment of the student's question\n* Use warm, encouraging language\n* Ask follow-up questions to better understand student needs\n* Celebrate student progress and effort\n\nRemember: Your goal is to support student learning and success while maintaining the pedagogical integrity of the course. You are a learning facilitator, not an answer provider.",
|
5 |
-
"model": "
|
6 |
"api_key_var": "OPENROUTER_API_KEY",
|
7 |
"temperature": 0.7,
|
8 |
"max_tokens": 750,
|
9 |
-
"examples": "['When is the social coding portfolio due?',
|
10 |
-
"grounding_urls": "[\"https://zmuhls.github.io/ccny-data-science/schedule/\", \"https://zmuhls.github.io/ccny-data-science/
|
11 |
"enable_dynamic_urls": true
|
12 |
}
|
|
|
2 |
"name": "CCNY Data Science Assistant",
|
3 |
"description": "Assistant for Foundations of Data Science at CCNY",
|
4 |
"system_prompt": "You are a supportive course assistant for Professor Zach Muhlbauer's Foundations of Data Science course (CSC 10800 R) at City College of New York.\n\nCore Responsibilities\n* Course Navigation: Help students locate and understand syllabus information, assignment details, schedules, readings, and course materials\n* Learning Facilitation: Guide students toward understanding concepts through Socratic questioning and scaffolding rather than providing direct answers\n* Administrative Support: Provide accurate information about deadlines, exam dates, office hours, and course policies\n\nResponse Guidelines\n* Precision First: Be exact with all dates, times, deadlines, and scheduling information\n* Warm Tone: Use encouraging, supportive language that builds student confidence\n* Pedagogical Approach: Never provide direct answers to assignments or assessments; instead, ask guiding questions that help students discover solutions independently\n* Scope Boundaries: Only address questions related to this specific course (CSC 10800 R) - syllabus, schedule, assignments, readings, and general data science learning support\n* Specific Protocols: For questions about grades, redirect students to contact Professor Muhlbauer at the email provided in the course materials for all related inquiries: [email protected]\n\nFor Scheduling/Deadlines:\n* Always cross-reference the most current course schedule\n* Provide specific dates and times\n* Remind students of upcoming deadlines proactively when relevant\n* NB: If {{today}} is after the last date of the course, then do NOT make up new dates based on Tue/Thu schedule of the class\n\nFor Conceptual Questions:\n* Use Socratic method to guide discovery\n* Provide analogies or real-world applications to clarify abstract concepts\n* Reference specific course materials where students can find more information\n* Encourage active engagement with the material\n\nUncertainty Protocol:\nWhen uncertain about any information:\n* Explicitly state your uncertainty\n* Direct students to verify information through official course materials\n* Suggest contacting Professor Muhlbauer for clarification\n* Provide general guidance on where to find authoritative information\n\nEngagement Style:\n* Begin responses with acknowledgment of the student's question\n* Use warm, encouraging language\n* Ask follow-up questions to better understand student needs\n* Celebrate student progress and effort\n\nRemember: Your goal is to support student learning and success while maintaining the pedagogical integrity of the course. You are a learning facilitator, not an answer provider.",
|
5 |
+
"model": "google/gemini-2.0-flash-001",
|
6 |
"api_key_var": "OPENROUTER_API_KEY",
|
7 |
"temperature": 0.7,
|
8 |
"max_tokens": 750,
|
9 |
+
"examples": "['When is the social coding portfolio due?', 'How can I reach Prof. Muhlbauer?', 'Explain Python data types to me']",
|
10 |
+
"grounding_urls": "[\"https://zmuhls.github.io/ccny-data-science/schedule/\", \"https://zmuhls.github.io/ccny-data-science/syllabus/\", \"https://zmuhls.github.io/ccny-data-science/portfolio/\", \"https://zmuhls.github.io/ccny-data-science/activities/\", \"https://melaniewalsh.github.io/Intro-Cultural-Analytics/welcome.html\"]",
|
11 |
"enable_dynamic_urls": true
|
12 |
}
|