Skip to main content

Conva AI Python Library

This library enables interaction with Conva AI Co-pilots.

Installation

pip install conva-ai

Usage

Initializing the Client

To use the Conva AI library, you first need to initialize the AsyncConvaAI client with your credentials:

from conva_ai import AsyncConvaAI

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

Replace the placeholders with your actual assistant ID, version, and API key provided by Conva AI.

Basic Response Generation

To generate a response from the AI, use the invoke_capability method:

import asyncio

query = "What's the weather like today?"
response = asyncio.run(client.invoke_capability(query, stream=False))
print(response.message)

This will send your query to the AI and return a response. The stream=False parameter indicates that you want to receive the full response at once.

Invoking Specific Capabilities

If you want to use a particular capability of the AI, you can specify it using the invoke_capability_name method:

query = "Take me to the home page"
response = asyncio.run(client.invoke_capability_name(query, stream=False, capability_name="navigation"))
print(response.message)

In this example, we're specifically invoking the "navigation" capability of the AI.

Streaming Responses

For longer responses or real-time interactions, you can use streaming mode:

query = "Give me a detailed explanation of quantum computing"
response = asyncio.run(client.invoke_capability(query, stream=True))
async for res in response:
    print(res)

This will print parts of the response as they are generated, allowing for more interactive experiences.

Maintaining Conversation History

To have a continuous conversation with Conva AI, you can keep track of the conversation history:

history = "{}"
while True:
    query = input("Enter your query: ")
    response = asyncio.run(client.invoke_capability(query, stream=False, history=history))
    history = response.conversation_history
    print(response.message)

This loop allows you to have an ongoing conversation with the Conva AI, with each response considering the context of previous interactions.

Debugging Responses

To understand the Conva AI's reasoning behind a response, you can access additional information:

final_response_dict = response.model_dump()
print(final_response_dict["reason"])

This will print out the AI's reasoning process, which can be helpful for debugging or understanding complex responses.

Try It Out

You can experiment with the Conva AI Co-pilot in a Google Colab notebook. This is a great way to get familiar with the library's capabilities without setting up a local environment. Try Conva AI on Google Colab

Additional Information

Make sure to handle API keys securely and never expose them in your code repositories. The library uses asynchronous programming with asyncio for efficient handling of I/O operations.

Metadata

Release files for conva-ai 0.2.4

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.2.4
File Size Uploaded
conva_ai-0.2.4.tar.gz 6.5 kB Details

Built distribution (wheel)

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

Total release size: 13.4 kB

Release files / conva_ai-0.2.4.tar.gz

Download URL conva_ai-0.2.4.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a2cd2d018a33d7159c6d7fda9f1aecc2305d1fce0e3d7b4114a57732a437435e
BLAKE2b-256 checksum
How to use checksums
89a801da210a03ca3cbd3d6216bf2aa9e6e8ade7afc6b4a006f5a34a94ad7ff1
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.2.4-py3-none-any.whl

Download URL conva_ai-0.2.4-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65cce77377eba22b3f893b592803c4f847f31a1bfa6cd3741650cc1bf03dfa68
BLAKE2b-256 checksum
How to use checksums
76d5d2dd8e7b2bf836419c3b78d8ce87f586b5087c73d2dc28668f5cb0fe4593
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

This release

0.2.4 This release

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

0.1.0

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