Send feedback
Class LlamaIndexQueryPipelineAgent (1.95.1)
Stay organized with collections
Save and categorize content based on your preferences.
Version latestkeyboard_arrow_down
LlamaIndexQueryPipelineAgent (
model : str ,
* ,
system_instruction : typing . Optional [ str ] = None ,
prompt : typing . Optional [ QueryComponent ] = None ,
model_kwargs : typing . Optional [ typing . Mapping [ str , typing . Any ]] = None ,
model_builder : typing . Optional [ typing . Callable [[ ... ], FunctionCallingLLM ]] = None ,
retriever_kwargs : typing . Optional [ typing . Mapping [ str , typing . Any ]] = None ,
retriever_builder : typing . Optional [ typing . Callable [[ ... ], QueryComponent ]] = None ,
response_synthesizer_kwargs : typing . Optional [
typing . Mapping [ str , typing . Any ]
] = None ,
response_synthesizer_builder : typing . Optional [
typing . Callable [[ ... ], QueryComponent ]
] = None ,
runnable_kwargs : typing . Optional [ typing . Mapping [ str , typing . Any ]] = None ,
runnable_builder : typing . Optional [ typing . Callable [[ ... ], QueryPipeline ]] = None ,
enable_tracing : bool = False
)
Methods
LlamaIndexQueryPipelineAgent
LlamaIndexQueryPipelineAgent (
model : str ,
* ,
system_instruction : typing . Optional [ str ] = None ,
prompt : typing . Optional [ QueryComponent ] = None ,
model_kwargs : typing . Optional [ typing . Mapping [ str , typing . Any ]] = None ,
model_builder : typing . Optional [ typing . Callable [[ ... ], FunctionCallingLLM ]] = None ,
retriever_kwargs : typing . Optional [ typing . Mapping [ str , typing . Any ]] = None ,
retriever_builder : typing . Optional [ typing . Callable [[ ... ], QueryComponent ]] = None ,
response_synthesizer_kwargs : typing . Optional [
typing . Mapping [ str , typing . Any ]
] = None ,
response_synthesizer_builder : typing . Optional [
typing . Callable [[ ... ], QueryComponent ]
] = None ,
runnable_kwargs : typing . Optional [ typing . Mapping [ str , typing . Any ]] = None ,
runnable_builder : typing . Optional [ typing . Callable [[ ... ], QueryPipeline ]] = None ,
enable_tracing : bool = False
)
Initializes the LlamaIndexQueryPipelineAgent.
Under-the-hood, assuming .set_up() is called, this will correspond to
# model_builder
model = model_builder(model_name, project, location, model_kwargs)
# runnable_builder
runnable = runnable_builder(
prompt=prompt,
model=model,
retriever=retriever_builder(model, retriever_kwargs),
response_synthesizer=response_synthesizer_builder(
model, response_synthesizer_kwargs
),
runnable_kwargs=runnable_kwargs,
)
When everything is based on their default values, this corresponds to a
query pipeline Prompt - Model
:
# Default Model Builder
model = google_genai.GoogleGenAI(
model=model_name,
vertexai_config={
"project": initializer.global_config.project,
"location": initializer.global_config.location,
},
)
# Default Prompt Builder
prompt = prompts.ChatPromptTemplate(
message_templates=[
types.ChatMessage(
role=types.MessageRole.USER,
content="{input}",
),
],
)
# Default Runnable Builder
runnable = QueryPipeline(
modules = {
"prompt": prompt,
"model": model,
},
)
pipeline.add_link("prompt", "model")
When system_instruction
is specified, the prompt will be updated to
include the system instruction.
# Updated Prompt Builder
prompt = prompts.ChatPromptTemplate(
message_templates=[
types.ChatMessage(
role=types.MessageRole.SYSTEM,
content=system_instruction,
),
types.ChatMessage(
role=types.MessageRole.USER,
content="{input}",
),
],
)
When all inputs are specified, this corresponds to a query pipeline
Prompt - Model - Retriever - Summarizer
:
runnable = QueryPipeline(
modules = {
"prompt": prompt,
"model": model,
"retriever": retriever_builder(retriever_kwargs),
"response_synthesizer": response_synthesizer_builder(
response_synthesizer_kwargs
),
},
)
pipeline.add_link("prompt", "model")
pipeline.add_link("model", "retriever")
pipeline.add_link("model", "response_synthesizer", dest_key="query_str")
pipeline.add_link("retriever", "response_synthesizer", dest_key="nodes")
Parameters
Name
Description
model
str
The name of the model (e.g. "gemini-1.0-pro").
system_instruction
str
Optional. The system instruction to use for the agent.
prompt
llama_index.core.base.query_pipeline.query.QUERY_COMPONENT_TYPE
Optional. The prompt template for the model.
model_kwargs
Mapping[str, Any]
Optional. Keyword arguments for the model constructor of the google_genai.GoogleGenAI. An example of a model_kwargs is:
python { # api_key (string): The API key for the GoogleGenAI model. # The API can also be fetched from the GOOGLE_API_KEY # environment variable. If vertexai_config
is provided, # the API key is ignored. "api_key": "your_api_key", # temperature (float): Sampling temperature, it controls the # degree of randomness in token selection. If not provided, # the default temperature is 0.1. "temperature": 0.1, # context_window (int): The context window of the model. # If not provided, the default context window is 200000. "context_window": 200000, # max_tokens (int): Token limit determines the maximum # amount of text output from one prompt. If not provided, # the default max_tokens is 256. "max_tokens": 256, # is_function_calling_model (bool): Whether the model is a # function calling model. If not provided, the default # is_function_calling_model is True. "is_function_calling_model": True, }
model_builder
Callable
Optional. Callable that returns a language model.
retriever_kwargs
Mapping[str, Any]
Optional. Keyword arguments for the retriever constructor.
retriever_builder
Callable
Optional. Callable that returns a retriever object.
response_synthesizer_kwargs
Mapping[str, Any]
Optional. Keyword arguments for the response synthesizer constructor.
response_synthesizer_builder
Callable
Optional. Callable that returns a response_synthesizer object.
runnable_kwargs
Mapping[str, Any]
Optional. Keyword arguments for the runnable constructor.
runnable_builder
Callable
Optional. Callable that returns a runnable (query pipeline).
enable_tracing
bool
Optional. Whether to enable tracing. Defaults to False.
clone
clone () - > (
vertexai . preview . reasoning_engines . templates . llama_index . LlamaIndexQueryPipelineAgent
)
Returns a clone of the LlamaIndexQueryPipelineAgent.
query
query (
input : typing . Union [ str , typing . Mapping [ str , typing . Any ]], ** kwargs : typing . Any
) - > typing . Union [
str ,
typing . Dict [ str , typing . Any ],
typing . Sequence [ typing . Union [ str , typing . Dict [ str , typing . Any ]]],
]
Queries the Agent with the given input and config.
Parameter
Name
Description
input
Union[str, Mapping[str, Any]]
Required. The input to be passed to the Agent.
set_up
Sets up the agent for execution of queries at runtime.
It initializes the model, connects it with the prompt template,
retriever and response_synthesizer.
This method should not be called for an object that being passed to
the ReasoningEngine service for deployment, as it initializes clients
that can not be serialized.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class LlamaIndexQueryPipelineAgent (1.95.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.95.1 (latest)](/python/docs/reference/vertexai/latest/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.94.0](/python/docs/reference/vertexai/1.94.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.93.1](/python/docs/reference/vertexai/1.93.1/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.92.0](/python/docs/reference/vertexai/1.92.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.91.0](/python/docs/reference/vertexai/1.91.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.90.0](/python/docs/reference/vertexai/1.90.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.89.0](/python/docs/reference/vertexai/1.89.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.88.0](/python/docs/reference/vertexai/1.88.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.87.0](/python/docs/reference/vertexai/1.87.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.86.0](/python/docs/reference/vertexai/1.86.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.85.0](/python/docs/reference/vertexai/1.85.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.84.0](/python/docs/reference/vertexai/1.84.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.83.0](/python/docs/reference/vertexai/1.83.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.82.0](/python/docs/reference/vertexai/1.82.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.81.0](/python/docs/reference/vertexai/1.81.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.80.0](/python/docs/reference/vertexai/1.80.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.79.0](/python/docs/reference/vertexai/1.79.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.78.0](/python/docs/reference/vertexai/1.78.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.77.0](/python/docs/reference/vertexai/1.77.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.76.0](/python/docs/reference/vertexai/1.76.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.75.0](/python/docs/reference/vertexai/1.75.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.74.0](/python/docs/reference/vertexai/1.74.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.73.0](/python/docs/reference/vertexai/1.73.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.72.0](/python/docs/reference/vertexai/1.72.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.71.1](/python/docs/reference/vertexai/1.71.1/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.70.0](/python/docs/reference/vertexai/1.70.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.69.0](/python/docs/reference/vertexai/1.69.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.68.0](/python/docs/reference/vertexai/1.68.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.67.1](/python/docs/reference/vertexai/1.67.1/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.66.0](/python/docs/reference/vertexai/1.66.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.65.0](/python/docs/reference/vertexai/1.65.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.63.0](/python/docs/reference/vertexai/1.63.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.62.0](/python/docs/reference/vertexai/1.62.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.60.0](/python/docs/reference/vertexai/1.60.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent)\n- [1.59.0](/python/docs/reference/vertexai/1.59.0/vertexai.preview.reasoning_engines.LlamaIndexQueryPipelineAgent) \n\n LlamaIndexQueryPipelineAgent(\n model: str,\n *,\n system_instruction: typing.Optional[str] = None,\n prompt: typing.Optional[QueryComponent] = None,\n model_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n model_builder: typing.Optional[typing.Callable[[...], FunctionCallingLLM]] = None,\n retriever_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n retriever_builder: typing.Optional[typing.Callable[[...], QueryComponent]] = None,\n response_synthesizer_kwargs: typing.Optional[\n typing.Mapping[str, typing.Any]\n ] = None,\n response_synthesizer_builder: typing.Optional[\n typing.Callable[[...], QueryComponent]\n ] = None,\n runnable_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n runnable_builder: typing.Optional[typing.Callable[[...], QueryPipeline]] = None,\n enable_tracing: bool = False\n )\n\nA LlamaIndex Query Pipeline Agent.\n\nThis agent uses a query pipeline for LLAIndex, including prompt, model,\nretrieval and summarization steps. More details can be found in\n\u003chttps://docs.llamaindex.ai/en/stable/module_guides/querying/pipeline/\u003e.\n\nMethods\n-------\n\n### LlamaIndexQueryPipelineAgent\n\n LlamaIndexQueryPipelineAgent(\n model: str,\n *,\n system_instruction: typing.Optional[str] = None,\n prompt: typing.Optional[QueryComponent] = None,\n model_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n model_builder: typing.Optional[typing.Callable[[...], FunctionCallingLLM]] = None,\n retriever_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n retriever_builder: typing.Optional[typing.Callable[[...], QueryComponent]] = None,\n response_synthesizer_kwargs: typing.Optional[\n typing.Mapping[str, typing.Any]\n ] = None,\n response_synthesizer_builder: typing.Optional[\n typing.Callable[[...], QueryComponent]\n ] = None,\n runnable_kwargs: typing.Optional[typing.Mapping[str, typing.Any]] = None,\n runnable_builder: typing.Optional[typing.Callable[[...], QueryPipeline]] = None,\n enable_tracing: bool = False\n )\n\nInitializes the LlamaIndexQueryPipelineAgent.\n\nUnder-the-hood, assuming .set_up() is called, this will correspond to \n\n # model_builder\n model = model_builder(model_name, project, location, model_kwargs)\n\n # runnable_builder\n runnable = runnable_builder(\n prompt=prompt,\n model=model,\n retriever=retriever_builder(model, retriever_kwargs),\n response_synthesizer=response_synthesizer_builder(\n model, response_synthesizer_kwargs\n ),\n runnable_kwargs=runnable_kwargs,\n )\n\nWhen everything is based on their default values, this corresponds to a\nquery pipeline `Prompt - Model`: \n\n # Default Model Builder\n model = google_genai.GoogleGenAI(\n model=model_name,\n vertexai_config={\n \"project\": initializer.global_config.project,\n \"location\": initializer.global_config.location,\n },\n )\n\n # Default Prompt Builder\n prompt = prompts.ChatPromptTemplate(\n message_templates=[\n types.ChatMessage(\n role=types.MessageRole.USER,\n content=\"{input}\",\n ),\n ],\n )\n\n # Default Runnable Builder\n runnable = QueryPipeline(\n modules = {\n \"prompt\": prompt,\n \"model\": model,\n },\n )\n pipeline.add_link(\"prompt\", \"model\")\n\nWhen `system_instruction` is specified, the prompt will be updated to\ninclude the system instruction. \n\n # Updated Prompt Builder\n prompt = prompts.ChatPromptTemplate(\n message_templates=[\n types.ChatMessage(\n role=types.MessageRole.SYSTEM,\n content=system_instruction,\n ),\n types.ChatMessage(\n role=types.MessageRole.USER,\n content=\"{input}\",\n ),\n ],\n )\n\nWhen all inputs are specified, this corresponds to a query pipeline\n`Prompt - Model - Retriever - Summarizer`: \n\n runnable = QueryPipeline(\n modules = {\n \"prompt\": prompt,\n \"model\": model,\n \"retriever\": retriever_builder(retriever_kwargs),\n \"response_synthesizer\": response_synthesizer_builder(\n response_synthesizer_kwargs\n ),\n },\n )\n pipeline.add_link(\"prompt\", \"model\")\n pipeline.add_link(\"model\", \"retriever\")\n pipeline.add_link(\"model\", \"response_synthesizer\", dest_key=\"query_str\")\n pipeline.add_link(\"retriever\", \"response_synthesizer\", dest_key=\"nodes\")\n\n### clone\n\n clone() -\u003e (\n vertexai.preview.reasoning_engines.templates.llama_index.LlamaIndexQueryPipelineAgent\n )\n\nReturns a clone of the LlamaIndexQueryPipelineAgent.\n\n### query\n\n query(\n input: typing.Union[str, typing.Mapping[str, typing.Any]], **kwargs: typing.Any\n ) -\u003e typing.Union[\n str,\n typing.Dict[str, typing.Any],\n typing.Sequence[typing.Union[str, typing.Dict[str, typing.Any]]],\n ]\n\nQueries the Agent with the given input and config.\n\n### set_up\n\n set_up()\n\nSets up the agent for execution of queries at runtime.\n\nIt initializes the model, connects it with the prompt template,\nretriever and response_synthesizer.\n\nThis method should not be called for an object that being passed to\nthe ReasoningEngine service for deployment, as it initializes clients\nthat can not be serialized."]]