File size: 1,158 Bytes
1a4ef4f
42ae0c5
794b339
 
 
 
 
 
 
42ae0c5
794b339
 
 
 
febe906
794b339
 
 
 
 
 
 
 
 
 
 
 
 
 
73a7ab9
616b330
8b223af
6ad5b12
 
 
 
8252cd7
6ad5b12
 
8252cd7
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
import yaml

from smolagents import (
    PromptTemplates,
    PlanningPromptTemplate,
    FinalAnswerPromptTemplate,
    ManagedAgentPromptTemplate,
)

def load_prompts():

    """Builds a CodeAgent using the custom system and planning prompts from code_agent.yaml."""

    # 1) Load YAML
    with open("prompts/code_agent.yaml", "r", encoding="utf-8") as f:
        y = yaml.safe_load(f)

    # 2) Build PromptTemplates
    templates = PromptTemplates(
        system_prompt=y.get("system_prompt", ""),
        planning=PlanningPromptTemplate(**y.get("planning", {})),
        managed_agent=ManagedAgentPromptTemplate(**y.get("managed_agent", {})),
        final_answer=FinalAnswerPromptTemplate(**y.get("final_answer", {})),
    )

    return templates


def load_prompts2():
    system_prompt_override = "prompts/code_agent.yaml"
    
    try:
        with open(system_prompt_override, 'r', encoding='utf-8') as file:
            return file.read()
    except FileNotFoundError:
        raise FileNotFoundError(f"Prompt file '{system_prompt_override}' not found.")
    except Exception as e:
        raise Exception(f"Failed to read prompt file: {e}")