agents.chain.examples¶
Examples of using DeclarativeChainAgent to build complex RAG flows.
Shows how to recreate our complex agents using declarative specifications.
Classes¶
Strategy decision for RAG routing. |
Functions¶
|
Create an agentic RAG router using declarative chain building. |
Create a complex flow using raw ChainSpec. |
|
|
Create query execution plan. |
|
Create a query planning RAG using declarative chain building. |
Create a RAG with fallback strategies. |
|
|
Create a self-reflective RAG using declarative chain building. |
|
Execute one sub-query. |
|
Finalize the answer. |
|
Improve the answer based on critique. |
|
Reflect on answer quality. |
|
Synthesize all sub-query results. |
Module Contents¶
- class agents.chain.examples.StrategyDecision(/, **data)¶
Bases:
pydantic.BaseModel
Strategy decision for RAG routing.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (Any)
- agents.chain.examples.create_agentic_router_declarative(documents)¶
Create an agentic RAG router using declarative chain building.
- Parameters:
documents (list[langchain_core.documents.Document])
- agents.chain.examples.create_complex_flow_from_spec()¶
Create a complex flow using raw ChainSpec.
- Return type:
Any
- agents.chain.examples.create_plan(state)¶
Create query execution plan.
- agents.chain.examples.create_query_planning_declarative(documents)¶
Create a query planning RAG using declarative chain building.
- Parameters:
documents (list[langchain_core.documents.Document])
- agents.chain.examples.create_rag_with_fallback()¶
Create a RAG with fallback strategies.
- Return type:
Any
- agents.chain.examples.create_self_reflective_declarative(documents)¶
Create a self-reflective RAG using declarative chain building.
- Parameters:
documents (list[langchain_core.documents.Document])
- agents.chain.examples.execute_sub_query(state)¶
Execute one sub-query.
- agents.chain.examples.finalize_answer(state)¶
Finalize the answer.
- agents.chain.examples.improve_answer(state)¶
Improve the answer based on critique.
- agents.chain.examples.reflect_and_critique(state)¶
Reflect on answer quality.