File size: 3,134 Bytes
217dd65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/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()