llama-index-readers-wordlift


Namellama-index-readers-wordlift JSON
Version 0.1.1 PyPI version JSON
download
home_page
Summaryllama-index readers wordlift integration
upload_time2024-02-12 23:47:54
maintainer
docs_urlNone
authorYour Name
requires_python>=3.8.1,<3.12
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

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](https://docs.wordlift.io/pages/key-concepts/#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:

```python
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](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/apify/actor#:~:text=load%20data%20into-,LlamaIndex,-and/or%20subsequently) and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "llama-index-readers-wordlift",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<3.12",
    "maintainer_email": "",
    "keywords": "",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/87/57/6ea2331f8317bddb6fbd2da917ba84c7f55283d1ffe0bf03920f3a294973/llama_index_readers_wordlift-0.1.1.tar.gz",
    "platform": null,
    "description": "# WordLift Reader\n\nThe 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.\n\n## Usage\n\nTo use the WordLift GraphQL Reader, follow the steps below:\n\n1. 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](https://docs.wordlift.io/pages/key-concepts/#wordlift-key)).\n2. Create an instance of the `WordLiftLoader` class, passing in the configuration options.\n3. Use the `load_data` method to fetch and transform the data.\n4. Process the loaded documents as needed.\n\nHere's an example of how to use the WordLift GraphQL Reader:\n\n```python\nimport json\nfrom llama_index import VectorStoreIndex\nfrom llama_index.readers.schema import Document\nfrom langchain.llms import OpenAI\nfrom llama_hub.wordlift import WordLiftLoader\n\n# Set up the necessary configuration options\nendpoint = \"https://api.wordlift.io/graphql\"\nheaders = {\n    \"Authorization\": \"<YOUR_WORDLIFT_KEY>\",\n    \"Content-Type\": \"application/json\",\n}\n\nquery = \"\"\"\n# Your GraphQL query here\n\"\"\"\nfields = \"<YOUR_FIELDS>\"\nconfig_options = {\n    \"text_fields\": [\"<YOUR_TEXT_FIELDS>\"],\n    \"metadata_fields\": [\"<YOUR_METADATA_FIELDS>\"],\n}\n# Create an instance of the WordLiftLoader\nreader = WordLiftLoader(endpoint, headers, query, fields, config_options)\n\n# Load the data\ndocuments = reader.load_data()\n\n# Convert the documents\nconverted_doc = []\nfor doc in documents:\n    converted_doc_id = json.dumps(doc.doc_id)\n    converted_doc.append(\n        Document(\n            text=doc.text,\n            doc_id=converted_doc_id,\n            embedding=doc.embedding,\n            doc_hash=doc.doc_hash,\n            extra_info=doc.extra_info,\n        )\n    )\n\n# Create the index and query engine\nindex = VectorStoreIndex.from_documents(converted_doc)\nquery_engine = index.as_query_engine()\n\n# Perform a query\nresult = query_engine.query(\"<YOUR_QUERY>\")\n\n# Process the result as needed\nlogging.info(\"Result: %s\", result)\n```\n\nThis loader is designed to be used as a way to load data from WordLift KGs into [LlamaIndex](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/apify/actor#:~:text=load%20data%20into-,LlamaIndex,-and/or%20subsequently) and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index readers wordlift integration",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23265a3d4ddaaa51000943ada232bcbb36336df240f7f0e8199e3782aca11d3f",
                "md5": "98690eccc8aa360561974c316d00f090",
                "sha256": "776a93382209143819cf7bdd6c5a087d272f525a82727cec1326516f2526545e"
            },
            "downloads": -1,
            "filename": "llama_index_readers_wordlift-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "98690eccc8aa360561974c316d00f090",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<3.12",
            "size": 5514,
            "upload_time": "2024-02-12T23:47:53",
            "upload_time_iso_8601": "2024-02-12T23:47:53.256846Z",
            "url": "https://files.pythonhosted.org/packages/23/26/5a3d4ddaaa51000943ada232bcbb36336df240f7f0e8199e3782aca11d3f/llama_index_readers_wordlift-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87576ea2331f8317bddb6fbd2da917ba84c7f55283d1ffe0bf03920f3a294973",
                "md5": "92875f1975f8754d7e6509ffe2396601",
                "sha256": "42225e23200745faeed33dcd946100cd6538fb1a06a4551893795fec15144dd2"
            },
            "downloads": -1,
            "filename": "llama_index_readers_wordlift-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "92875f1975f8754d7e6509ffe2396601",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<3.12",
            "size": 5016,
            "upload_time": "2024-02-12T23:47:54",
            "upload_time_iso_8601": "2024-02-12T23:47:54.727901Z",
            "url": "https://files.pythonhosted.org/packages/87/57/6ea2331f8317bddb6fbd2da917ba84c7f55283d1ffe0bf03920f3a294973/llama_index_readers_wordlift-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-12 23:47:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-readers-wordlift"
}
        
Elapsed time: 0.17344s