Skip to main content

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.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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copilotcloud_rl-0.1.1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

copilotcloud_rl-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

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

Hashes for copilotcloud_rl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fa228a6957522c09f8c39515c31f28bfe012096a787dc105c046d95863b62581
MD5 05046213bb911501de6658bb78df836c
BLAKE2b-256 d183c5e84d38af6c7abcf999f8176f29e7e6132ee2e212163fd07916d84e61e2

See more details on using hashes here.

File details

Details for the file copilotcloud_rl-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for copilotcloud_rl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9103c2eb5931b42960740ce389907dc7711f0f49a95985704f90e6e7e4fdfde8
MD5 32d14a507d3798c38d8f92e30f6b0351
BLAKE2b-256 b31fabdbb8f69993acc28f984654e53fe94e94002e5fe7337ebafea7b6885f06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page