llama-index readers airbyte_cdk integration
Project description
Airbyte CDK Loader
pip install llama-index-readers-airbyte-cdk
The Airbyte CDK Loader is a shim for sources created using the Airbyte Python CDK. It allows you to load data from any Airbyte source into LlamaIndex.
Installation
- Install llama-index reader:
pip install llama-index-readers-airbyte-cdk
- Install airbyte-cdk:
pip install airbyte-cdk
- Install a source via git (or implement your own):
pip install git+https://github.com/airbytehq/airbyte.git@master#egg=source_github&subdirectory=airbyte-integrations/connectors/source-github
Usage
Implement and import your own source. You can find lots of resources for how to achieve this on the Airbyte documentation page.
Here's an example usage of the AirbyteCdkReader.
from llama_index.readers.airbyte_cdk import AirbyteCDKReader
from source_github.source import (
SourceGithub,
) # this is just an example, you can use any source here - this one is loaded from the Airbyte Github repo via pip install git+https://github.com/airbytehq/airbyte.git@master#egg=source_github&subdirectory=airbyte-integrations/connectors/source-github`
github_config = {
# ...
}
reader = AirbyteCDKReader(source_class=SourceGithub, config=github_config)
documents = reader.load_data(stream_name="issues")
By default all fields are stored as metadata in the documents and the text is set to the JSON representation of all the fields. Construct the text of the document by passing a record_handler
to the reader:
def handle_record(record, id):
return Document(
doc_id=id, text=record.data["title"], extra_info=record.data
)
reader = AirbyteCDKReader(
source_class=SourceGithub,
config=github_config,
record_handler=handle_record,
)
Lazy loads
The reader.load_data
endpoint will collect all documents and return them as a list. If there are a large number of documents, this can cause issues. By using reader.lazy_load_data
instead, an iterator is returned which can be consumed document by document without the need to keep all documents in memory.
Incremental loads
If a stream supports it, this loader can be used to load data incrementally (only returning documents that weren't loaded last time or got updated in the meantime):
reader = AirbyteCDKReader(source_class=SourceGithub, config=github_config)
documents = reader.load_data(stream_name="issues")
current_state = reader.last_state # can be pickled away or stored otherwise
updated_documents = reader.load_data(
stream_name="issues", state=current_state
) # only loads documents that were updated since last time
This loader is designed to be used as a way to load data into LlamaIndex.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file llama_index_readers_airbyte_cdk-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_readers_airbyte_cdk-0.3.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc00dfae22350381de5a59b18c69e1647574f9db1dbbce90481c64b9911bd6e3 |
|
MD5 | dc3e2dc4561da47863c88805c7d2f4b8 |
|
BLAKE2b-256 | 610b5d308a00d3ff98a8c754d7315f8f151638d7e6b251bb4bba52960bfa8361 |
File details
Details for the file llama_index_readers_airbyte_cdk-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_readers_airbyte_cdk-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b99e2ba852eeb1084d87aa5b6431416426d08a0e917c62fa9373cec4e9dd4c29 |
|
MD5 | 8b9bd640d66f7919704ac38c3f249a9f |
|
BLAKE2b-256 | 3c0ffc2748547aefbc1d2e82ceb2245e83d5e4113515d61e6957fc51a5f6d8bc |