-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
126 lines (104 loc) · 3.82 KB
/
config.py
File metadata and controls
126 lines (104 loc) · 3.82 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
"""
Configuration for the Program Research Agent.
Loads settings from environment variables and provides defaults.
"""
from pathlib import Path
from dotenv import load_dotenv
from pydantic import Field
from pydantic_settings import BaseSettings
# Load .env file if present
load_dotenv()
class Settings(BaseSettings):
"""Application settings loaded from environment."""
# ----- API Keys -----
anthropic_api_key: str = Field(
default="",
description="Anthropic API key for Claude",
)
linear_api_key: str = Field(
default="",
description="Linear API key for ticket creation",
)
# ----- Model Configuration -----
researcher_model: str = Field(
default="claude-opus-4-6",
description="Model to use for researcher agent (extraction, generation)",
)
qa_model: str = Field(
default="claude-opus-4-6",
description="Model to use for QA agent (validation, error detection)",
)
model_temperature: float = Field(
default=0.1,
description="Temperature for model responses (lower = more deterministic)",
)
model_max_tokens: int = Field(
default=8192,
description="Maximum tokens for model responses",
)
model_max_retries: int = Field(
default=5,
description="Maximum retries for API calls (handles transient 500 errors)",
)
# ----- Workflow Configuration -----
max_qa_iterations: int = Field(
default=3,
description="Maximum QA loop iterations before proceeding",
)
max_links_per_source: int = Field(
default=50,
description="Maximum links to extract from a single source",
)
web_request_timeout: int = Field(
default=60,
description="Timeout in seconds for web requests",
)
# ----- Paths -----
project_root: Path = Field(
default=Path(__file__).parent.parent,
description="Root directory of the MFB project",
)
output_dir: Path = Field(
default=Path(__file__).parent / "output",
description="Directory for output files",
)
schema_url: str = Field(
default="https://raw.githubusercontent.com/MyFriendBen/benefits-api/main/validations/management/commands/import_validations/test_case_schema.json",
description="URL to fetch the JSON test case schema from",
)
# ----- Backend Paths (for reading screener fields) -----
backend_models_path: Path = Field(
default=Path(__file__).parent.parent / "benefits-api" / "screener" / "models.py",
description="Path to Django screener models",
)
frontend_types_path: Path = Field(
default=Path(__file__).parent.parent / "benefits-calculator" / "src" / "Types" / "FormData.ts",
description="Path to frontend type definitions",
)
# ----- Linear Configuration -----
linear_team_id: str = Field(
default="",
description="Linear team ID for ticket creation",
)
linear_project_id: str = Field(
default="",
description="Linear project ID for new programs",
)
class Config:
env_prefix = "RESEARCH_AGENT_"
env_file = ".env"
extra = "ignore"
# Global settings instance
settings = Settings()
def get_output_path(filename: str) -> Path:
"""Get the full path to an output file, creating the directory if needed."""
settings.output_dir.mkdir(parents=True, exist_ok=True)
return settings.output_dir / filename
def validate_settings() -> list[str]:
"""Validate that required settings are configured. Returns list of errors."""
errors = []
if not settings.anthropic_api_key:
errors.append("RESEARCH_AGENT_ANTHROPIC_API_KEY is required")
if not settings.backend_models_path.exists():
errors.append(f"Backend models not found at {settings.backend_models_path}")
return errors