Skip to main content

Python Library for Conva AI

This is the python library for using Conva AI Co-pilots

Examples

1. A simple example for generating response using Conva Co-pilot

import asyncio
from conva_ai import AsyncConvaAI
client = AsyncConvaAI(
    assistant_id="<YOUR_ASSISTANT_ID>", 
    assistant_version="<YOUR_ASSISTANT_VERSION>", 
    api_key="<YOUR_API_KEY>"
)
async def generate(client: AsyncConvaAI, query: str, stream: bool):
    response = client.invoke_capability(query, stream=stream)
    out = ""
    async for res in response:
        out = res.model_dump_json(indent=4)
    return out

final_response = asyncio.run(generate(client, "how are you", True))
print(final_response)

You can try out the co-pilot on Google Colab

If you want to get the response as dictionary, then replace

out = res.model_dump_json(indent=4)

with

out = res.model_dump()

2. How to clear history

Conva AI client, by default keeps track of your conversation history and uses it as the context for responding intelligently

You can clear conversation history by executing the below code:

from conva_ai.client import AsyncConvaAI
client = AsyncConvaAI(
    assistant_id="<YOUR_ASSISTANT_ID>", 
    assistant_version="<YOUR_ASSISTANT_VERSION>", 
    api_key="<YOUR_API_KEY>"
)
client.clear_history()

In case you are buliding an application where you don't want to track conversation history, you can disable history tracking

client.use_history(False)

You can enable history by

client.use_history(True)

3. Debugging responses

Conva AI uses generative AI to give you the response to your query. In order for you to understand the reasoning behind the response. We also provide you with AI's reasoning

import asyncio
from conva_ai.client import AsyncConvaAI

client = AsyncConvaAI(
        assistant_id="<YOUR_ASSISTANT_ID>", 
        assistant_version="<YOUR_ASSISTANT_VERSION>", 
        api_key="<YOUR_API_KEY>"
    )

async def generate(client: AsyncConvaAI, query: str, stream: bool):
    response = client.invoke_capability(query, stream=stream)
    out=""
    async for res in response:
        out = res
    return out

final_response = asyncio.run(generate("how are you", True))
print(final_response.reason)

How to use capability groups

Capability Groups are used to control the list of Capabilities that Co pilot will have access. You can make use of the capability group while using the invoke_capability method

async def generate(client: AsyncConvaAI, query: str, stream: bool):
    response = client.invoke_capability(query, stream=stream, capability_group="<CAPABILITY_GROUP_NAME>")
    out=""
    async for res in response:
        out = res
    return out

Metadata

Release files for conva-ai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conva-ai 0.1.0
File Size Uploaded Provenance Actions
conva_ai-0.1.0.tar.gz 4.0 kB Without provenance Details for conva_ai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for conva-ai 0.1.0
File Interpreter ABI Platform Actions
conva_ai-0.1.0-py3-none-any.whl Python 3 none any Details for conva_ai-0.1.0-py3-none-any.whl

Total release size: 8.4 kB

Release files / conva_ai-0.1.0.tar.gz

Download URL conva_ai-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
895ad9665ade98f0ed2011cbcae5387e3a58c4e7f11521e92237f39393732ff9
BLAKE2b-256 checksum
How to use checksums
6153a9acd35d19616d5305207cbdf261c1baa17b6069837defc93e4d11aea25c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Release files / conva_ai-0.1.0-py3-none-any.whl

Download URL conva_ai-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2abe5957d7de1d98c4301a8f92cae73fe943bd16f2fa722145fc267239d579e
BLAKE2b-256 checksum
How to use checksums
aacc76e32a4b4a3e4ba4e07ac07b66c48a83767bd7f3ad2e0142b6045ecea44a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.1

Security for conva-ai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page