A Python SDK for interacting with the Lumbni API
Project description
Lumbni Client SDK
This is a Python SDK for interacting with the Lumbni API. It allows you to generate text using the Lumbni model and handle API responses efficiently.
Installation
To install the Lumbni client SDK, you can use pip:
pip install lumbni-client
Setup
Requirements
- Python 3.6 or higher
requestslibrary (this is automatically installed with the package)
Configuration
To use the SDK, you'll need an API key from Lumbni. You can obtain this by visiting https://www.lumbni.tech
Once you have the API key, you can initialize the LumbniClient class and start generating text.
Usage Example
- Import the SDK: You can import the
LumbniClientclass from the SDK package. - Initialize the Client: Create a client instance by passing your API key and setting the environment mode (
devorprod). - Generate Text: Use the
generate_text()method to generate text by providing a prompt.
Basic Example
from lumbni_client.client import LumbniClient
# Initialize the client with your API key and the mode (dev or prod)
client = LumbniClient(api_key="your_api_key", mode="dev")
# Generate text
response = client.generate_text(prompt="What is the significance of lumbni ?")
# Print the response
print(response)
Advanced Example with Optional Parameters
You can also provide optional parameters for more control over the text generation:
from lumbni_client.client import LumbniClient
# Initialize the client
client = LumbniClient(api_key="your_api_key", mode="prod")
# Generate text with additional parameters
response = client.generate_text(
prompt="Explain quantum computing.",
system_prompt="Please explain at a beginner level.",
model_name="gemini-1.5-flash-8b",
temperature=0.8,
top_p=0.9,
top_k=3,
max_output_tokens=150,
stream=False
)
# Print the generated text response
print(response)
Response Handling
The response from the API will be a dictionary containing the generated text and additional metadata. Here's an example of handling and processing the API response:
from lumbni_client.response import handle_api_response
# Call the generate_text method
response = client.generate_text(prompt="Tell me a joke.")
# Handle the response
handle_api_response(response)
The handle_api_response() function will print the generated text if the request is successful or log an error if something goes wrong.
Error Handling
If there is an error with the API request (e.g., invalid API key or malformed request), the SDK will raise a LumbniApiError.
Example of error handling:
from lumbni_client.exceptions import LumbniApiError
try:
response = client.generate_text(prompt="Tell me a joke.")
except LumbniApiError as e:
print(f"An error occurred: {e}")
Customizing the API Key and Server URL
- API Key: The API key is provided during the
LumbniClientinitialization. Replace"your_api_key"with the key you obtained from Lumbni. - Server Mode: The mode (
devorprod) can be set during the initialization to switch between development and production servers.
client = LumbniClient(api_key="your_api_key", mode="dev") # Use the development server
client = LumbniClient(api_key="your_api_key", mode="prod") # Use the production server
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 lumbni_client-1.0.1.tar.gz.
File metadata
- Download URL: lumbni_client-1.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4313fed1a3bcdc00aabb7bb9d23dc397c49e82f1a2bf8c867f4629647e78badd
|
|
| MD5 |
2a35eae4ca70946541fd95b4841a4b4d
|
|
| BLAKE2b-256 |
03e54c8d670de7624cb4867a4ba545321517fc124ef1f9228ddf13bd066f57cf
|
File details
Details for the file lumbni_client-1.0.1-py3-none-any.whl.
File metadata
- Download URL: lumbni_client-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57275e2c40893b011c358f247b76c1ef0eb99074c5c58865d192c0c947d95ea4
|
|
| MD5 |
d9126da2bdebf1b9cf04b0bdea603688
|
|
| BLAKE2b-256 |
c6f5a229472afb769d655d0132b62b78dc410ecf599dab415490773076f81aae
|