kaxil opened a new pull request, #67924:
URL: https://github.com/apache/airflow/pull/67924

   ## Summary
   
   Commit 9318bd6250 (#67644) stopped the common.ai LLM operators from calling 
`model_dump()` on Pydantic `output_type` results before pushing to XCom. 
Downstream tasks now receive the model instance instead of a dict. The 
[`example_langchain_10k`](https://github.com/apache/airflow/blob/main/providers/common/ai/src/airflow/providers/common/ai/example_dags/example_langchain_10k.py)
 and 
[`example_llamaindex_10k`](https://github.com/apache/airflow/blob/main/providers/common/ai/src/airflow/providers/common/ai/example_dags/example_llamaindex_10k.py)
 DAGs were never updated, so their consumer tasks still subscripted the result 
as a dict (`decomposed["sub_questions"]`, `report["executive_summary"]`, 
`sq["ticker"]`) and now fail with `TypeError: '...' object is not 
subscriptable` on current main.
   
   ## What changed
   
   Switched the four consumer tasks in each example DAG to attribute access and 
typed their parameters with the model classes:
   
   - `extract_sub_questions(decomposed: DecomposedQuestion)` returns 
`decomposed.sub_questions`
   - `build_retrieval_kwargs(sub_questions: list[SubQuestion])` uses 
`sq.sub_question`, `sq.ticker`
   - `collect_results(...)` uses `sq.ticker`, `sq.sub_question`
   - `format_report(report: AnalysisReport)` uses `report.executive_summary`, 
`report.company_findings`, `report.key_risks`, `report.recommendations`
   
   This is the access pattern #67644 was built to enable, so the examples now 
demonstrate it.
   
   ## Left as dict access (intentional)
   
   - `finding` inside `company_findings`, which is typed `list[dict]` on 
`AnalysisReport`, so each finding stays a plain dict
   - retrieval chunks (`r["chunks"]`, `c["score"]`, `c["text"]`) produced by 
the retrieval operators as plain dicts
   - `hitl_response` and the SEC EDGAR filing dicts
   
   ## Why the cross-task round-trip works
   
   The consuming tasks are plain `@task` functions, not LLM operators, but the 
worker-side operator walk added in #67875 registers `decompose_question`'s 
`output_type=DecomposedQuestion` plus the reachable `SubQuestion`, so those 
workers can deserialize the model instances handed down through XCom.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to