Langchain Integrations

Agent Tools + Functions
Llama integration with Langchain agents.
pydantic model llama_index.langchain_helpers.agents.IndexToolConfig
   Configuration for LlamaIndex index tool.
      {
         "title": "IndexToolConfig",
         "description": "Configuration for LlamaIndex index tool.",
         "type": "object",
         "properties": {
            "query_engine": {
               "title": "Query Engine"
            },
            "name": {
               "title": "Name",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "tool_kwargs": {
               "title": "Tool Kwargs",
               "type": "object"
            }
         },
         "required": [
            "name",
            "description"
         ]
      }
   Config:
      * **arbitrary_types_allowed**: *bool = True*
   Fields:
      * "description (str)"
      * "name (str)"
      * "query_engine
        (llama_index.indices.query.base.BaseQueryEngine)"
      * "tool_kwargs (Dict)"
   field description: str [Required]
   field name: str [Required]
   field query_engine: BaseQueryEngine [Required]
   field tool_kwargs: Dict [Optional]
   classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) -> Model
      Creates a new model setting __dict__ and __fields_set__ from
      trusted or pre-validated data. Default values are respected, but
      no other validation is performed. Behaves as if *Config.extra =
      'allow'* was set since it adds all passed values
   copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) -> Model
      Duplicate a model, optionally choose which fields to include,
      exclude and change.
      Parameters:
         * **include** -- fields to include in new model
         * **exclude** -- fields to exclude from new model, as with
           values this takes precedence over include
         * **update** -- values to change/add in the new model. Note:
           the data is not validated before creating the new model:
           you should trust this data
         * **deep** -- set to *True* to make a deep copy of the model
      Returns:
         new model instance
   dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) -> DictStrAny
      Generate a dictionary representation of the model, optionally
      specifying which fields to include or exclude.
   classmethod from_orm(obj: Any) -> Model
   json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) -> unicode
      Generate a JSON representation of the model, *include* and
      *exclude* arguments as per *dict()*.
      *encoder* is an optional function to supply as *default* to

Langchain Integrations

      json.dumps(), other arguments as per *json.dumps()*.
   classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod parse_obj(obj: Any) -> Model
   classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') -> DictStrAny
   classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) -> unicode
   classmethod update_forward_refs(**localns: Any) -> None
      Try to update ForwardRefs on fields based on this Model,
      globalns and localns.
   classmethod validate(value: Any) -> Model
pydantic model llama_index.langchain_helpers.agents.LlamaIndexTool
   Tool for querying a LlamaIndex.
      {
         "title": "LlamaIndexTool",
         "description": "Tool for querying a LlamaIndex.",
         "type": "object",
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "description": {
               "title": "Description",
               "type": "string"
            },
            "args_schema": {
               "title": "Args Schema"
            },
            "return_direct": {
               "title": "Return Direct",
               "default": false,
               "type": "boolean"
            },
            "verbose": {
               "title": "Verbose",
               "default": false,
               "type": "boolean"
            },
            "callbacks": {
               "title": "Callbacks"
            },
            "callback_manager": {
               "title": "Callback Manager"
            },
            "tags": {
               "title": "Tags",
               "type": "array",
               "items": {
                  "type": "string"
               }
            },
            "metadata": {
               "title": "Metadata",
               "type": "object"
            },
            "query_engine": {
               "title": "Query Engine"
            },
            "return_sources": {
               "title": "Return Sources",
               "default": false,
               "type": "boolean"
            }
         },
         "required": [
            "name",
            "description"
         ]
      }
   Config:
      * **arbitrary_types_allowed**: *bool = True*
      * **extra**: *str = ignore*
   Fields:
      * "args_schema (Optional[Type[pydantic.main.BaseModel]])"
      * "callback_manager
        (Optional[langchain.callbacks.base.BaseCallbackManager])"
      * "callbacks (Optional[Union[List[langchain.callbacks.base.Base
        CallbackHandler],
        langchain.callbacks.base.BaseCallbackManager]])"
      * "description (str)"
      * "handle_tool_error (Optional[Union[bool, str,
        Callable[[langchain.tools.base.ToolException], str]]])"
      * "metadata (Optional[Dict[str, Any]])"
      * "name (str)"
      * "query_engine
        (llama_index.indices.query.base.BaseQueryEngine)"
      * "return_direct (bool)"
      * "return_sources (bool)"
      * "tags (Optional[List[str]])"
      * "verbose (bool)"
   field args_schema: Optional[Type[BaseModel]] = None
      Pydantic model class to validate and parse the tool's input
      arguments.
      Validated by:
         * "raise_deprecation"
   field callback_manager: Optional[BaseCallbackManager] = None

Langchain Integrations

      Deprecated. Please use callbacks instead.
      Validated by:
         * "raise_deprecation"
   field callbacks: Callbacks = None
      Callbacks to be called during tool execution.
      Validated by:
         * "raise_deprecation"
   field description: str [Required]
      Used to tell the model how/when/why to use the tool.
      You can provide few-shot examples as a part of the description.
      Validated by:
         * "raise_deprecation"
   field handle_tool_error: Optional[Union[bool, str, Callable[[ToolException], str]]] = False
      Handle the content of the ToolException thrown.
      Validated by:
         * "raise_deprecation"
   field metadata: Optional[Dict[str, Any]] = None
      Optional metadata associated with the tool. Defaults to None
      This metadata will be associated with each call to this tool,
      and passed as arguments to the handlers defined in *callbacks*.
      You can use these to eg identify a specific instance of a tool
      with its use case.
      Validated by:
         * "raise_deprecation"
   field name: str [Required]
      The unique name of the tool that clearly communicates its
      purpose.
      Validated by:
         * "raise_deprecation"
   field query_engine: BaseQueryEngine [Required]
      Validated by:
         * "raise_deprecation"
   field return_direct: bool = False
      Whether to return the tool's output directly. Setting this to
      True means
      that after the tool is called, the AgentExecutor will stop
      looping.
      Validated by:
         * "raise_deprecation"
   field return_sources: bool = False
      Validated by:
         * "raise_deprecation"
   field tags: Optional[List[str]] = None
      Optional list of tags associated with the tool. Defaults to None
      These tags will be associated with each call to this tool, and
      passed as arguments to the handlers defined in *callbacks*. You
      can use these to eg identify a specific instance of a tool with
      its use case.
      Validated by:
         * "raise_deprecation"
   field verbose: bool = False
      Whether to log the tool's progress.
      Validated by:
         * "raise_deprecation"
   async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) -> List[Output]
      Default implementation of abatch, which calls ainvoke N times.
      Subclasses should override this method if they can batch more
      efficiently.
   async ainvoke(input: Union[str, Dict], config: Optional[RunnableConfig] = None, **kwargs: Any) -> Any
      Default implementation of ainvoke, which calls invoke in a
      thread pool. Subclasses should override this method if they can
      run asynchronously.
   async arun(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwargs: Any) -> Any
      Run the tool asynchronously.
   async astream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) -> AsyncIterator[Output]
      Default implementation of astream, which calls ainvoke.
      Subclasses should override this method if they support streaming
      output.
   async astream_log(input: Any, config: Optional[RunnableConfig] = None, *, diff: bool = True, include_names: Optional[Sequence[str]] = None, include_types: Optional[Sequence[str]] = None, include_tags: Optional[Sequence[str]] = None, exclude_names: Optional[Sequence[str]] = None, exclude_types: Optional[Sequence[str]] = None, exclude_tags: Optional[Sequence[str]] = None, **kwargs: Optional[Any]) -> Union[AsyncIterator[RunLogPatch], AsyncIterator[RunLog]]

