Spaces:
Running
Running
File size: 5,765 Bytes
026ee5d |
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# Agents API Reference
This page documents the API for DeepCritical agents.
## KnowledgeGapAgent
**Module**: `src.agents.knowledge_gap`
**Purpose**: Evaluates research state and identifies knowledge gaps.
### Methods
#### `evaluate`
```python
async def evaluate(
self,
query: str,
background_context: str,
conversation_history: Conversation,
iteration: int,
time_elapsed_minutes: float,
max_time_minutes: float
) -> KnowledgeGapOutput
```
Evaluates research completeness and identifies outstanding knowledge gaps.
**Parameters**:
- `query`: Research query string
- `background_context`: Background context for the query
- `conversation_history`: Conversation history with previous iterations
- `iteration`: Current iteration number
- `time_elapsed_minutes`: Elapsed time in minutes
- `max_time_minutes`: Maximum time limit in minutes
**Returns**: `KnowledgeGapOutput` with:
- `research_complete`: Boolean indicating if research is complete
- `outstanding_gaps`: List of remaining knowledge gaps
## ToolSelectorAgent
**Module**: `src.agents.tool_selector`
**Purpose**: Selects appropriate tools for addressing knowledge gaps.
### Methods
#### `select_tools`
```python
async def select_tools(
self,
query: str,
knowledge_gaps: list[str],
available_tools: list[str]
) -> AgentSelectionPlan
```
Selects tools for addressing knowledge gaps.
**Parameters**:
- `query`: Research query string
- `knowledge_gaps`: List of knowledge gaps to address
- `available_tools`: List of available tool names
**Returns**: `AgentSelectionPlan` with list of `AgentTask` objects.
## WriterAgent
**Module**: `src.agents.writer`
**Purpose**: Generates final reports from research findings.
### Methods
#### `write_report`
```python
async def write_report(
self,
query: str,
findings: str,
output_length: str = "medium",
output_instructions: str | None = None
) -> str
```
Generates a markdown report from research findings.
**Parameters**:
- `query`: Research query string
- `findings`: Research findings to include in report
- `output_length`: Desired output length ("short", "medium", "long")
- `output_instructions`: Additional instructions for report generation
**Returns**: Markdown string with numbered citations.
## LongWriterAgent
**Module**: `src.agents.long_writer`
**Purpose**: Long-form report generation with section-by-section writing.
### Methods
#### `write_next_section`
```python
async def write_next_section(
self,
query: str,
draft: ReportDraft,
section_title: str,
section_content: str
) -> LongWriterOutput
```
Writes the next section of a long-form report.
**Parameters**:
- `query`: Research query string
- `draft`: Current report draft
- `section_title`: Title of the section to write
- `section_content`: Content/guidance for the section
**Returns**: `LongWriterOutput` with updated draft.
#### `write_report`
```python
async def write_report(
self,
query: str,
report_title: str,
report_draft: ReportDraft
) -> str
```
Generates final report from draft.
**Parameters**:
- `query`: Research query string
- `report_title`: Title of the report
- `report_draft`: Complete report draft
**Returns**: Final markdown report string.
## ProofreaderAgent
**Module**: `src.agents.proofreader`
**Purpose**: Proofreads and polishes report drafts.
### Methods
#### `proofread`
```python
async def proofread(
self,
query: str,
report_title: str,
report_draft: ReportDraft
) -> str
```
Proofreads and polishes a report draft.
**Parameters**:
- `query`: Research query string
- `report_title`: Title of the report
- `report_draft`: Report draft to proofread
**Returns**: Polished markdown string.
## ThinkingAgent
**Module**: `src.agents.thinking`
**Purpose**: Generates observations from conversation history.
### Methods
#### `generate_observations`
```python
async def generate_observations(
self,
query: str,
background_context: str,
conversation_history: Conversation
) -> str
```
Generates observations from conversation history.
**Parameters**:
- `query`: Research query string
- `background_context`: Background context
- `conversation_history`: Conversation history
**Returns**: Observation string.
## InputParserAgent
**Module**: `src.agents.input_parser`
**Purpose**: Parses and improves user queries, detects research mode.
### Methods
#### `parse_query`
```python
async def parse_query(
self,
query: str
) -> ParsedQuery
```
Parses and improves a user query.
**Parameters**:
- `query`: Original query string
**Returns**: `ParsedQuery` with:
- `original_query`: Original query string
- `improved_query`: Refined query string
- `research_mode`: "iterative" or "deep"
- `key_entities`: List of key entities
- `research_questions`: List of research questions
## Factory Functions
All agents have factory functions in `src.agent_factory.agents`:
```python
def create_knowledge_gap_agent(model: Any | None = None) -> KnowledgeGapAgent
def create_tool_selector_agent(model: Any | None = None) -> ToolSelectorAgent
def create_writer_agent(model: Any | None = None) -> WriterAgent
def create_long_writer_agent(model: Any | None = None) -> LongWriterAgent
def create_proofreader_agent(model: Any | None = None) -> ProofreaderAgent
def create_thinking_agent(model: Any | None = None) -> ThinkingAgent
def create_input_parser_agent(model: Any | None = None) -> InputParserAgent
```
**Parameters**:
- `model`: Optional Pydantic AI model. If None, uses `get_model()` from settings.
**Returns**: Agent instance.
## See Also
- [Architecture - Agents](../architecture/agents.md) - Architecture overview
- [Models API](models.md) - Data models used by agents
|