# copilotcloud-rl
Python client for CopilotCloud Reinforcement Learning context API.
## Installation
Build and install the package from source:
```bash
pip install .
```
or using a wheel built via:
```bash
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.ai` or 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
```python
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 for
- `agentName` (str): Name of the agent to get context for
- `api_url` (str, optional): CopilotCloud API base URL (defaults to `COPILOTCLOUD_API_URL` env var)
- `public_api_key` (str, optional): Public API key (defaults to `COPILOTCLOUD_PUBLIC_API_KEY` env var)
- `private_api_key` (str, optional): Private API key (defaults to `COPILOTCLOUD_PRIVATE_API_KEY` env var)
- `limit` (int, optional): Maximum number of learning examples to return
- `timeout_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 invalid
- `RuntimeError`: If the API request fails or returns invalid data
Raw data
{
"_id": null,
"home_page": null,
"name": "copilotcloud-rl",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "ai, copilotcloud, copilotkit, reinforcement-learning, rl",
"author": null,
"author_email": "Luis Valdes <luis@copilotkit.ai>",
"download_url": "https://files.pythonhosted.org/packages/d1/83/c5e84d38af6c7abcf999f8176f29e7e6132ee2e212163fd07916d84e61e2/copilotcloud_rl-0.1.1.tar.gz",
"platform": null,
"description": "# copilotcloud-rl\n\nPython client for CopilotCloud Reinforcement Learning context API.\n\n## Installation\n\nBuild and install the package from source:\n\n```bash\npip install .\n```\n\nor using a wheel built via:\n\n```bash\npython -m build\npip install dist/copilotcloud_rl-*.whl\n```\n\n## Configuration\n\nThe client requires your CopilotCloud API keys and base URL to the API service.\n\n- Environment variables (recommended):\n - `COPILOTCLOUD_API_URL` (e.g. `https://api.copilotcloud.ai` or your self-hosted base URL)\n - `COPILOTCLOUD_PUBLIC_API_KEY` (your public API key)\n - `COPILOTCLOUD_PRIVATE_API_KEY` (your private API key)\n\nYou can also pass these values explicitly to the functions.\n\n## Usage\n\n```python\nfrom copilotcloud_rl import get_learning_context\n\n# Provide explicitly or rely on env vars\ncontext = get_learning_context(\n prompt=\"User asked to summarize quarterly KPIs\",\n agentName=\"sample_agent\",\n api_url=\"https://your-cloud.example.com\", # optional if env is set\n public_api_key=\"ck_public_xxx\", # optional if env is set\n private_api_key=\"ck_private_xxx\", # optional if env is set\n limit=10, # optional, limits number of examples\n timeout_seconds=15 # optional, request timeout\n)\n\nprint(context[\"learningContext\"]) # string prepared for few-shot priming\n```\n\n## API\n\n### 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\n\nSends 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`.\n\n**Parameters:**\n- `prompt` (str): The user prompt or query to get learning context for\n- `agentName` (str): Name of the agent to get context for\n- `api_url` (str, optional): CopilotCloud API base URL (defaults to `COPILOTCLOUD_API_URL` env var)\n- `public_api_key` (str, optional): Public API key (defaults to `COPILOTCLOUD_PUBLIC_API_KEY` env var)\n- `private_api_key` (str, optional): Private API key (defaults to `COPILOTCLOUD_PRIVATE_API_KEY` env var)\n- `limit` (int, optional): Maximum number of learning examples to return\n- `timeout_seconds` (int, optional): Request timeout in seconds (default: 15)\n\n**Returns:** Dictionary containing the parsed JSON response, typically `{ \"learningContext\": str }`\n\n**Raises:**\n- `ValueError`: If required parameters are missing or invalid\n- `RuntimeError`: If the API request fails or returns invalid data\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python client for CopilotCloud Reinforcement Learning context API",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/CopilotKit/copilotcloud-rl",
"Repository": "https://github.com/CopilotKit/copilotcloud-rl"
},
"split_keywords": [
"ai",
" copilotcloud",
" copilotkit",
" reinforcement-learning",
" rl"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b31fabdbb8f69993acc28f984654e53fe94e94002e5fe7337ebafea7b6885f06",
"md5": "32d14a507d3798c38d8f92e30f6b0351",
"sha256": "9103c2eb5931b42960740ce389907dc7711f0f49a95985704f90e6e7e4fdfde8"
},
"downloads": -1,
"filename": "copilotcloud_rl-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32d14a507d3798c38d8f92e30f6b0351",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 5797,
"upload_time": "2025-09-03T13:33:10",
"upload_time_iso_8601": "2025-09-03T13:33:10.464394Z",
"url": "https://files.pythonhosted.org/packages/b3/1f/abdbb8f69993acc28f984654e53fe94e94002e5fe7337ebafea7b6885f06/copilotcloud_rl-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d183c5e84d38af6c7abcf999f8176f29e7e6132ee2e212163fd07916d84e61e2",
"md5": "05046213bb911501de6658bb78df836c",
"sha256": "fa228a6957522c09f8c39515c31f28bfe012096a787dc105c046d95863b62581"
},
"downloads": -1,
"filename": "copilotcloud_rl-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "05046213bb911501de6658bb78df836c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4089,
"upload_time": "2025-09-03T13:33:11",
"upload_time_iso_8601": "2025-09-03T13:33:11.425007Z",
"url": "https://files.pythonhosted.org/packages/d1/83/c5e84d38af6c7abcf999f8176f29e7e6132ee2e212163fd07916d84e61e2/copilotcloud_rl-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-03 13:33:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "CopilotKit",
"github_project": "copilotcloud-rl",
"github_not_found": true,
"lcname": "copilotcloud-rl"
}