Detailed Pipeline Steps¶
This document provides a technical breakdown of the OpenHosta execution pipeline, detailing the responsibility of each step.
1. Analysis Phase (core/analizer.py)¶
- Responsibility: Inspect the calling function's signature and documentation.
- Key Step:
hosta_analyze() - Uses
inspect.signatureto get parameters. - Uses
typing.get_type_hintsto resolve annotations. - Generates an
AnalyzedFunctiondataclass.
2. Preparation (Push Phase - pipelines/simple_pipeline.py)¶
push_detect_missing_types: Fills inAnyorstrif annotations are missing.push_choose_model: Matches required capabilities (Text, Image, JSON, Logprobs) against available models.push_check_uncertainty(Safe Context):- If inside a
safe()block, it injects theseedto ensure reproducibility. - It automatically injects
{"logprobs": True, "top_logprobs": 20}into the LLM parameters if the model supports it. push_encode_inspected_data: Callsencode_functionto transform the analysis into prompt-ready snippets (docstrings, type definitions viaTypeResolver).push_select_meta_prompts: Chooses the appropriate system and user templates.push_build_messages: Renders the templates with the encoded data to produce the final payload for the LLM API.
3. Execution (core/base_model.py)¶
- Responsibility: Send the payload to the LLM and receive the raw response.
- Retries: The pipeline handles retries here if subsequent parsing fails.
4. Processing (Pull Phase - pipelines/simple_pipeline.py)¶
pull_extract_messages: Retrieves the text content from the API response format.pull_extract_data_section: Identifies "Thinking" vs "Answer" blocks (crucial for reasoning models).pull_type_data_section:- Calls
TypeResolver.resolve()to get the executableGuardedPrimitive. - Calls
guarded_type.attempt()to parse the string into a Python object. - Performs
.unwrap()if a native type was expected (unless a Guarded type was explicitly requested). pull_check_uncertainty:- If inside a
safe()block, it extracts the logprobs from the response. - For Enums, it uses
get_enum_logprobesto calculate probabilities for all valid members. - For other types, it uses
get_certaintyto estimate the confidence of the generated answer. - Updates the
cumulated_uncertaintyin the safety context and raisesUncertaintyErrorif the threshold is exceeded.