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.
- Prompt: To Manage Prompt History
- Compass: For Compass endpoints
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.
--
Thanks
Happy Coding 👩🏻💻
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rnl_edge_sdk-1.0.1.tar.gz.
File metadata
- Download URL: rnl_edge_sdk-1.0.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
feda66646ead909451fd1eb3ee2a9aa2d77340da1d42d2e91df8081d77fda44c
|
|
| MD5 |
f2f8f51e88c81c9f08db18f0408caf0a
|
|
| BLAKE2b-256 |
40bf0ae894fa9bb4b9ba331c235d8c86396e464acf9c26853ad4ce0add0c026c
|
File details
Details for the file rnl_edge_sdk-1.0.1-py3-none-any.whl.
File metadata
- Download URL: rnl_edge_sdk-1.0.1-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4ea256f93766d2b73eead957ae117d2765507434906adb29a7125bb60e401c9
|
|
| MD5 |
fcfc302020405d033bf0e0c4cfd4dc33
|
|
| BLAKE2b-256 |
b809351d698d27d2f6ce8a5c81e5d194a8123e90b1ad5fc80599bb5ffd1e7cda
|