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

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
conva_ai-0.1.0.tar.gz 4.0 kB Details

Built distribution (wheel)

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

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

Release history Release notifications | RSS feed

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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