Spaces:
Running
Running
Upload 4 files
Browse files- README.md +1 -1
- app.py +38 -38
- config.json +9 -8
README.md
CHANGED
|
@@ -42,7 +42,7 @@ Socratic dialogue partner based on Phaedrus
|
|
| 42 |
Your Space should now be running! Try the example prompts or ask your own questions.
|
| 43 |
|
| 44 |
## Configuration
|
| 45 |
-
- **Model**:
|
| 46 |
- **API Key Variable**: API_KEY
|
| 47 |
- **HF Token Variable**: HF_TOKEN (for auto-updates)
|
| 48 |
- **Access Control**: Enabled (ACCESS_CODE)
|
|
|
|
| 42 |
Your Space should now be running! Try the example prompts or ask your own questions.
|
| 43 |
|
| 44 |
## Configuration
|
| 45 |
+
- **Model**: openai/gpt-4.1-nano
|
| 46 |
- **API Key Variable**: API_KEY
|
| 47 |
- **HF Token Variable**: HF_TOKEN (for auto-updates)
|
| 48 |
- **Access Control**: Enabled (ACCESS_CODE)
|
app.py
CHANGED
|
@@ -20,11 +20,11 @@ DEFAULT_CONFIG = {
|
|
| 20 |
'name': SPACE_NAME,
|
| 21 |
'description': SPACE_DESCRIPTION,
|
| 22 |
'system_prompt': "You are a Socratic conversation partner for students in general education courses across all disciplines with strengths in the pebble-in-the-pond learning model, responsive teaching, and constructivist learning principles. Loosely model your approach after Socrates' interlocutor Phaedrus from the eponymous Socratic dialogue, guiding students through source discovery, evaluation, and synthesis using methods of Socratic dialogue. Ask probing questions about explicit and implicit disciplinary knowledge, adapting to their skill level over the conversation and incrementing in complexity based on their demonstrated ability. Connect theory and method to grounded experiences, fostering reflexivity and critical dialogue around research methods and disciplinary practices. Select timely moments to respond with a punchy tone and ironic or self-referential levity. Expect to complete every response in under 400 tokens, and always end with a question to keep the conversation going.",
|
| 23 |
-
'temperature': 0.
|
| 24 |
'max_tokens': 400,
|
| 25 |
-
'model': '
|
| 26 |
'api_key_var': 'API_KEY',
|
| 27 |
-
'theme': '
|
| 28 |
'grounding_urls': ["https://classics.mit.edu/Plato/phaedrus.1b.txt", "https://plato.stanford.edu/entries/plato-rhetoric/#Pha", "https://plato.stanford.edu/entries/plato-myths/", "https://en.wikipedia.org/wiki/Socratic_method"],
|
| 29 |
'enable_dynamic_urls': True,
|
| 30 |
'enable_file_upload': True,
|
|
@@ -552,14 +552,45 @@ def create_interface():
|
|
| 552 |
chatbot = gr.Chatbot(type="messages", height=400)
|
| 553 |
msg = gr.Textbox(label="Message", placeholder="Type your message here...", lines=2)
|
| 554 |
|
| 555 |
-
# Examples section
|
| 556 |
-
if examples:
|
| 557 |
-
gr.Examples(examples=examples, inputs=msg)
|
| 558 |
-
|
| 559 |
with gr.Row():
|
| 560 |
submit_btn = gr.Button("Send", variant="primary")
|
| 561 |
clear_btn = gr.Button("Clear")
|
| 562 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
# Chat functionality
|
| 564 |
def respond(message, chat_history, files_state, is_granted):
|
| 565 |
if not is_granted:
|
|
@@ -640,37 +671,6 @@ def create_interface():
|
|
| 640 |
outputs=[file_upload, uploaded_files, uploaded_files_display, uploaded_files_display]
|
| 641 |
)
|
| 642 |
|
| 643 |
-
# Export functionality
|
| 644 |
-
with gr.Row():
|
| 645 |
-
export_btn = gr.DownloadButton(
|
| 646 |
-
"📥 Export Conversation",
|
| 647 |
-
variant="secondary",
|
| 648 |
-
size="sm"
|
| 649 |
-
)
|
| 650 |
-
|
| 651 |
-
# Export handler
|
| 652 |
-
def prepare_export():
|
| 653 |
-
if not chat_history_store:
|
| 654 |
-
return None
|
| 655 |
-
|
| 656 |
-
content = export_conversation_to_markdown(chat_history_store)
|
| 657 |
-
|
| 658 |
-
# Create filename
|
| 659 |
-
space_name_safe = re.sub(r'[^a-zA-Z0-9]+', '_', SPACE_NAME).lower()
|
| 660 |
-
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
| 661 |
-
filename = f"{space_name_safe}_conversation_{timestamp}.md"
|
| 662 |
-
|
| 663 |
-
# Save to temp file
|
| 664 |
-
temp_path = Path(tempfile.gettempdir()) / filename
|
| 665 |
-
temp_path.write_text(content, encoding='utf-8')
|
| 666 |
-
|
| 667 |
-
return str(temp_path)
|
| 668 |
-
|
| 669 |
-
export_btn.click(
|
| 670 |
-
prepare_export,
|
| 671 |
-
outputs=[export_btn]
|
| 672 |
-
)
|
| 673 |
-
|
| 674 |
# Configuration accordion
|
| 675 |
with gr.Accordion("ℹ️ Configuration", open=False):
|
| 676 |
gr.JSON(
|
|
|
|
| 20 |
'name': SPACE_NAME,
|
| 21 |
'description': SPACE_DESCRIPTION,
|
| 22 |
'system_prompt': "You are a Socratic conversation partner for students in general education courses across all disciplines with strengths in the pebble-in-the-pond learning model, responsive teaching, and constructivist learning principles. Loosely model your approach after Socrates' interlocutor Phaedrus from the eponymous Socratic dialogue, guiding students through source discovery, evaluation, and synthesis using methods of Socratic dialogue. Ask probing questions about explicit and implicit disciplinary knowledge, adapting to their skill level over the conversation and incrementing in complexity based on their demonstrated ability. Connect theory and method to grounded experiences, fostering reflexivity and critical dialogue around research methods and disciplinary practices. Select timely moments to respond with a punchy tone and ironic or self-referential levity. Expect to complete every response in under 400 tokens, and always end with a question to keep the conversation going.",
|
| 23 |
+
'temperature': 0.6,
|
| 24 |
'max_tokens': 400,
|
| 25 |
+
'model': 'openai/gpt-4.1-nano',
|
| 26 |
'api_key_var': 'API_KEY',
|
| 27 |
+
'theme': 'Glass',
|
| 28 |
'grounding_urls': ["https://classics.mit.edu/Plato/phaedrus.1b.txt", "https://plato.stanford.edu/entries/plato-rhetoric/#Pha", "https://plato.stanford.edu/entries/plato-myths/", "https://en.wikipedia.org/wiki/Socratic_method"],
|
| 29 |
'enable_dynamic_urls': True,
|
| 30 |
'enable_file_upload': True,
|
|
|
|
| 552 |
chatbot = gr.Chatbot(type="messages", height=400)
|
| 553 |
msg = gr.Textbox(label="Message", placeholder="Type your message here...", lines=2)
|
| 554 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
with gr.Row():
|
| 556 |
submit_btn = gr.Button("Send", variant="primary")
|
| 557 |
clear_btn = gr.Button("Clear")
|
| 558 |
|
| 559 |
+
# Export functionality
|
| 560 |
+
with gr.Row():
|
| 561 |
+
export_btn = gr.DownloadButton(
|
| 562 |
+
"📥 Export Conversation",
|
| 563 |
+
variant="secondary",
|
| 564 |
+
size="sm"
|
| 565 |
+
)
|
| 566 |
+
|
| 567 |
+
# Export handler
|
| 568 |
+
def prepare_export():
|
| 569 |
+
if not chat_history_store:
|
| 570 |
+
return None
|
| 571 |
+
|
| 572 |
+
content = export_conversation_to_markdown(chat_history_store)
|
| 573 |
+
|
| 574 |
+
# Create filename
|
| 575 |
+
space_name_safe = re.sub(r'[^a-zA-Z0-9]+', '_', SPACE_NAME).lower()
|
| 576 |
+
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
| 577 |
+
filename = f"{space_name_safe}_conversation_{timestamp}.md"
|
| 578 |
+
|
| 579 |
+
# Save to temp file
|
| 580 |
+
temp_path = Path(tempfile.gettempdir()) / filename
|
| 581 |
+
temp_path.write_text(content, encoding='utf-8')
|
| 582 |
+
|
| 583 |
+
return str(temp_path)
|
| 584 |
+
|
| 585 |
+
export_btn.click(
|
| 586 |
+
prepare_export,
|
| 587 |
+
outputs=[export_btn]
|
| 588 |
+
)
|
| 589 |
+
|
| 590 |
+
# Examples section
|
| 591 |
+
if examples:
|
| 592 |
+
gr.Examples(examples=examples, inputs=msg)
|
| 593 |
+
|
| 594 |
# Chat functionality
|
| 595 |
def respond(message, chat_history, files_state, is_granted):
|
| 596 |
if not is_granted:
|
|
|
|
| 671 |
outputs=[file_upload, uploaded_files, uploaded_files_display, uploaded_files_display]
|
| 672 |
)
|
| 673 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 674 |
# Configuration accordion
|
| 675 |
with gr.Accordion("ℹ️ Configuration", open=False):
|
| 676 |
gr.JSON(
|
config.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
| 1 |
{
|
| 2 |
-
"name": "Socratic Partner
|
| 3 |
-
"description": "Socratic
|
| 4 |
-
"system_prompt": "You are a Socratic conversation partner for students in general education courses across all disciplines with strengths in the pebble-in-the-pond learning model, responsive teaching, and constructivist learning principles. Loosely model your approach after Socrates' interlocutor Phaedrus from the eponymous Socratic dialogue, guiding students through source discovery, evaluation, and synthesis using methods of Socratic dialogue.
|
| 5 |
-
"model": "
|
| 6 |
"api_key_var": "API_KEY",
|
| 7 |
-
"temperature": 0.
|
| 8 |
-
"max_tokens":
|
| 9 |
"examples": [
|
| 10 |
"What makes a good research question?",
|
| 11 |
"How do I know if my sources are reliable?",
|
|
|
|
|
|
|
| 12 |
"Why does theory matter in practice?"
|
| 13 |
],
|
| 14 |
"grounding_urls": [
|
|
@@ -19,6 +21,5 @@
|
|
| 19 |
],
|
| 20 |
"enable_dynamic_urls": true,
|
| 21 |
"enable_file_upload": true,
|
| 22 |
-
"theme": "
|
| 23 |
-
"locked": false
|
| 24 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"name": "Socratic Dialogue Partner",
|
| 3 |
+
"description": "Socratic dialogue partner based on Phaedrus",
|
| 4 |
+
"system_prompt": "You are a Socratic conversation partner for students in general education courses across all disciplines with strengths in the pebble-in-the-pond learning model, responsive teaching, and constructivist learning principles. Loosely model your approach after Socrates' interlocutor Phaedrus from the eponymous Socratic dialogue, guiding students through source discovery, evaluation, and synthesis using methods of Socratic dialogue. Ask probing questions about explicit and implicit disciplinary knowledge, adapting to their skill level over the conversation and incrementing in complexity based on their demonstrated ability. Connect theory and method to grounded experiences, fostering reflexivity and critical dialogue around research methods and disciplinary practices. Select timely moments to respond with a punchy tone and ironic or self-referential levity. Expect to complete every response in under 400 tokens, and always end with a question to keep the conversation going.",
|
| 5 |
+
"model": "openai/gpt-4.1-nano",
|
| 6 |
"api_key_var": "API_KEY",
|
| 7 |
+
"temperature": 0.6,
|
| 8 |
+
"max_tokens": 400,
|
| 9 |
"examples": [
|
| 10 |
"What makes a good research question?",
|
| 11 |
"How do I know if my sources are reliable?",
|
| 12 |
+
"Help me think through my thesis argument",
|
| 13 |
+
"I'm confused about methodology - where do I start?",
|
| 14 |
"Why does theory matter in practice?"
|
| 15 |
],
|
| 16 |
"grounding_urls": [
|
|
|
|
| 21 |
],
|
| 22 |
"enable_dynamic_urls": true,
|
| 23 |
"enable_file_upload": true,
|
| 24 |
+
"theme": "Glass"
|
|
|
|
| 25 |
}
|