Langchain Integrations

      Stream all output from a runnable, as reported to the callback
      system. This includes all inner runs of LLMs, Retrievers, Tools,
      etc.
      Output is streamed as Log objects, which include a list of
      jsonpatch ops that describe how the state of the run has changed
      in each step, and the final state of the run.
      The jsonpatch ops can be applied in order to construct state.
   async atransform(input: AsyncIterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) -> AsyncIterator[Output]
      Default implementation of atransform, which buffers input and
      calls astream. Subclasses should override this method if they
      can start producing output while input is still being generated.
   batch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) -> List[Output]
      Default implementation of batch, which calls invoke N times.
      Subclasses should override this method if they can batch more
      efficiently.
   bind(**kwargs: Any) -> Runnable[Input, Output]
      Bind arguments to a Runnable, returning a new Runnable.
   config_schema(*, include: Sequence[str]) -> Type[BaseModel]
      The type of config this runnable accepts specified as a pydantic
      model.
      To mark a field as configurable, see the *configurable_fields*
      and *configurable_alternatives* methods.
      Parameters:
         **include** -- A list of fields to include in the config
         schema.
      Returns:
         A pydantic model that can be used to validate config.
   configurable_alternatives(which: ConfigurableField, **kwargs: Runnable[Input, Output]) -> RunnableSerializable[Input, Output]
   configurable_fields(**kwargs: ConfigurableField) -> RunnableSerializable[Input, Output]
   classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) -> Model
      Creates a new model setting __dict__ and __fields_set__ from
      trusted or pre-validated data. Default values are respected, but
      no other validation is performed. Behaves as if *Config.extra =
      'allow'* was set since it adds all passed values
   copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) -> Model
      Duplicate a model, optionally choose which fields to include,
      exclude and change.
      Parameters:
         * **include** -- fields to include in new model
         * **exclude** -- fields to exclude from new model, as with
           values this takes precedence over include
         * **update** -- values to change/add in the new model. Note:
           the data is not validated before creating the new model:
           you should trust this data
         * **deep** -- set to *True* to make a deep copy of the model
      Returns:
         new model instance
   dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) -> DictStrAny
      Generate a dictionary representation of the model, optionally
      specifying which fields to include or exclude.
   classmethod from_orm(obj: Any) -> Model
   classmethod from_tool_config(tool_config: IndexToolConfig) -> LlamaIndexTool

Langchain Integrations

      Create a tool from a tool config.
   classmethod get_lc_namespace() -> List[str]
      Get the namespace of the langchain object.
      For example, if the class is *langchain.llms.openai.OpenAI*,
      then the namespace is ["langchain", "llms", "openai"]
   invoke(input: Union[str, Dict], config: Optional[RunnableConfig] = None, **kwargs: Any) -> Any
      Transform a single input into an output. Override to implement.
   classmethod is_lc_serializable() -> bool
      Is this class serializable?
   json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) -> unicode
      Generate a JSON representation of the model, *include* and
      *exclude* arguments as per *dict()*.
      *encoder* is an optional function to supply as *default* to
      json.dumps(), other arguments as per *json.dumps()*.
   classmethod lc_id() -> List[str]
      A unique identifier for this class for serialization purposes.
      The unique identifier is a list of strings that describes the
      path to the object.
   map() -> Runnable[List[Input], List[Output]]
      Return a new Runnable that maps a list of inputs to a list of
      outputs, by calling invoke() with each input.
   classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod parse_obj(obj: Any) -> Model
   classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   validator raise_deprecation  »  *all fields*
      Raise deprecation warning if callback_manager is used.
   run(tool_input: Union[str, Dict], verbose: Optional[bool] = None, start_color: Optional[str] = 'green', color: Optional[str] = 'green', callbacks: Optional[Union[List[BaseCallbackHandler], BaseCallbackManager]] = None, *, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, run_name: Optional[str] = None, **kwargs: Any) -> Any
      Run the tool.
   classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') -> DictStrAny
   classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) -> unicode
   stream(input: Input, config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) -> Iterator[Output]
      Default implementation of stream, which calls invoke. Subclasses
      should override this method if they support streaming output.
   to_json() -> Union[SerializedConstructor, SerializedNotImplemented]
   to_json_not_implemented() -> SerializedNotImplemented
   transform(input: Iterator[Input], config: Optional[RunnableConfig] = None, **kwargs: Optional[Any]) -> Iterator[Output]
      Default implementation of transform, which buffers input and
      then calls stream. Subclasses should override this method if
      they can start producing output while input is still being
      generated.
   classmethod update_forward_refs(**localns: Any) -> None

Langchain Integrations

      Try to update ForwardRefs on fields based on this Model,
      globalns and localns.
   classmethod validate(value: Any) -> Model
   with_config(config: Optional[RunnableConfig] = None, **kwargs: Any) -> Runnable[Input, Output]
      Bind config to a Runnable, returning a new Runnable.
   with_fallbacks(fallbacks: Sequence[Runnable[Input, Output]], *, exceptions_to_handle: Tuple[Type[BaseException], ...] = (<class 'Exception'>,)) -> RunnableWithFallbacksT[Input, Output]
   with_retry(*, retry_if_exception_type: ~typing.Tuple[~typing.Type[BaseException], ...] = (<class 'Exception'>,), wait_exponential_jitter: bool = True, stop_after_attempt: int = 3) -> Runnable[Input, Output]
   property InputType: Type[Input]
      The type of input this runnable accepts specified as a type
      annotation.
   property OutputType: Type[Output]
      The type of output this runnable produces specified as a type
      annotation.
   property args: dict
   property config_specs: Sequence[ConfigurableFieldSpec]
      List configurable fields for this runnable.
   property input_schema: Type[BaseModel]
      The tool's input schema.
   property is_single_input: bool
      Whether the tool only accepts a single input.
   property lc_attributes: Dict
      List of attribute names that should be included in the
      serialized kwargs.
      These attributes must be accepted by the constructor.
   property lc_secrets: Dict[str, str]
      A map of constructor argument names to secret ids.
      For example,
         {"openai_api_key": "OPENAI_API_KEY"}
   property output_schema: Type[BaseModel]
      The type of output this runnable produces specified as a
      pydantic model.
