Metadata-Version: 2.1
Name: conva_ai
Version: 0.1.0
Summary: Python SDK for using Conva AI co-pilots
Author-email: Slang Labs <support@slanglabs.in>
Project-URL: Homepage, http://www.slanglabs.in
Project-URL: Documentation, https://docs.slanglabs.in/
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: annotated-types ==0.6.0
Requires-Dist: certifi ==2024.2.2
Requires-Dist: charset-normalizer ==3.3.2
Requires-Dist: idna ==3.7
Requires-Dist: pydantic ==2.7.0
Requires-Dist: pydantic-core ==2.18.1
Requires-Dist: requests ==2.31.0
Requires-Dist: sseclient-py ==1.8.0
Requires-Dist: typing-extensions ==4.11.0
Requires-Dist: urllib3 ==2.2.1

# 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](https://colab.research.google.com/drive/1WtbARTRQ9wCvztrAQuEhQUvwImhtPZXd#scrollTo=ZSVBQsOelgfv)

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