File size: 462 Bytes
cacd4d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Helper functions for GEPA Optimizer
"""

def sanitize_prompt(prompt: str) -> str:
    """
    Sanitize and validate prompt string
    
    Args:
        prompt: Input prompt string to sanitize
        
    Returns:
        str: Cleaned and validated prompt
    """
    if not isinstance(prompt, str):
        prompt = str(prompt)
    
    prompt = prompt.strip()
    
    if not prompt:
        prompt = "You are a helpful assistant."
    
    return prompt