ElCarroDocumentSaver(
elcarro_engine: langchain_google_el_carro.engine.ElCarroEngine,
table_name: str,
content_column: typing.Optional[str] = None,
metadata_json_column: typing.Optional[str] = None,
)
A class for saving langchain documents into an ElCarro-Oracle database table.
Methods
ElCarroDocumentSaver
ElCarroDocumentSaver(
elcarro_engine: langchain_google_el_carro.engine.ElCarroEngine,
table_name: str,
content_column: typing.Optional[str] = None,
metadata_json_column: typing.Optional[str] = None,
)
ElCarroDocumentSaver allows for saving of langchain documents in an ElCarro-Oracle database. If the table doesn't exist, a table with default schema will be created. The default schema:
- page_content (type: text)
- langchain_metadata (type: JSON)
Parameters | |
---|---|
Name | Description |
elcarro_engine |
ElCarroEngine
ElCarroEngine object to connect to the ElCarro-Oracle database. |
table_name |
str
The name of table for saving documents. |
content_column |
str
The column to store document content. Default: |
metadata_json_column |
str
The name of the JSON column to use as the metadata’s base dictionary. Default: |
_parse_row_from_doc
_parse_row_from_doc(
column_names: typing.Iterable[str],
doc: langchain_core.documents.base.Document,
content_column: str = "page_content",
metadata_json_column: str = "langchain_metadata",
json_as_string=True,
) -> typing.Dict
Convert a Document into a dictionary according to the table schema:
Store Doc.page_content
in result[content_column
]
If a Doc metadata fields exist in the Table Schema, add them to the result
If there's a JSON metadata column in the table, unpack remaining Doc metadata
to result[metadata_json_column]
Parameters | |
---|---|
Name | Description |
column_names |
typing.Iterable[str]
Database table columns |
doc |
Document
Document |
content_column |
str
name of the content column |
metadata_json_column |
str
name of the JSON metadata column |
add_documents
add_documents(docs: typing.List[langchain_core.documents.base.Document]) -> None
Save documents in the DocumentSaver table. Document’s metadata is added to columns if found or stored in langchain_metadata JSON column.
Args: docs (List[langchain_core.documents.Document]): a list of documents to be saved.
delete
delete(docs: typing.List[langchain_core.documents.base.Document]) -> None
Delete all instances of a document from the DocumentSaver table by matching the entire Document object.
Parameter | |
---|---|
Name | Description |
docs |
List[langchain_core.documents.Document]
a list of documents |