Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Test the complete system message construction with both grounding URLs and file uploads | |
""" | |
def test_system_message_construction(): | |
"""Test how the system message is built with all components""" | |
# Simulate the components | |
SYSTEM_PROMPT = "You are Domenico from Sicily, a Juventus football fan, native Italian speaker serving as a conversational partner for university students in an Italian 101 class." | |
# Grounding context from URLs | |
grounding_context = """ | |
π **Reference Context:** | |
**Source 1:** π Content from https://www.pnac.org/wp-content/uploads/Italian-Study-Guide.pdf: | |
Italian Study Guide - Basic Vocabulary and Grammar | |
- Greetings: Ciao, Buongiorno, Buonasera | |
- Common phrases: Come stai? Mi chiamo... | |
- Present tense conjugations for regular verbs | |
[truncated] | |
**Source 2:** π Content from https://italian101.university.edu/resources: | |
Course materials for Italian 101 | |
- Focus on conversational practice | |
- Cultural context from Sicily and southern Italy | |
[truncated]""" | |
# Dynamic URL context | |
dynamic_context = """ | |
π **Dynamic Context:** | |
π Content from https://juventus.com/news: | |
Latest Juventus match results and player news | |
[truncated]""" | |
# File upload context | |
file_context = """ | |
[UPLOADED FILES] | |
π **homework1.pdf** (PDF, 2,345 bytes) | |
Assignment: Practice introducing yourself in Italian | |
Questions about daily routines and hobbies | |
π **vocabulary_list.txt** (856 bytes) | |
```txt | |
calcio - soccer/football | |
tifoso - fan | |
squadra - team | |
partita - match/game | |
[truncated] | |
```""" | |
# Build the complete system message as per the implementation | |
system_content = SYSTEM_PROMPT | |
# Add grounding context (includes dynamic URLs) | |
full_grounding = grounding_context + dynamic_context | |
if full_grounding: | |
system_content = f"{system_content}\n\n{full_grounding}" | |
# Add file context | |
if file_context: | |
system_content = f"{system_content}\n\n{file_context}" | |
# Display the results | |
print("=" * 80) | |
print("COMPLETE SYSTEM MESSAGE CONSTRUCTION TEST") | |
print("=" * 80) | |
print("\n1. ORIGINAL SYSTEM PROMPT:") | |
print("-" * 40) | |
print(SYSTEM_PROMPT) | |
print("\n\n2. GROUNDING CONTEXT (URLs):") | |
print("-" * 40) | |
print(full_grounding) | |
print("\n\n3. FILE UPLOAD CONTEXT:") | |
print("-" * 40) | |
print(file_context) | |
print("\n\n4. FINAL COMPLETE SYSTEM MESSAGE:") | |
print("=" * 80) | |
print(system_content) | |
print("=" * 80) | |
# Test message structure | |
messages = [ | |
{"role": "system", "content": system_content}, | |
{"role": "user", "content": "Ciao! Come stai oggi?"} | |
] | |
print("\n\n5. MESSAGE STRUCTURE:") | |
print("-" * 40) | |
print(f"System message length: {len(system_content)} characters") | |
print(f"System role: {messages[0]['role']}") | |
print(f"User message: {messages[1]['content']}") | |
print("\n\nβ TEST COMPLETE - All components properly integrated into system message") | |
return system_content | |
if __name__ == "__main__": | |
test_system_message_construction() |