Skip to main content

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:

  1. 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).
  2. Create an instance of the WordLiftLoader class, passing in the configuration options.
  3. Use the load_data method to fetch and transform the data.
  4. 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

llama_index_readers_wordlift-0.3.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file llama_index_readers_wordlift-0.3.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_readers_wordlift-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0a035e5effd4fa6636ed07c9f82ca5332c198d9f5f7057013e9ab7ad54e43e39
MD5 262d82b438674bef2b7d21c7081d96dd
BLAKE2b-256 c9005ed74985176923a397bbdf8f57a29d1465265cc44ea786a5a18de3364e56

See more details on using hashes here.

File details

Details for the file llama_index_readers_wordlift-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_wordlift-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd3d894ec0b13f224785c8f453897ae7433f6f7119cb67d5f99213e75a7bba69
MD5 e84dc0a584ac7da3d1336da311c61ee8
BLAKE2b-256 2f4a7446ba6a2de93e68b465b91e36f7ed9b12f63e9660365e7fb8e42847b9b9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page