File size: 1,479 Bytes
9c8703c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
def generate_human_query(user_interests: dict) -> str:
    query_parts = []
    base_phrase = "I am interested in museum artifacts"
    
    # 1. Handle time periods.
    if user_interests.get("time_periods"):
        periods_list = " and ".join(user_interests["time_periods"])
        query_parts.append(f"from the {periods_list} Dynasty periods")
    
    # 2. Handle art mediums and themes.
    art_details = []
    if user_interests.get("art_medium"):
        mediums_list = " and ".join(user_interests["art_medium"])
        art_details.append(mediums_list)
    if user_interests.get("themes"):
        themes_list = " and ".join(user_interests["themes"])
        art_details.append(themes_list)
    
    if art_details:
        query_parts.append("focusing on " + " and ".join(art_details))
        
    # 3. Handle keywords.
    if user_interests.get("keywords"):
        keywords_str = ", ".join(user_interests["keywords"])
        # Add connecting phrase based on previous parts.
        if query_parts:
            query_parts.append(f"and with interests in {keywords_str}")
        else:
            query_parts.append(f"with interests in {keywords_str}")
    
    # Combine all parts.
    if query_parts:
        final_query = f"{base_phrase} " + ", ".join(query_parts) + "."
    else:
        final_query = "I am looking for general museum artifacts."
    
    # Capitalize the first letter.
    return final_query[0].upper() + final_query[1:] if final_query else ""