File size: 1,094 Bytes
5ea745b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be5ca66
5ea745b
e1ed8d0
 
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
# Import all prompts as both constants and in a PROMPTS dictionary,
# from all files in the prompts directory that aren't __init__.py 

import os

def load_constants(constants_dir):
    """Loads constants from .py files in the specified directory."""

    constants = {}

    for filename in os.listdir(constants_dir):
        if filename.endswith(".py") and filename != "__init__.py":
            module_name = filename[:-3]  # Remove .py extension
            module = __import__(f"{constants_dir}.{module_name}", fromlist=[module_name])

            for name, value in vars(module).items():
                if name.isupper():  # Convention for constants
                    constants[name] = value

    return constants

PROMPTS = load_constants("prompts")

# Import all prompts locally as well, for code completion
from transformers.agents.prompts import DEFAULT_REACT_CODE_SYSTEM_PROMPT
from prompts.default import DEFAULT_SQUAD_REACT_CODE_SYSTEM_PROMPT
from prompts.succinct import SUCCINCT_SQUAD_REACT_CODE_SYSTEM_PROMPT
from prompts.focused import FOCUSED_SQUAD_REACT_CODE_SYSTEM_PROMPT