Skip to main content

Python SDK for RNL Edge API

Project description

RNL Edge Python SDK

The RNL Edge SDK is a Python library designed to interact with RNL Edge services, providing an easy-to-use interface for authentication, managing documents, feedback collection, and interacting with the RNL API. This SDK simplifies the process of accessing and utilizing RNL Edge API features, allowing you to quickly authenticate users, manage documents, and handle various other tasks.

Features

Authentication: Handle user authentication via the RNL API. Document Management: Upload, retrieve, and manage documents within the RNL system. Feedback Collection: Submit feedback data to the RNL system. RAG (Retrieval-Augmented Generation): Query documents using the RNL RAG interface. Others: Additional utility functions for interacting with RNL API.

Installation

pip install rnl_edge_sdk

Usage

1. Authentication

The auth.py module allows you to authenticate users using the RNL Edge API. Here’s how to authenticate a user:

Example: example_auth.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient

def main():
    # Initialize the environment and client
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").auth

    # Perform authentication
    try:
        auth_data = client.auth("local", {"email": "user@example.com", "password": "password"})
        print(f"Authentication successful! Access token: {client.access_token}")
    except Exception as e:
        print(f"Authentication failed: {str(e)}")

if __name__ == "__main__":
    main()

2. Document Management

The documents.py module provides functionality for uploading and retrieving documents.

Example: example_documents.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient
from rnl_edge_sdk.requests.post_document_request import PostDocumentRequest

def main():
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").document

    # Authenticate the user
    client.auth("local", {"email": "user@example.com", "password": "password"})

    # Retrieve documents
    try:
        documents_response = client.get_documents()
        print(f"Number of documents: {documents_response.record_count}")
        for doc in documents_response.files:
            print(f"- {doc.get('name', 'Unnamed document')}")
    except Exception as e:
        print(f"Failed to get documents: {str(e)}")

    # Post a new document
    try:
        request = PostDocumentRequest([{"name": "sample.pdf", "content": "base64encodedcontent"}], category="Enrollment")
        post_document_response = client.post_document(request)
        print(f"Document uploaded successfully! ID: {post_document_response.document_id}")
    except Exception as e:
        print(f"Failed to post document: {str(e)}")

if __name__ == "__main__":
    main()

3. Feedback

The feedback.py module allows users to submit feedback through the RNL API.

Example: example_feedback.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient

def main():
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").feedback

    # Authenticate the user
    client.auth("local", {"email": "user@example.com", "password": "password"})

    # Submit feedback
    try:
        client.submit_feedback("This is feedback for the RNL system.")
        print("Feedback submitted successfully!")
    except Exception as e:
        print(f"Failed to submit feedback: {str(e)}")

if __name__ == "__main__":
    main()

4. RAG (Retrieval-Augmented Generation)

The rag.py module provides an interface for querying documents using the RAG (Retrieval-Augmented Generation) system.

Example: example_rag.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient

def main():
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").rag

    # Authenticate the user
    client.auth("local", {"email": "user@example.com", "password": "password"})

    # Query RAG
    try:
        response = client.query_rag("What is the enrollment process?")
        print("Query response:", response)
    except Exception as e:
        print(f"Failed to query RAG: {str(e)}")

if __name__ == "__main__":
    main()

5. Compass

The compass.py module contains functionality for interacting with the Compass component of the RNL system.

Example: example_compass.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient

def main():
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").compass

    # Authenticate the user
    client.auth("local", {"email": "user@example.com", "password": "password"})

    # Use Compass functionality (example)
    try:
        response = client.some_compass_function()
        print("Compass response:", response)
    except Exception as e:
        print(f"Failed to interact with Compass: {str(e)}")

if __name__ == "__main__":
    main()

6. Others

The others.py module contains additional utility functions for interacting with the RNL API.

Example: example_others.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient

def main():
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").other

    # Perform other utility functions
    try:
        response = client.some_other_function()
        print("Utility function response:", response)
    except Exception as e:
        print(f"Failed to perform utility function: {str(e)}")

if __name__ == "__main__":
    main()

7. Prompt

The prompt.py module provides prompt management functionality.

Example: example_prompt.py

from rnl_edge_sdk.environment import Environment
from rnl_edge_sdk.rnl_edge_client import RnlEdgeClient

def main():
    environment = Environment(Environment.Hosts.QA, "QA")
    client = RnlEdgeClient(environment, "token1234", "subdomain").prompt

    # Authenticate and manage prompts
    try:
        client.auth("local", {"email": "user@example.com", "password": "password"})
        response = client.get_prompt()
        print("Prompt response:", response)
    except Exception as e:
        print(f"Failed to manage prompt: {str(e)}")

if __name__ == "__main__":
    main()

Example Usage Files

The repository contains example Python scripts (example_auth.py, example_documents.py, etc.) that demonstrate how to use the various features of the SDK. You can refer to these files for detailed usage examples.

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

rnl_edge_sdk-1.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rnl_edge_sdk-1.0.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file rnl_edge_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: rnl_edge_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.7

File hashes

Hashes for rnl_edge_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 20ed409aaa66a6131fdfcb38da7623ce1f18647541a48b12179dc1906613786f
MD5 b6681acd312e03c015e9ed08e444fe4d
BLAKE2b-256 7f1b186cffd5d35a7757215498ac75a6bf0d2606679f99861079a739cb5cb4c9

See more details on using hashes here.

File details

Details for the file rnl_edge_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rnl_edge_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.7

File hashes

Hashes for rnl_edge_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ece34bd4ff48c434fdce7148309f5c97e29b82416c1da7b4ccc7cfae4b192244
MD5 66750604e14ee93b8fa60d303c9c817a
BLAKE2b-256 9d1a7b95f62d2edd8475bf78d1c73cb6aca888ac5b53e01c52a20c804a72d697

See more details on using hashes here.

Supported by

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