StringIterableReader#

pydantic model llama_index.readers.StringIterableReader#

String Iterable Reader.

Gets a list of documents, given an iterable (e.g. list) of strings.

Example

from llama_index import StringIterableReader, TreeIndex

documents = StringIterableReader().load_data(
    texts=["I went to the store", "I bought an apple"]
)
index = TreeIndex.from_documents(documents)
query_engine = index.as_query_engine()
query_engine.query("what did I buy?")

# response should be something like "You bought an apple."

Show JSON schema
{
   "title": "StringIterableReader",
   "description": "String Iterable Reader.\n\nGets a list of documents, given an iterable (e.g. list) of strings.\n\nExample:\n    .. code-block:: python\n\n        from llama_index import StringIterableReader, TreeIndex\n\n        documents = StringIterableReader().load_data(\n            texts=[\"I went to the store\", \"I bought an apple\"]\n        )\n        index = TreeIndex.from_documents(documents)\n        query_engine = index.as_query_engine()\n        query_engine.query(\"what did I buy?\")\n\n        # response should be something like \"You bought an apple.\"",
   "type": "object",
   "properties": {
      "is_remote": {
         "title": "Is Remote",
         "default": false,
         "type": "boolean"
      },
      "class_name": {
         "title": "Class Name",
         "type": "string",
         "default": "StringIterableReader"
      }
   }
}

Config
  • arbitrary_types_allowed: bool = True

Fields
  • is_remote (bool)

field is_remote: bool = False#
classmethod class_name() str#

Get the class name, used as a unique ID in serialization.

This provides a key that makes serialization robust against actual class name changes.

load_data(texts: List[str]) List[Document]#

Load the data.