pydantic model llama_index.langchain_helpers.agents.LlamaToolkit
   Toolkit for interacting with Llama indices.
      {
         "title": "LlamaToolkit",
         "description": "Toolkit for interacting with Llama indices.",
         "type": "object",
         "properties": {
            "index_configs": {
               "title": "Index Configs"
            }
         }
      }
   Config:
      * **arbitrary_types_allowed**: *bool = True*
   Fields:
      * "index_configs (List[llama_index.langchain_helpers.agents.too
        ls.IndexToolConfig])"
   field index_configs: List[IndexToolConfig] [Optional]
   classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) -> Model
      Creates a new model setting __dict__ and __fields_set__ from
      trusted or pre-validated data. Default values are respected, but
      no other validation is performed. Behaves as if *Config.extra =
      'allow'* was set since it adds all passed values
   copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) -> Model
      Duplicate a model, optionally choose which fields to include,
      exclude and change.
      Parameters:
         * **include** -- fields to include in new model
         * **exclude** -- fields to exclude from new model, as with
           values this takes precedence over include
         * **update** -- values to change/add in the new model. Note:
           the data is not validated before creating the new model:
           you should trust this data
         * **deep** -- set to *True* to make a deep copy of the model
      Returns:
         new model instance
   dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) -> DictStrAny

Langchain Integrations

      Generate a dictionary representation of the model, optionally
      specifying which fields to include or exclude.
   classmethod from_orm(obj: Any) -> Model
   get_tools() -> List[BaseTool]
      Get the tools in the toolkit.
   json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) -> unicode
      Generate a JSON representation of the model, *include* and
      *exclude* arguments as per *dict()*.
      *encoder* is an optional function to supply as *default* to
      json.dumps(), other arguments as per *json.dumps()*.
   classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod parse_obj(obj: Any) -> Model
   classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') -> DictStrAny
   classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) -> unicode
   classmethod update_forward_refs(**localns: Any) -> None
      Try to update ForwardRefs on fields based on this Model,
      globalns and localns.
   classmethod validate(value: Any) -> Model
llama_index.langchain_helpers.agents.create_llama_agent(toolkit: LlamaToolkit, llm: BaseLLM, agent: Optional[AgentType] = None, callback_manager: Optional[BaseCallbackManager] = None, agent_path: Optional[str] = None, agent_kwargs: Optional[dict] = None, **kwargs: Any) -> AgentExecutor
   Load an agent executor given a Llama Toolkit and LLM.
   NOTE: this is a light wrapper around initialize_agent in langchain.
   Parameters:
      * **toolkit** -- LlamaToolkit to use.
      * **llm** -- Language model to use as the agent.
      * **agent** --
        A string that specified the agent type to use. Valid options
        are:
           *zero-shot-react-description* *react-docstore* *self-ask-
           with-search* *conversational-react-description* *chat-zero-
           shot-react-description*, *chat-conversational-react-
           description*,
        If None and agent_path is also None, will default to
           *zero-shot-react-description*.
      * **callback_manager** -- CallbackManager to use. Global
        callback manager is used if not provided. Defaults to None.
      * **agent_path** -- Path to serialized agent to use.
      * **agent_kwargs** -- Additional key word arguments to pass to
        the underlying agent
      * ****kwargs** -- Additional key word arguments passed to the
        agent executor
   Returns:
      An agent executor
llama_index.langchain_helpers.agents.create_llama_chat_agent(toolkit: LlamaToolkit, llm: BaseLLM, callback_manager: Optional[BaseCallbackManager] = None, agent_kwargs: Optional[dict] = None, **kwargs: Any) -> AgentExecutor
   Load a chat llama agent given a Llama Toolkit and LLM.

Langchain Integrations

   Parameters:
      * **toolkit** -- LlamaToolkit to use.
      * **llm** -- Language model to use as the agent.
      * **callback_manager** -- CallbackManager to use. Global
        callback manager is used if not provided. Defaults to None.
      * **agent_kwargs** -- Additional key word arguments to pass to
        the underlying agent
      * ****kwargs** -- Additional key word arguments passed to the
        agent executor
   Returns:
      An agent executor
