A Python SDK for interacting with the Nebula API
Project description
Nebula Python SDK
A Python client for interacting with the Nebula API, providing a seamless interface for chat-based interactions with thirdweb's Nebula service.
Installation
pip install nebula-python
Quick Start
from nebula import Nebula
# Initialize the client
client = Nebula(
base_url="https://nebula-api.thirdweb.com",
secret_key="your-secret-key"
)
# Basic chat request
response = client.chat("Hello, Nebula!")
print(response.message)
# Streaming chat request
for chunk in client.chat("Hello, Nebula!", stream=True):
print(chunk, end="")
Features
- Synchronous and streaming chat responses
- Session management
- Configurable execution environments
- Context filtering capabilities
- Custom model selection
- Type-safe request/response handling with Pydantic
Advanced Usage
Context Filtering
Filter the context of your chat based on specific blockchain parameters:
from nebula import ContextFilter
context = ContextFilter(
chain_ids=["1", "137"],
contract_addresses=["0x..."],
wallet_addresses=["0x..."]
)
response = client.chat(
"Tell me about my contracts",
context_filter=context
)
Execution Configuration
Configure how your requests are executed:
from nebula import ExecuteConfig
config = ExecuteConfig(
mode="client",
signer_wallet_address="0x...",
engine_url="https://your-engine.com"
)
response = client.chat(
"Execute this transaction",
execute_config=config
)
Session Management
Maintain conversation context across multiple messages:
response = client.chat(
"Remember this conversation",
session_id="unique-session-id"
)
Error Handling
The SDK provides custom exceptions for proper error handling:
from nebula import NebulaAPIError
try:
response = client.chat("Hello")
except NebulaAPIError as e:
print(f"API Error: {e}")
Configuration
The client can be configured with:
base_url: The base URL for the Nebula API (defaults to "https://nebula-api.thirdweb.com")secret_key: Your thirdweb API secret key for authentication
Development
Requirements
- Python 3.12+
requestspydantic
Running Tests
pytest tests/
License
[License Type] - See LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
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 thirdweb_nebula-0.1.0.tar.gz.
File metadata
- Download URL: thirdweb_nebula-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f95696e97dee8ab484125521c1d40012dec6c9d2f3ab1c0c81345ec6a602b3b0
|
|
| MD5 |
ed9a17fcb8f77c5c16e4bc8f9cb962bb
|
|
| BLAKE2b-256 |
0288071c2aeb41637709c5679b33779770f9a2bdc09eb44f3b2c5c45deb9ae4b
|
File details
Details for the file thirdweb_nebula-0.1.0-py3-none-any.whl.
File metadata
- Download URL: thirdweb_nebula-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/24.1.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7647ebb0c919d9e5c2db87f3378cdf9c31afbedea0dd7d5ea49ad28b0a68403
|
|
| MD5 |
4ebd4a61ee00ed71c1b72639d605a874
|
|
| BLAKE2b-256 |
f68ff55e6310347679fc230bd32979ff3359e94ba8aa4ab9df06b0d334e1ad23
|