Python client for CopilotCloud Reinforcement Learning context API
Project description
copilotcloud-rl
Python client for CopilotCloud Reinforcement Learning context API.
Installation
Build and install the package from source:
pip install .
or using a wheel built via:
python -m build
pip install dist/copilotcloud_rl-*.whl
Configuration
The client requires your CopilotCloud API keys and base URL to the API service.
- Environment variables (recommended):
COPILOTCLOUD_API_URL(e.g.https://api.copilotcloud.aior your self-hosted base URL)COPILOTCLOUD_PUBLIC_API_KEY(your public API key)COPILOTCLOUD_PRIVATE_API_KEY(your private API key)
You can also pass these values explicitly to the functions.
Usage
from copilotcloud_rl import get_learning_context
# Provide explicitly or rely on env vars
context = get_learning_context(
prompt="User asked to summarize quarterly KPIs",
agentName="sample_agent",
api_url="https://your-cloud.example.com", # optional if env is set
public_api_key="ck_public_xxx", # optional if env is set
private_api_key="ck_private_xxx", # optional if env is set
limit=10, # optional, limits number of examples
timeout_seconds=15 # optional, request timeout
)
print(context["learningContext"]) # string prepared for few-shot priming
API
get_learning_context(prompt: str, agentName: str, *, api_url: str | None = None, public_api_key: str | None = None, private_api_key: str | None = None, limit: int | None = None, timeout_seconds: int = 15) -> dict
Sends a POST request to /reinforcement-learning/v1/context with body { agentName, prompt, limit } and headers X-CopilotCloud-Public-Api-Key and X-CopilotCloud-Private-Api-Key.
Parameters:
prompt(str): The user prompt or query to get learning context foragentName(str): Name of the agent to get context forapi_url(str, optional): CopilotCloud API base URL (defaults toCOPILOTCLOUD_API_URLenv var)public_api_key(str, optional): Public API key (defaults toCOPILOTCLOUD_PUBLIC_API_KEYenv var)private_api_key(str, optional): Private API key (defaults toCOPILOTCLOUD_PRIVATE_API_KEYenv var)limit(int, optional): Maximum number of learning examples to returntimeout_seconds(int, optional): Request timeout in seconds (default: 15)
Returns: Dictionary containing the parsed JSON response, typically { "learningContext": str }
Raises:
ValueError: If required parameters are missing or invalidRuntimeError: If the API request fails or returns invalid data
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 copilotcloud_rl-0.1.1.tar.gz.
File metadata
- Download URL: copilotcloud_rl-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa228a6957522c09f8c39515c31f28bfe012096a787dc105c046d95863b62581
|
|
| MD5 |
05046213bb911501de6658bb78df836c
|
|
| BLAKE2b-256 |
d183c5e84d38af6c7abcf999f8176f29e7e6132ee2e212163fd07916d84e61e2
|
File details
Details for the file copilotcloud_rl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: copilotcloud_rl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9103c2eb5931b42960740ce389907dc7711f0f49a95985704f90e6e7e4fdfde8
|
|
| MD5 |
32d14a507d3798c38d8f92e30f6b0351
|
|
| BLAKE2b-256 |
b31fabdbb8f69993acc28f984654e53fe94e94002e5fe7337ebafea7b6885f06
|