Memory Module
Langchain memory wrapper (for LlamaIndex).
pydantic model llama_index.langchain_helpers.memory_wrapper.GPTIndexChatMemory
   Langchain chat memory wrapper (for LlamaIndex).
   Parameters:
      * **human_prefix** (*str*) -- Prefix for human input. Defaults
        to "Human".
      * **ai_prefix** (*str*) -- Prefix for AI output. Defaults to
        "AI".
      * **memory_key** (*str*) -- Key for memory. Defaults to
        "history".
      * **index** (*BaseIndex*) -- LlamaIndex instance.
      * **query_kwargs** (*Dict**[**str**, **Any**]*) -- Keyword
        arguments for LlamaIndex query.
      * **input_key** (*Optional**[**str**]*) -- Input key. Defaults
        to None.
      * **output_key** (*Optional**[**str**]*) -- Output key. Defaults
        to None.
      {
         "title": "GPTIndexChatMemory",
         "description": "Langchain chat memory wrapper (for LlamaIndex).\n\nArgs:\n    human_prefix (str): Prefix for human input. Defaults to \"Human\".\n    ai_prefix (str): Prefix for AI output. Defaults to \"AI\".\n    memory_key (str): Key for memory. Defaults to \"history\".\n    index (BaseIndex): LlamaIndex instance.\n    query_kwargs (Dict[str, Any]): Keyword arguments for LlamaIndex query.\n    input_key (Optional[str]): Input key. Defaults to None.\n    output_key (Optional[str]): Output key. Defaults to None.",
         "type": "object",
         "properties": {
            "chat_memory": {
               "title": "Chat Memory"
            },
            "output_key": {
               "title": "Output Key",
               "type": "string"
            },
            "input_key": {
               "title": "Input Key",
               "type": "string"
            },
            "return_messages": {
               "title": "Return Messages",
               "default": false,
               "type": "boolean"
            },
            "human_prefix": {
               "title": "Human Prefix",
               "default": "Human",
               "type": "string"
            },
            "ai_prefix": {
               "title": "Ai Prefix",
               "default": "AI",
               "type": "string"
            },
            "memory_key": {
               "title": "Memory Key",
               "default": "history",
               "type": "string"
            },
            "index": {
               "title": "Index"
            },
            "query_kwargs": {
               "title": "Query Kwargs",
               "type": "object"
            },
            "return_source": {
               "title": "Return Source",
               "default": false,
               "type": "boolean"
            },
            "id_to_message": {
               "title": "Id To Message",
               "type": "object",
               "additionalProperties": {
                  "$ref": "#/definitions/BaseMessage"
               }
            }
         },
         "required": [
            "index"
         ],
         "definitions": {
            "BaseMessage": {
               "title": "BaseMessage",
               "description": "The base abstract Message class.\n\nMessages are the inputs and outputs of ChatModels.",

Langchain Integrations

               "type": "object",
               "properties": {
                  "content": {
                     "title": "Content",
                     "type": "string"
                  },
                  "additional_kwargs": {
                     "title": "Additional Kwargs",
                     "type": "object"
                  },
                  "type": {
                     "title": "Type",
                     "type": "string"
                  }
               },
               "required": [
                  "content",
                  "type"
               ]
            }
         }
      }
   Config:
      * **arbitrary_types_allowed**: *bool = True*
   Fields:
      * "ai_prefix (str)"
      * "chat_memory
        (langchain.schema.chat_history.BaseChatMessageHistory)"
      * "human_prefix (str)"
      * "id_to_message (Dict[str,
        langchain.schema.messages.BaseMessage])"
      * "index (llama_index.indices.base.BaseIndex)"
      * "input_key (Optional[str])"
      * "memory_key (str)"
      * "output_key (Optional[str])"
      * "query_kwargs (Dict)"
      * "return_messages (bool)"
      * "return_source (bool)"
   field ai_prefix: str = 'AI'
   field chat_memory: BaseChatMessageHistory [Optional]
   field human_prefix: str = 'Human'
   field id_to_message: Dict[str, BaseMessage] [Optional]
   field index: BaseIndex [Required]
   field input_key: Optional[str] = None
   field memory_key: str = 'history'
   field output_key: Optional[str] = None
   field query_kwargs: Dict [Optional]
   field return_messages: bool = False
   field return_source: bool = False
   clear() -> None
      Clear memory contents.
   classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) -> Model
      Creates a new model setting __dict__ and __fields_set__ from
      trusted or pre-validated data. Default values are respected, but
      no other validation is performed. Behaves as if *Config.extra =
      'allow'* was set since it adds all passed values
   copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) -> Model
      Duplicate a model, optionally choose which fields to include,
      exclude and change.
      Parameters:
         * **include** -- fields to include in new model
         * **exclude** -- fields to exclude from new model, as with
           values this takes precedence over include
         * **update** -- values to change/add in the new model. Note:
           the data is not validated before creating the new model:
           you should trust this data
         * **deep** -- set to *True* to make a deep copy of the model
      Returns:
         new model instance
   dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) -> DictStrAny
      Generate a dictionary representation of the model, optionally
      specifying which fields to include or exclude.
   classmethod from_orm(obj: Any) -> Model
   classmethod get_lc_namespace() -> List[str]
      Get the namespace of the langchain object.
      For example, if the class is *langchain.llms.openai.OpenAI*,
      then the namespace is ["langchain", "llms", "openai"]

Langchain Integrations

   classmethod is_lc_serializable() -> bool
      Is this class serializable?
   json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) -> unicode
      Generate a JSON representation of the model, *include* and
      *exclude* arguments as per *dict()*.
      *encoder* is an optional function to supply as *default* to
      json.dumps(), other arguments as per *json.dumps()*.
   classmethod lc_id() -> List[str]
      A unique identifier for this class for serialization purposes.
      The unique identifier is a list of strings that describes the
      path to the object.
   load_memory_variables(inputs: Dict[str, Any]) -> Dict[str, str]
      Return key-value pairs given the text input to the chain.
   classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod parse_obj(obj: Any) -> Model
   classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) -> None
      Save the context of this model run to memory.
   classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') -> DictStrAny
   classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) -> unicode
   to_json() -> Union[SerializedConstructor, SerializedNotImplemented]
   to_json_not_implemented() -> SerializedNotImplemented
   classmethod update_forward_refs(**localns: Any) -> None
      Try to update ForwardRefs on fields based on this Model,
      globalns and localns.
   classmethod validate(value: Any) -> Model
   property lc_attributes: Dict
      List of attribute names that should be included in the
      serialized kwargs.
      These attributes must be accepted by the constructor.
   property lc_secrets: Dict[str, str]
      A map of constructor argument names to secret ids.
      For example,
         {"openai_api_key": "OPENAI_API_KEY"}
   property memory_variables: List[str]
      Return memory variables.
pydantic model llama_index.langchain_helpers.memory_wrapper.GPTIndexMemory
   Langchain memory wrapper (for LlamaIndex).
   Parameters:
      * **human_prefix** (*str*) -- Prefix for human input. Defaults
        to "Human".
      * **ai_prefix** (*str*) -- Prefix for AI output. Defaults to
        "AI".
      * **memory_key** (*str*) -- Key for memory. Defaults to
        "history".
      * **index** (*BaseIndex*) -- LlamaIndex instance.
      * **query_kwargs** (*Dict**[**str**, **Any**]*) -- Keyword
        arguments for LlamaIndex query.
      * **input_key** (*Optional**[**str**]*) -- Input key. Defaults
        to None.
      * **output_key** (*Optional**[**str**]*) -- Output key. Defaults
        to None.
      {
         "title": "GPTIndexMemory",

Langchain Integrations

         "description": "Langchain memory wrapper (for LlamaIndex).\n\nArgs:\n    human_prefix (str): Prefix for human input. Defaults to \"Human\".\n    ai_prefix (str): Prefix for AI output. Defaults to \"AI\".\n    memory_key (str): Key for memory. Defaults to \"history\".\n    index (BaseIndex): LlamaIndex instance.\n    query_kwargs (Dict[str, Any]): Keyword arguments for LlamaIndex query.\n    input_key (Optional[str]): Input key. Defaults to None.\n    output_key (Optional[str]): Output key. Defaults to None.",
         "type": "object",
         "properties": {
            "human_prefix": {
               "title": "Human Prefix",
               "default": "Human",
               "type": "string"
            },
            "ai_prefix": {
               "title": "Ai Prefix",
               "default": "AI",
               "type": "string"
            },
            "memory_key": {
               "title": "Memory Key",
               "default": "history",
               "type": "string"
            },
            "index": {
               "title": "Index"
            },
            "query_kwargs": {
               "title": "Query Kwargs",
               "type": "object"
            },
            "output_key": {
               "title": "Output Key",
               "type": "string"
            },
            "input_key": {
               "title": "Input Key",
               "type": "string"
            }
         },
         "required": [
            "index"
         ]
      }
   Config:
      * **arbitrary_types_allowed**: *bool = True*
   Fields:
      * "ai_prefix (str)"
      * "human_prefix (str)"
      * "index (llama_index.indices.base.BaseIndex)"
      * "input_key (Optional[str])"
      * "memory_key (str)"
      * "output_key (Optional[str])"
      * "query_kwargs (Dict)"
   field ai_prefix: str = 'AI'
   field human_prefix: str = 'Human'
   field index: BaseIndex [Required]
   field input_key: Optional[str] = None
   field memory_key: str = 'history'
   field output_key: Optional[str] = None
   field query_kwargs: Dict [Optional]
   clear() -> None
      Clear memory contents.
   classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) -> Model
      Creates a new model setting __dict__ and __fields_set__ from
      trusted or pre-validated data. Default values are respected, but
      no other validation is performed. Behaves as if *Config.extra =
      'allow'* was set since it adds all passed values
   copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) -> Model
      Duplicate a model, optionally choose which fields to include,
      exclude and change.
      Parameters:
         * **include** -- fields to include in new model
         * **exclude** -- fields to exclude from new model, as with
           values this takes precedence over include
         * **update** -- values to change/add in the new model. Note:
           the data is not validated before creating the new model:
           you should trust this data
         * **deep** -- set to *True* to make a deep copy of the model
      Returns:
         new model instance
   dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) -> DictStrAny

