(
env: Environment,
config: str,
workdir: str,
model: str,
keep_thinking_log: bool,
debug_output_folder: str,
)
| 209 | ) |
| 210 | @pass_env |
| 211 | def extract( |
| 212 | env: Environment, |
| 213 | config: str, |
| 214 | workdir: str, |
| 215 | model: str, |
| 216 | keep_thinking_log: bool, |
| 217 | debug_output_folder: str, |
| 218 | ): |
| 219 | workdir_path = pathlib.Path(workdir) |
| 220 | inbox_doc = load_inbox_doc(config) |
| 221 | |
| 222 | logger.info( |
| 223 | "Extracting data with Ollama model [green]%s[/]", |
| 224 | model, |
| 225 | extra={"markup": True, "highlighter": None}, |
| 226 | ) |
| 227 | debug_output_path = None |
| 228 | if debug_output_folder is not None: |
| 229 | debug_output_path = pathlib.Path(debug_output_folder) |
| 230 | debug_output_path.mkdir(parents=True, exist_ok=True) |
| 231 | logger.info( |
| 232 | "Writing debugging files to [magenta]%s[/] folder", |
| 233 | debug_output_path, |
| 234 | extra={"markup": True, "highlighter": None}, |
| 235 | ) |
| 236 | |
| 237 | inbox_logger = logging.getLogger("beanhub_inbox") |
| 238 | inbox_logger.setLevel(logging.WARNING) |
| 239 | |
| 240 | # TODO: config logs for inbox lib |
| 241 | process_event_generators = process_imports( |
| 242 | inbox_doc=inbox_doc, |
| 243 | input_dir=workdir_path, |
| 244 | llm_model=model, |
| 245 | workdir_path=workdir_path, |
| 246 | ) |
| 247 | for event in process_event_generators: |
| 248 | if isinstance(event, StartProcessingEmail): |
| 249 | logger.info( |
| 250 | "Processing email [green]%s[/] at [green]%s[/], subject: [blue]%s[/]", |
| 251 | event.email_file.id, |
| 252 | event.email_file.filepath, |
| 253 | event.email_file.subject, |
| 254 | extra={"markup": True, "highlighter": None}, |
| 255 | ) |
| 256 | elif isinstance(event, NoMatch): |
| 257 | logger.info( |
| 258 | "No import rule matched for email [green]%s[/]", |
| 259 | event.email_file.id, |
| 260 | extra={"markup": True, "highlighter": None}, |
| 261 | ) |
| 262 | elif isinstance(event, MatchImportRule): |
| 263 | logger.info( |
| 264 | "Import rule [green]%s[/] matched", |
| 265 | event.import_config.name |
| 266 | if event.import_config.name is not None |
| 267 | else event.import_rule_index, |
| 268 | extra={"markup": True, "highlighter": None}, |
nothing calls this directly
no test coverage detected