Skip to main content

A simple RAG (Retrieval-Augumented Generation) Task Manager

Project description

RAGWrangler - A simple RAG (Retrieval-Augumented Generation) Task Manager

RAGWrangler is a Python project designed to streamline the management of RAG tasks using generative language models and the Weaviate database.

With this tool, you can automatically create, retrieve, and store the outputs of RAG tasks in a structured manner in Weaviate, allowing for easy management and tracking of outputs, ultimately saving time and resources.

Features

  • Automated Task Handling: Simplify the creation and management of tasks with a straightforward Python class interface.
  • Weaviate Integration: Seamlessly store and retrieve task outputs using Weaviate database integration.
  • Support for Multiple Language Models: You can easily swap out language models as desired.
  • Logging: Utilize integrated logging for effortless debugging and tracking of task statuses.

Installation

The tool should be compatible with Python 3.8 and higher, although development primarily utilized Python 3.9.

To get started, install the necessary Python packages using the command below:

pip install ragwrangler

Quickstart

See example_usage.py to see a brief example of how to use the tool.

Usage

You can connect to any Weaviate instance to save your data. Refer to the Weaviate documentation for more information on how to set up & connect to a Weaviate instance.

The primary class you will interact with is RAGTask.

RAGTask

Instantiate a RAGTask for each generative task to be handled.

Provide it with a Weaviate instance, and a builder function. You will also need to set the OpenAI API key.

import weaviate, os
from ragwrangler import RAGTask, set_openai_api_key

client = weaviate.Client(
    url=os.environ['WCS_URL'],
    auth_client_secret=weaviate.AuthApiKey(os.environ['WCS_ADMIN_KEY']),
    additional_headers={"X-OpenAI-Api-Key": os.environ["OPENAI_APIKEY"]}
)

set_openai_api_key(os.environ["OPENAI_APIKEY"])
quiz_rag = RAGTask(client=client, task_prompt_builder=revision_quiz_json_builder)

Where revision_quiz_json_builder is a function that takes in a source text and returns a task prompt for the LLM.

Extend RAGTask by defining custom task prompt builder functions that dictate how to generate prompts from the source text, which are then used to derive outputs.

Working with Tasks

To create a new task, instantiate an object of RAGTask (or its extension) with a source text:

quiz_rag = RAGTask(client=client, task_prompt_builder=revision_quiz_json_builder)

To obtain the task output, utilize the get_output method, specifying a model name if desired:

output = task.get_output(source_text="Your source text here", model_name="gpt-3.5-turbo")

License

This project is licensed under the MIT License.

Copyright

© 2023 JP Hwang

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

ragwrangler-0.1.4.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

ragwrangler-0.1.4-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file ragwrangler-0.1.4.tar.gz.

File metadata

  • Download URL: ragwrangler-0.1.4.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for ragwrangler-0.1.4.tar.gz
Algorithm Hash digest
SHA256 95d2a947d15006306a6ae9c901e4e6677f2bbb537becf6f0e58b072b2969897f
MD5 34fe9df6270ccdaf8975688f53ac977a
BLAKE2b-256 b997756b9cf6f7c43f20b99457842c2e5c06e08195d189ce6480d063c5139120

See more details on using hashes here.

File details

Details for the file ragwrangler-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: ragwrangler-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for ragwrangler-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6759f81df4074278127ff32c12c9b4319d413312ca716c2264436a4f356333bd
MD5 65784adc33c29ec0b3388acc0f45f85e
BLAKE2b-256 394da6ca2484fe65dec1ee2d0206e23b5c2c3808d925649ec7c391f97fef5572

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