Langchain Integrations

      Generate a dictionary representation of the model, optionally
      specifying which fields to include or exclude.
   classmethod from_orm(obj: Any) -> Model
   classmethod get_lc_namespace() -> List[str]
      Get the namespace of the langchain object.
      For example, if the class is *langchain.llms.openai.OpenAI*,
      then the namespace is ["langchain", "llms", "openai"]
   classmethod is_lc_serializable() -> bool
      Is this class serializable?
   json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) -> unicode
      Generate a JSON representation of the model, *include* and
      *exclude* arguments as per *dict()*.
      *encoder* is an optional function to supply as *default* to
      json.dumps(), other arguments as per *json.dumps()*.
   classmethod lc_id() -> List[str]
      A unique identifier for this class for serialization purposes.
      The unique identifier is a list of strings that describes the
      path to the object.
   load_memory_variables(inputs: Dict[str, Any]) -> Dict[str, str]
      Return key-value pairs given the text input to the chain.
   classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   classmethod parse_obj(obj: Any) -> Model
   classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) -> Model
   save_context(inputs: Dict[str, Any], outputs: Dict[str, str]) -> None
      Save the context of this model run to memory.
   classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') -> DictStrAny
   classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) -> unicode
   to_json() -> Union[SerializedConstructor, SerializedNotImplemented]
   to_json_not_implemented() -> SerializedNotImplemented
   classmethod update_forward_refs(**localns: Any) -> None
      Try to update ForwardRefs on fields based on this Model,
      globalns and localns.
   classmethod validate(value: Any) -> Model
   property lc_attributes: Dict
      List of attribute names that should be included in the
      serialized kwargs.
      These attributes must be accepted by the constructor.
   property lc_secrets: Dict[str, str]
      A map of constructor argument names to secret ids.
      For example,
         {"openai_api_key": "OPENAI_API_KEY"}
   property memory_variables: List[str]
      Return memory variables.
llama_index.langchain_helpers.memory_wrapper.get_prompt_input_key(inputs: Dict[str, Any], memory_variables: List[str]) -> str
   Get prompt input key.
   Copied over from langchain.


Index Store

class llama_index.storage.index_store.FirestoreKVStore(project: Optional[str] = None, database: str = '(default)')
   Firestore Key-Value store.
   Parameters:
      * **project** (*str*) -- The project which the client acts on
        behalf of.
      * **database** (*str*) -- The database name that the client
        targets.
   delete(key: str, collection: str = 'data') -> bool
      Delete a value from the Firestore.
      Parameters:
         * **key** (*str*) -- key
         * **collection** (*str*) -- collection name
   get(key: str, collection: str = 'data') -> Optional[dict]
      Get a key-value pair from the Firestore.
      Parameters:
         * **key** (*str*) -- key
         * **collection** (*str*) -- collection name
   get_all(collection: str = 'data') -> Dict[str, dict]
      Get all values from the Firestore collection.
      Parameters:
         **collection** (*str*) -- collection name
   put(key: str, val: dict, collection: str = 'data') -> None
      Put a key-value pair into the Firestore collection.
      Parameters:
         * **key** (*str*) -- key
         * **val** (*dict*) -- value
         * **collection** (*str*) -- collection name
