|
15 | 15 | from __future__ import annotations |
16 | 16 |
|
17 | 17 | import asyncio |
| 18 | +from dataclasses import dataclass |
| 19 | +from dataclasses import field |
18 | 20 | import logging |
19 | 21 | from typing import Any |
20 | 22 | from typing import Optional |
@@ -178,31 +180,20 @@ async def run_async( |
178 | 180 | return {'error': f'Extraction failed: {e}'} |
179 | 181 |
|
180 | 182 |
|
| 183 | +@dataclass |
181 | 184 | class LangExtractToolConfig: |
182 | | - """Configuration dataclass for LangExtractTool.""" |
183 | | - |
184 | | - def __init__( |
185 | | - self, |
186 | | - *, |
187 | | - name: str = 'langextract', |
188 | | - description: str = ( |
189 | | - 'Extracts structured information from unstructured text.' |
190 | | - ), |
191 | | - examples: Optional[list[lx.data.ExampleData]] = None, |
192 | | - model_id: str = 'gemini-2.5-flash', |
193 | | - api_key: Optional[str] = None, |
194 | | - extraction_passes: int = 1, |
195 | | - max_workers: int = 1, |
196 | | - max_char_buffer: int = 4000, |
197 | | - ): |
198 | | - self.name = name |
199 | | - self.description = description |
200 | | - self.examples = examples or [] |
201 | | - self.model_id = model_id |
202 | | - self.api_key = api_key |
203 | | - self.extraction_passes = extraction_passes |
204 | | - self.max_workers = max_workers |
205 | | - self.max_char_buffer = max_char_buffer |
| 185 | + """Configuration for LangExtractTool.""" |
| 186 | + |
| 187 | + name: str = 'langextract' |
| 188 | + description: str = ( |
| 189 | + 'Extracts structured information from unstructured text.' |
| 190 | + ) |
| 191 | + examples: list[lx.data.ExampleData] = field(default_factory=list) |
| 192 | + model_id: str = 'gemini-2.5-flash' |
| 193 | + api_key: Optional[str] = None |
| 194 | + extraction_passes: int = 1 |
| 195 | + max_workers: int = 1 |
| 196 | + max_char_buffer: int = 4000 |
206 | 197 |
|
207 | 198 | def build(self) -> LangExtractTool: |
208 | 199 | """Instantiate a LangExtractTool from this config.""" |
|
0 commit comments