chatui-helper / test_complete_system.py
milwright
fix language instructions in generated space template
217dd65
raw
history blame
3.13 kB
#!/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()