Skip to main content

Python SDK for using Conva AI co-pilots

Project description

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

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

conva_ai-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

conva_ai-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file conva_ai-0.1.0.tar.gz.

File metadata

  • Download URL: conva_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for conva_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 895ad9665ade98f0ed2011cbcae5387e3a58c4e7f11521e92237f39393732ff9
MD5 6f3cafee4ce3362b6f226d5921530ed6
BLAKE2b-256 6153a9acd35d19616d5305207cbdf261c1baa17b6069837defc93e4d11aea25c

See more details on using hashes here.

File details

Details for the file conva_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: conva_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for conva_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2abe5957d7de1d98c4301a8f92cae73fe943bd16f2fa722145fc267239d579e
MD5 d36d952c242a80861685538b5670a7bd
BLAKE2b-256 aacc76e32a4b4a3e4ba4e07ac07b66c48a83767bd7f3ad2e0142b6045ecea44a

See more details on using hashes here.

Supported by

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