llama-index readers wordlift integration
Project description
WordLift Reader
pip install llama-index-readers-wordlift
The WordLift GraphQL Reader is a connector to fetch and transform data from a WordLift Knowledge Graph using your the WordLift Key. The connector provides a convenient way to load data from WordLift using a GraphQL query and transform it into a list of documents for further processing.
Usage
To use the WordLift GraphQL Reader, follow the steps below:
- Set up the necessary configuration options, such as the API endpoint, headers, query, fields, and configuration options (make sure you have with you the Wordlift Key).
- Create an instance of the
WordLiftLoader
class, passing in the configuration options. - Use the
load_data
method to fetch and transform the data. - Process the loaded documents as needed.
Here's an example of how to use the WordLift GraphQL Reader:
import json
from llama_index.core import VectorStoreIndex
from llama_index.core import Document
from langchain.llms import OpenAI
from llama_index.readers.wordlift import WordLiftLoader
# Set up the necessary configuration options
endpoint = "https://api.wordlift.io/graphql"
headers = {
"Authorization": "<YOUR_WORDLIFT_KEY>",
"Content-Type": "application/json",
}
query = """
# Your GraphQL query here
"""
fields = "<YOUR_FIELDS>"
config_options = {
"text_fields": ["<YOUR_TEXT_FIELDS>"],
"metadata_fields": ["<YOUR_METADATA_FIELDS>"],
}
# Create an instance of the WordLiftLoader
reader = WordLiftLoader(endpoint, headers, query, fields, config_options)
# Load the data
documents = reader.load_data()
# Convert the documents
converted_doc = []
for doc in documents:
converted_doc_id = json.dumps(doc.doc_id)
converted_doc.append(
Document(
text=doc.text,
doc_id=converted_doc_id,
embedding=doc.embedding,
doc_hash=doc.doc_hash,
extra_info=doc.extra_info,
)
)
# Create the index and query engine
index = VectorStoreIndex.from_documents(converted_doc)
query_engine = index.as_query_engine()
# Perform a query
result = query_engine.query("<YOUR_QUERY>")
# Process the result as needed
logging.info("Result: %s", result)
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_wordlift-0.2.0.tar.gz
.
File metadata
- Download URL: llama_index_readers_wordlift-0.2.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.13 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396b371e3e3c9791996e9f8fe4c5cc67cc0ba691c09546566602967d48fbfbfe |
|
MD5 | 1f3642b3acba6ccce94f02b79ed65ede |
|
BLAKE2b-256 | 68ab4dda6b14a972684329de06dcff2c9a8c8dc7873a548e1d0f0f5a0af2148f |
File details
Details for the file llama_index_readers_wordlift-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_readers_wordlift-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.13 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1140b30609fd10f1c5cae2a2e4fe72e489d0f563ec998e2b1e86e3d6cd3d61ad |
|
MD5 | e6867d60254bd0dc59ccd5f822f50fab |
|
BLAKE2b-256 | d6e94196f2fdb32d1242fab573f8c02646adb6009d571a8a9709258119bbc1e7 |