class llama_index.storage.index_store.KVIndexStore(kvstore: BaseKVStore, namespace: Optional[str] = None)
   Key-Value Index store.
   Parameters:
      * **kvstore** (*BaseKVStore*) -- key-value store
      * **namespace** (*str*) -- namespace for the index store
   add_index_struct(index_struct: IndexStruct) -> None
      Add an index struct.
      Parameters:
         **index_struct** (*IndexStruct*) -- index struct
   delete_index_struct(key: str) -> None
      Delete an index struct.
      Parameters:
         **key** (*str*) -- index struct key
   get_index_struct(struct_id: Optional[str] = None) -> Optional[IndexStruct]
      Get an index struct.
      Parameters:
         **struct_id** (*Optional**[**str**]*) -- index struct id
   index_structs() -> List[IndexStruct]
      Get all index structs.
      Returns:
         index structs
      Return type:
         List[IndexStruct]
   persist(persist_path: str = './storage/index_store.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the index store to disk.
class llama_index.storage.index_store.MongoIndexStore(mongo_kvstore: MongoDBKVStore, namespace: Optional[str] = None)
   Mongo Index store.
   Parameters:
      * **mongo_kvstore** (*MongoDBKVStore*) -- MongoDB key-value
        store
      * **namespace** (*str*) -- namespace for the index store
   add_index_struct(index_struct: IndexStruct) -> None
      Add an index struct.
      Parameters:
         **index_struct** (*IndexStruct*) -- index struct
   delete_index_struct(key: str) -> None
      Delete an index struct.
      Parameters:
         **key** (*str*) -- index struct key
   classmethod from_host_and_port(host: str, port: int, db_name: Optional[str] = None, namespace: Optional[str] = None) -> MongoIndexStore
      Load a MongoIndexStore from a MongoDB host and port.
   classmethod from_uri(uri: str, db_name: Optional[str] = None, namespace: Optional[str] = None) -> MongoIndexStore
      Load a MongoIndexStore from a MongoDB URI.
   get_index_struct(struct_id: Optional[str] = None) -> Optional[IndexStruct]
      Get an index struct.
      Parameters:
         **struct_id** (*Optional**[**str**]*) -- index struct id

Index Store

   index_structs() -> List[IndexStruct]
      Get all index structs.
      Returns:
         index structs
      Return type:
         List[IndexStruct]
   persist(persist_path: str = './storage/index_store.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the index store to disk.
class llama_index.storage.index_store.RedisIndexStore(redis_kvstore: RedisKVStore, namespace: Optional[str] = None)
   Redis Index store.
   Parameters:
      * **redis_kvstore** (*RedisKVStore*) -- Redis key-value store
      * **namespace** (*str*) -- namespace for the index store
   add_index_struct(index_struct: IndexStruct) -> None
      Add an index struct.
      Parameters:
         **index_struct** (*IndexStruct*) -- index struct
   delete_index_struct(key: str) -> None
      Delete an index struct.
      Parameters:
         **key** (*str*) -- index struct key
   classmethod from_host_and_port(host: str, port: int, namespace: Optional[str] = None) -> RedisIndexStore
      Load a RedisIndexStore from a Redis host and port.
   classmethod from_redis_client(redis_client: Any, namespace: Optional[str] = None) -> RedisIndexStore
      Load a RedisIndexStore from a Redis Client.
   get_index_struct(struct_id: Optional[str] = None) -> Optional[IndexStruct]
      Get an index struct.
      Parameters:
         **struct_id** (*Optional**[**str**]*) -- index struct id
   index_structs() -> List[IndexStruct]
      Get all index structs.
      Returns:
         index structs
      Return type:
         List[IndexStruct]
   persist(persist_path: str = './storage/index_store.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the index store to disk.
class llama_index.storage.index_store.SimpleIndexStore(simple_kvstore: Optional[SimpleKVStore] = None)
   Simple in-memory Index store.
   Parameters:
      **simple_kvstore** (*SimpleKVStore*) -- simple key-value store
   add_index_struct(index_struct: IndexStruct) -> None
      Add an index struct.
      Parameters:
         **index_struct** (*IndexStruct*) -- index struct
   delete_index_struct(key: str) -> None
      Delete an index struct.
      Parameters:
         **key** (*str*) -- index struct key
   classmethod from_persist_dir(persist_dir: str = './storage', fs: Optional[AbstractFileSystem] = None) -> SimpleIndexStore
      Create a SimpleIndexStore from a persist directory.
   classmethod from_persist_path(persist_path: str, fs: Optional[AbstractFileSystem] = None) -> SimpleIndexStore
      Create a SimpleIndexStore from a persist path.
   get_index_struct(struct_id: Optional[str] = None) -> Optional[IndexStruct]
      Get an index struct.
      Parameters:
         **struct_id** (*Optional**[**str**]*) -- index struct id
   index_structs() -> List[IndexStruct]
      Get all index structs.
      Returns:
         index structs
      Return type:
         List[IndexStruct]
   persist(persist_path: str = './storage/index_store.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the store.


Document Store

class llama_index.storage.docstore.BaseDocumentStore
   abstract delete_document(doc_id: str, raise_error: bool = True) -> None
      Delete a document from the store.
   abstract delete_ref_doc(ref_doc_id: str, raise_error: bool = True) -> None
      Delete a ref_doc and all it's associated nodes.
   abstract get_all_ref_doc_info() -> Optional[Dict[str, RefDocInfo]]
      Get a mapping of ref_doc_id -> RefDocInfo for all ingested
      documents.
   get_node(node_id: str, raise_error: bool = True) -> BaseNode
      Get node from docstore.
      Parameters:
         * **node_id** (*str*) -- node id
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_node_dict(node_id_dict: Dict[int, str]) -> Dict[int, BaseNode]
      Get node dict from docstore given a mapping of index to node
      ids.
      Parameters:
         **node_id_dict** (*Dict**[**int**, **str**]*) -- mapping of
         index to node ids
   get_nodes(node_ids: List[str], raise_error: bool = True) -> List[BaseNode]
      Get nodes from docstore.
      Parameters:
         * **node_ids** (*List**[**str**]*) -- node ids
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   abstract get_ref_doc_info(ref_doc_id: str) -> Optional[RefDocInfo]
      Get the RefDocInfo for a given ref_doc_id.
   persist(persist_path: str = './storage/docstore.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the docstore to a file.
llama_index.storage.docstore.DocumentStore
   alias of "SimpleDocumentStore"
class llama_index.storage.docstore.FirestoreDocumentStore(firestore_kvstore: FirestoreKVStore, namespace: Optional[str] = None)
   Firestore Document (Node) store.
   A Firestore store for Document and Node objects.
   Parameters:
      * **firestore_kvstore** (*FirestoreKVStore*) -- Firestore key-
        value store
      * **namespace** (*str*) -- namespace for the docstore
   add_documents(nodes: Sequence[BaseNode], allow_update: bool = True) -> None
      Add a document to the store.
      Parameters:
         * **docs** (*List**[**BaseDocument**]*) -- documents
         * **allow_update** (*bool*) -- allow update of docstore from
           document
   delete_document(doc_id: str, raise_error: bool = True, remove_ref_doc_node: bool = True) -> None
      Delete a document from the store.
   delete_ref_doc(ref_doc_id: str, raise_error: bool = True) -> None
      Delete a ref_doc and all it's associated nodes.
   property docs: Dict[str, BaseNode]
      Get all documents.
      Returns:
         documents
      Return type:
         Dict[str, BaseDocument]
   document_exists(doc_id: str) -> bool
      Check if document exists.
   classmethod from_database(project: str, database: str, namespace: Optional[str] = None) -> FirestoreDocumentStore
      Parameters:
         * **project** (*str*) -- The project which the client acts on
           behalf of.
         * **database** (*str*) -- The database name that the client
           targets.
         * **namespace** (*str*) -- namespace for the docstore.
   get_all_ref_doc_info() -> Optional[Dict[str, RefDocInfo]]
      Get a mapping of ref_doc_id -> RefDocInfo for all ingested
      documents.
   get_document(doc_id: str, raise_error: bool = True) -> Optional[BaseNode]

Document Store

      Get a document from the store.
      Parameters:
         * **doc_id** (*str*) -- document id
         * **raise_error** (*bool*) -- raise error if doc_id not found
   get_document_hash(doc_id: str) -> Optional[str]
      Get the stored hash for a document, if it exists.
   get_node(node_id: str, raise_error: bool = True) -> BaseNode
      Get node from docstore.
      Parameters:
         * **node_id** (*str*) -- node id
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_node_dict(node_id_dict: Dict[int, str]) -> Dict[int, BaseNode]
      Get node dict from docstore given a mapping of index to node
      ids.
      Parameters:
         **node_id_dict** (*Dict**[**int**, **str**]*) -- mapping of
         index to node ids
   get_nodes(node_ids: List[str], raise_error: bool = True) -> List[BaseNode]
      Get nodes from docstore.
      Parameters:
         * **node_ids** (*List**[**str**]*) -- node ids
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_ref_doc_info(ref_doc_id: str) -> Optional[RefDocInfo]
      Get the RefDocInfo for a given ref_doc_id.
   persist(persist_path: str = './storage/docstore.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the docstore to a file.
   ref_doc_exists(ref_doc_id: str) -> bool
      Check if a ref_doc_id has been ingested.
   set_document_hash(doc_id: str, doc_hash: str) -> None
      Set the hash for a given doc_id.
class llama_index.storage.docstore.KVDocumentStore(kvstore: BaseKVStore, namespace: Optional[str] = None)
   Document (Node) store.
   NOTE: at the moment, this store is primarily used to store Node
   objects. Each node will be assigned an ID.
   The same docstore can be reused across index structures. This
   allows you to reuse the same storage for multiple index structures;
   otherwise, each index would create a docstore under the hood.
   This will use the same docstore for multiple index structures.
   Parameters:
      * **kvstore** (*BaseKVStore*) -- key-value store
      * **namespace** (*str*) -- namespace for the docstore
   add_documents(nodes: Sequence[BaseNode], allow_update: bool = True) -> None
      Add a document to the store.
      Parameters:
         * **docs** (*List**[**BaseDocument**]*) -- documents
         * **allow_update** (*bool*) -- allow update of docstore from
           document
   delete_document(doc_id: str, raise_error: bool = True, remove_ref_doc_node: bool = True) -> None
      Delete a document from the store.
   delete_ref_doc(ref_doc_id: str, raise_error: bool = True) -> None
      Delete a ref_doc and all it's associated nodes.
   property docs: Dict[str, BaseNode]
      Get all documents.
      Returns:
         documents
      Return type:
         Dict[str, BaseDocument]
   document_exists(doc_id: str) -> bool
      Check if document exists.
   get_all_ref_doc_info() -> Optional[Dict[str, RefDocInfo]]
      Get a mapping of ref_doc_id -> RefDocInfo for all ingested
      documents.
   get_document(doc_id: str, raise_error: bool = True) -> Optional[BaseNode]
      Get a document from the store.
      Parameters:
         * **doc_id** (*str*) -- document id
         * **raise_error** (*bool*) -- raise error if doc_id not found

Document Store

   get_document_hash(doc_id: str) -> Optional[str]
      Get the stored hash for a document, if it exists.
   get_node(node_id: str, raise_error: bool = True) -> BaseNode
      Get node from docstore.
      Parameters:
         * **node_id** (*str*) -- node id
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_node_dict(node_id_dict: Dict[int, str]) -> Dict[int, BaseNode]
      Get node dict from docstore given a mapping of index to node
      ids.
      Parameters:
         **node_id_dict** (*Dict**[**int**, **str**]*) -- mapping of
         index to node ids
   get_nodes(node_ids: List[str], raise_error: bool = True) -> List[BaseNode]
      Get nodes from docstore.
      Parameters:
         * **node_ids** (*List**[**str**]*) -- node ids
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_ref_doc_info(ref_doc_id: str) -> Optional[RefDocInfo]
      Get the RefDocInfo for a given ref_doc_id.
   persist(persist_path: str = './storage/docstore.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the docstore to a file.
   ref_doc_exists(ref_doc_id: str) -> bool
      Check if a ref_doc_id has been ingested.
   set_document_hash(doc_id: str, doc_hash: str) -> None
      Set the hash for a given doc_id.
class llama_index.storage.docstore.MongoDocumentStore(mongo_kvstore: MongoDBKVStore, namespace: Optional[str] = None)
   Mongo Document (Node) store.
   A MongoDB store for Document and Node objects.
   Parameters:
      * **mongo_kvstore** (*MongoDBKVStore*) -- MongoDB key-value
        store
      * **namespace** (*str*) -- namespace for the docstore
   add_documents(nodes: Sequence[BaseNode], allow_update: bool = True) -> None
      Add a document to the store.
      Parameters:
         * **docs** (*List**[**BaseDocument**]*) -- documents
         * **allow_update** (*bool*) -- allow update of docstore from
           document
   delete_document(doc_id: str, raise_error: bool = True, remove_ref_doc_node: bool = True) -> None
      Delete a document from the store.
   delete_ref_doc(ref_doc_id: str, raise_error: bool = True) -> None
      Delete a ref_doc and all it's associated nodes.
   property docs: Dict[str, BaseNode]
      Get all documents.
      Returns:
         documents
      Return type:
         Dict[str, BaseDocument]
   document_exists(doc_id: str) -> bool
      Check if document exists.
   classmethod from_host_and_port(host: str, port: int, db_name: Optional[str] = None, namespace: Optional[str] = None) -> MongoDocumentStore
      Load a MongoDocumentStore from a MongoDB host and port.
   classmethod from_uri(uri: str, db_name: Optional[str] = None, namespace: Optional[str] = None) -> MongoDocumentStore
      Load a MongoDocumentStore from a MongoDB URI.
   get_all_ref_doc_info() -> Optional[Dict[str, RefDocInfo]]
      Get a mapping of ref_doc_id -> RefDocInfo for all ingested
      documents.
   get_document(doc_id: str, raise_error: bool = True) -> Optional[BaseNode]
      Get a document from the store.
      Parameters:
         * **doc_id** (*str*) -- document id
         * **raise_error** (*bool*) -- raise error if doc_id not found

Document Store

   get_document_hash(doc_id: str) -> Optional[str]
      Get the stored hash for a document, if it exists.
   get_node(node_id: str, raise_error: bool = True) -> BaseNode
      Get node from docstore.
      Parameters:
         * **node_id** (*str*) -- node id
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_node_dict(node_id_dict: Dict[int, str]) -> Dict[int, BaseNode]
      Get node dict from docstore given a mapping of index to node
      ids.
      Parameters:
         **node_id_dict** (*Dict**[**int**, **str**]*) -- mapping of
         index to node ids
   get_nodes(node_ids: List[str], raise_error: bool = True) -> List[BaseNode]
      Get nodes from docstore.
      Parameters:
         * **node_ids** (*List**[**str**]*) -- node ids
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_ref_doc_info(ref_doc_id: str) -> Optional[RefDocInfo]
      Get the RefDocInfo for a given ref_doc_id.
   persist(persist_path: str = './storage/docstore.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the docstore to a file.
   ref_doc_exists(ref_doc_id: str) -> bool
      Check if a ref_doc_id has been ingested.
   set_document_hash(doc_id: str, doc_hash: str) -> None
      Set the hash for a given doc_id.
class llama_index.storage.docstore.RedisDocumentStore(redis_kvstore: RedisKVStore, namespace: Optional[str] = None)
   Redis Document (Node) store.
   A Redis store for Document and Node objects.
   Parameters:
      * **redis_kvstore** (*RedisKVStore*) -- Redis key-value store
      * **namespace** (*str*) -- namespace for the docstore
   add_documents(nodes: Sequence[BaseNode], allow_update: bool = True) -> None
      Add a document to the store.
      Parameters:
         * **docs** (*List**[**BaseDocument**]*) -- documents
         * **allow_update** (*bool*) -- allow update of docstore from
           document
   delete_document(doc_id: str, raise_error: bool = True, remove_ref_doc_node: bool = True) -> None
      Delete a document from the store.
   delete_ref_doc(ref_doc_id: str, raise_error: bool = True) -> None
      Delete a ref_doc and all it's associated nodes.
   property docs: Dict[str, BaseNode]
      Get all documents.
      Returns:
         documents
      Return type:
         Dict[str, BaseDocument]
   document_exists(doc_id: str) -> bool
      Check if document exists.
   classmethod from_host_and_port(host: str, port: int, namespace: Optional[str] = None) -> RedisDocumentStore
      Load a RedisDocumentStore from a Redis host and port.
   classmethod from_redis_client(redis_client: Any, namespace: Optional[str] = None) -> RedisDocumentStore
      Load a RedisDocumentStore from a Redis Client.
   get_all_ref_doc_info() -> Optional[Dict[str, RefDocInfo]]
      Get a mapping of ref_doc_id -> RefDocInfo for all ingested
      documents.
   get_document(doc_id: str, raise_error: bool = True) -> Optional[BaseNode]
      Get a document from the store.
      Parameters:
         * **doc_id** (*str*) -- document id
         * **raise_error** (*bool*) -- raise error if doc_id not found
   get_document_hash(doc_id: str) -> Optional[str]
      Get the stored hash for a document, if it exists.

Document Store

   get_node(node_id: str, raise_error: bool = True) -> BaseNode
      Get node from docstore.
      Parameters:
         * **node_id** (*str*) -- node id
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_node_dict(node_id_dict: Dict[int, str]) -> Dict[int, BaseNode]
      Get node dict from docstore given a mapping of index to node
      ids.
      Parameters:
         **node_id_dict** (*Dict**[**int**, **str**]*) -- mapping of
         index to node ids
   get_nodes(node_ids: List[str], raise_error: bool = True) -> List[BaseNode]
      Get nodes from docstore.
      Parameters:
         * **node_ids** (*List**[**str**]*) -- node ids
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_ref_doc_info(ref_doc_id: str) -> Optional[RefDocInfo]
      Get the RefDocInfo for a given ref_doc_id.
   persist(persist_path: str = './storage/docstore.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the docstore to a file.
   ref_doc_exists(ref_doc_id: str) -> bool
      Check if a ref_doc_id has been ingested.
   set_document_hash(doc_id: str, doc_hash: str) -> None
      Set the hash for a given doc_id.
class llama_index.storage.docstore.SimpleDocumentStore(simple_kvstore: Optional[SimpleKVStore] = None, namespace: Optional[str] = None)
   Simple Document (Node) store.
   An in-memory store for Document and Node objects.
   Parameters:
      * **simple_kvstore** (*SimpleKVStore*) -- simple key-value store
      * **namespace** (*str*) -- namespace for the docstore
   add_documents(nodes: Sequence[BaseNode], allow_update: bool = True) -> None
      Add a document to the store.
      Parameters:
         * **docs** (*List**[**BaseDocument**]*) -- documents
         * **allow_update** (*bool*) -- allow update of docstore from
           document
   delete_document(doc_id: str, raise_error: bool = True, remove_ref_doc_node: bool = True) -> None
      Delete a document from the store.
   delete_ref_doc(ref_doc_id: str, raise_error: bool = True) -> None
      Delete a ref_doc and all it's associated nodes.
   property docs: Dict[str, BaseNode]
      Get all documents.
      Returns:
         documents
      Return type:
         Dict[str, BaseDocument]
   document_exists(doc_id: str) -> bool
      Check if document exists.
   classmethod from_persist_dir(persist_dir: str = './storage', namespace: Optional[str] = None, fs: Optional[AbstractFileSystem] = None) -> SimpleDocumentStore
      Create a SimpleDocumentStore from a persist directory.
      Parameters:
         * **persist_dir** (*str*) -- directory to persist the store
         * **namespace** (*Optional**[**str**]*) -- namespace for the
           docstore
         * **fs** (*Optional**[**fsspec.AbstractFileSystem**]*) --
           filesystem to use
   classmethod from_persist_path(persist_path: str, namespace: Optional[str] = None, fs: Optional[AbstractFileSystem] = None) -> SimpleDocumentStore
      Create a SimpleDocumentStore from a persist path.
      Parameters:
         * **persist_path** (*str*) -- Path to persist the store
         * **namespace** (*Optional**[**str**]*) -- namespace for the
           docstore
         * **fs** (*Optional**[**fsspec.AbstractFileSystem**]*) --

Document Store

           filesystem to use
   get_all_ref_doc_info() -> Optional[Dict[str, RefDocInfo]]
      Get a mapping of ref_doc_id -> RefDocInfo for all ingested
      documents.
   get_document(doc_id: str, raise_error: bool = True) -> Optional[BaseNode]
      Get a document from the store.
      Parameters:
         * **doc_id** (*str*) -- document id
         * **raise_error** (*bool*) -- raise error if doc_id not found
   get_document_hash(doc_id: str) -> Optional[str]
      Get the stored hash for a document, if it exists.
   get_node(node_id: str, raise_error: bool = True) -> BaseNode
      Get node from docstore.
      Parameters:
         * **node_id** (*str*) -- node id
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_node_dict(node_id_dict: Dict[int, str]) -> Dict[int, BaseNode]
      Get node dict from docstore given a mapping of index to node
      ids.
      Parameters:
         **node_id_dict** (*Dict**[**int**, **str**]*) -- mapping of
         index to node ids
   get_nodes(node_ids: List[str], raise_error: bool = True) -> List[BaseNode]
      Get nodes from docstore.
      Parameters:
         * **node_ids** (*List**[**str**]*) -- node ids
         * **raise_error** (*bool*) -- raise error if node_id not
           found
   get_ref_doc_info(ref_doc_id: str) -> Optional[RefDocInfo]
      Get the RefDocInfo for a given ref_doc_id.
   persist(persist_path: str = './storage/docstore.json', fs: Optional[AbstractFileSystem] = None) -> None
      Persist the store.
   ref_doc_exists(ref_doc_id: str) -> bool
      Check if a ref_doc_id has been ingested.
   set_document_hash(doc_id: str, doc_hash: str) -> None
      Set the hash for a given doc_id.