Skip to main content

State-of-the-art RAG pipeline from D-Star AI

Project description

Overview

This python package is only useful for a custom cloud deployment of dsRAG

Usage

pip install dsrag-sdk

Setup

You can set the base url that the sdk connects to by running the following:

from dsrag_sdk.main import set_base_url
set_base_url("http://0.0.0.0:8000")

Knowledge bases

from dsrag_sdk.knowledge_bases import create_knowledge_base, list_knowledge_bases, get_knowledge_base, delete_knowledge_base, update_knowledge_base

Create knowledge base

kb = create_knowledge_base(title="sdk_test_kb", supp_id="test-supp-id")

List knowledge bases

knowledge_bases = list_knowledge_bases()

List with supp_id filter

knowledge_bases = list_knowledge_bases(supp_id="test-supp-id")

Get a knowledge base by id

knowledge_base = get_knowledge_base(knowledge_base_id="test-kb-id")

Update a knowledge base

knowledge_base = update_knowledge_base(knowledge_base_id="test-kb-id", title="updated-title", supp_id="updated-supp-id")

Delete a knowledge base

response = delete_knowledge_base(knowledge_base_id="test-kb-id")

Documents

from dsrag_sdk.documents import create_document_via_text, list_documents, get_document, delete_document

Add a document via text

kb_id = "test-kb-id"
document_text = "This is some test text for document upload"
document = create_document_via_text(kb_id, document_text)

List documents

documents = list_documents(kb_id)

List documents with supp_id filter

documents = list_documents(knowledge_base_id="test-kb-id", supp_id="test-supp-id")

Get document by id

document = get_document(knowledge_base_id="test-kb-id", document_id="test-document-id")

Delete a document

response = delete_document(knowledge_base_id="test-kb-id", document_id="test-document-id")

Chat

from dsrag_sdk.chat import create_chat_thread, list_chat_threads, update_chat_thread, get_chat_thread, delete_chat_thread, get_chat_response, list_thread_interactions

Create a chat thread

response = create_chat_thread(knowledge_base_ids=[kb_id])

List chat threads

chat_threads = list_chat_threads()

Filter with supp_id

chat_threads = list_chat_threads(supp_id="test-supp-id")

Get chat thread by id

chat_thread = get_chat_threads(thread_id="test-thread-id")

Get a chat response

response = get_chat_response(thread_id="test-thread-id", input="What is AGI?")

Update a chat thread

chat_thread = update_chat_thread(thread_id="test-thread-id", knowledge_base_ids=[kb_id_1, kn_id_2], supp_id="updated-supp-id", model="gpt-4o-mini")

Delete a chat thread

response = delete_chat_thread(thread_id="test-thread-id")

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

dsrag_sdk-0.0.5.tar.gz (9.0 kB view hashes)

Uploaded Source

Built Distribution

dsrag_sdk-0.0.5-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

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