llama-index readers wordlift integration
Project description
WordLift Reader
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 import VectorStoreIndex
from llama_index.readers.schema import Document
from langchain.llms import OpenAI
from llama_hub.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)
This loader is designed to be used as a way to load data from WordLift KGs into LlamaIndex and/or subsequently used as a Tool in a LangChain Agent.
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
Close
Hashes for llama_index_readers_wordlift-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fdd8d924b1315eaca1c84725e23da775244092da1bdb69582cc74de26feb2be |
|
MD5 | 4210db3aafd032ed1fd6e9b8d06fa376 |
|
BLAKE2b-256 | 80ab9599b9c8ba6241b2ee54e6b0fb6903609471af3fd1a2235722e776e84bb6 |
Close
Hashes for llama_index_readers_wordlift-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87d52c4a0a51b98acdee994b99707587127b5c64ab8bd886823deb837660cb95 |
|
MD5 | c979a0a2407fde582be2da0990d507e7 |
|
BLAKE2b-256 | 2fe42076307cd36625a562c43770f5a5de7e2b530ab4c0799c05f55b918a53af |