PythonSDK
Last updated
Last updated
from mimetypes import knownfiles
rivalz-client
is a Python client designed for interacting with the Rivalz API. It enables developers to upload, download, and manage files on the Rivalz platform using IPFS (InterPlanetary File System).
Upload Files: Upload any file to the Rivalz platform and get an IPFS hash.
Upload Passport Images: Upload passport images to the Rivalz platform.
Download Files: Download files from the Rivalz platform using an IPFS hash.v
Delete Files: Delete files from the Rivalz platform using an IPFS hash.
Vectorize Documents: Vectorize documents to create a RAG (Retrieval-Augmented Generation) based on the document uploaded.
Create conversations: Create conversations based on the document uploaded.
You can install the rivalz-client package via pip using the following command:
This guide provides detailed instructions on how to use the rivalz-client to interact with the Rivalz API.
To upload a file to the Rivalz, you can use the upload_file
method. Simply provide the path to the file you want to upload as an argument
To upload a passport image, use the upload_passport
method. Provide the path to the passport image file.
To download a file, use the download_file
method with the IPFS hash of the file and the directory where you want to save the file.
To delete a file, use the delete_file
method with the IPFS hash of the file you want to delete.
To get your uploaded files, use the get_upload_history
method. This method accept page and size for pagination. Page start from 0. And default is page 0 (first page) and size is 10.
To vectorize a document and create a knowledge base for Retrieval-Augmented Generation (RAG), use the create_rag_knowledge_base
method, which takes the document's file path as input. This method generates a vectorized embedding of the document, assigns it a knowledge base ID, and stores it for future use in RAG-based conversations. Currently, this process supports only PDF files.
To add a document to an existing knowledge base, use the add_document_to_knowledge_base
method. This method requires the knowledge base ID (from the knowledge base you’ve already created) and the file path of the new document.
To delete a document from an existing knowledge base, use the delete_document_from_knowledge_base
method with the knowledge base id and the document name.
To get all knowledge bases, use the get_knowledge_bases
method.
To get details of a knowledge base, use the get_knowledge_base
method with the knowledge base id.
To initiate a conversation in the RAG (Retrieval Augmented Generation) system, use the create_chat_session
method. This method requires the knowledge base ID (from your existing knowledge base) and the question you want to ask. The AI will return a response based on the context provided by the knowledge base, along with a chat session ID to continue the conversation if needed.
To add a message to a conversation, use the same method create_chat_session
with the chat session id and the message.
To get all conversations, use the get_chat_sessions
method.
To get details of a conversation (which contains chat history for this conversation), use the get_chat_session
method with the chat session id.
To get all uploaded documents, use the get_uploaded_documents
method.
Here is a complete example demonstrating how to use the rivalz-client
to create a simple RAG conversation based on a PDF document:
First, import the RivalzClient
class and initialize it with . If you don’t provide a token, it will use a default example token.
Before using the RAG API, you need api key and some rivalz credits. Claim for free now