Metadata-Version: 2.4
Name: sonika-ai-toolkit
Version: 0.3.2
Summary: Toolkit para creación de agentes de IA y procesamiento de documentos
Author: Erley Blanco Carvajal
License: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-mcp-adapters>=0.1.9
Requires-Dist: langchain-community>=0.3.26
Requires-Dist: langchain-core>=0.3.66
Requires-Dist: langchain-openai>=0.3.24
Requires-Dist: langgraph>=0.4.8
Requires-Dist: langgraph-checkpoint>=2.1.0
Requires-Dist: langgraph-sdk>=0.1.70
Requires-Dist: dataclasses-json==0.6.7
Requires-Dist: python-dateutil==2.9.0.post0
Requires-Dist: pydantic==2.11.7
Requires-Dist: faiss-cpu==1.11.0
Requires-Dist: pypdf==5.6.1
Requires-Dist: python-dotenv==1.0.1
Requires-Dist: typing_extensions==4.14.0
Requires-Dist: typing-inspect==0.9.0
Requires-Dist: PyPDF2==3.0.1
Requires-Dist: python-docx==1.2.0
Requires-Dist: openpyxl==3.1.5
Requires-Dist: python-pptx==1.0.2
Requires-Dist: nest-asyncio==1.6.0
Provides-Extra: dev
Requires-Dist: sphinx<9.0.0,>=8.1.3; extra == "dev"
Requires-Dist: sphinx-rtd-theme<4.0.0,>=3.0.1; extra == "dev"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Sonika AI Toolkit <a href="https://pepy.tech/projects/sonika-ai-toolkit"><img src="https://static.pepy.tech/badge/sonika-ai-toolkit" alt="PyPI Downloads"></a>

A robust Python library designed to build state-of-the-art conversational agents and AI tools. It leverages `LangChain` and `LangGraph` to create autonomous bots capable of complex reasoning and tool execution.

## Installation

```bash
pip install sonika-ai-toolkit
```

## Prerequisites

You'll need the following API keys depending on the model you wish to use:

- OpenAI API Key
- DeepSeek API Key (Optional)
- Google Gemini API Key (Optional)
- AWS Bedrock API Key (Optional, for Bedrock)

Create a `.env` file in the root of your project with the following variables:

```env
OPENAI_API_KEY=your_openai_key_here
DEEPSEEK_API_KEY=your_deepseek_key_here
GOOGLE_API_KEY=your_gemini_key_here
AWS_BEARER_TOKEN_BEDROCK=your_bedrock_api_key_here
AWS_REGION=us-east-1
```

## Key Features

- **Multi-Model Support**: Agnostic integration with OpenAI, DeepSeek, Google Gemini, and Amazon Bedrock.
- **Conversational Agent**: Robust agent (`ReactBot`) with native tool execution capabilities and LangGraph state management.
- **Tasker Agent**: Advanced planner-executor agent (`TaskerBot`) for complex multi-step tasks.
- **Structured Classification**: Text classification with strongly typed outputs.
- **Document Processing**: Utilities for processing PDFs, DOCX, and other formats with intelligent chunking.
- **Custom Tools**: Easy integration of custom tools via Pydantic and LangChain.

## Basic Usage

### Conversational Agent with Tools

```python
import os
from dotenv import load_dotenv
from sonika_ai_toolkit.tools.integrations import EmailTool
from sonika_ai_toolkit.agents.react import ReactBot
from sonika_ai_toolkit.utilities.types import Message
from sonika_ai_toolkit.utilities.models import OpenAILanguageModel

# Load environment variables
load_dotenv()

# Configure model
api_key = os.getenv("OPENAI_API_KEY")
language_model = OpenAILanguageModel(api_key, model_name='gpt-4o-mini', temperature=0.7)

# Configure tools
tools = [EmailTool()]

# Create agent instance
bot = ReactBot(language_model, instructions="You are a helpful assistant", tools=tools)

# Get response
user_message = 'Send an email to erley@gmail.com saying hello'
messages = [Message(content="My name is Erley", is_bot=False)]
response = bot.get_response(user_message, messages, logs=[])

print(response["content"])
```

### Text Classification

```python
import os
from sonika_ai_toolkit.classifiers.text import TextClassifier
from sonika_ai_toolkit.utilities.models import OpenAILanguageModel
from pydantic import BaseModel, Field

# Define classification structure
class Classification(BaseModel):
    intention: str = Field()
    sentiment: str = Field(..., enum=["happy", "neutral", "sad", "excited"])

# Initialize classifier
model = OpenAILanguageModel(os.getenv("OPENAI_API_KEY"))
classifier = TextClassifier(llm=model, validation_class=Classification)

# Classify text
result = classifier.classify("I am very happy today!")
print(result.result)
```

## Available Components

### Agents
- **ReactBot**: Standard agent using LangGraph workflow.
- **TaskerBot**: Advanced planner agent for multi-step tasks.

### Utilities
- **ILanguageModel**: Unified interface for LLM providers.
- **DocumentProcessor**: Text extraction and chunking utilities.

## Project Structure

```
src/sonika_ai_toolkit/
├── agents/             # Bot implementations
├── classifiers/        # Text classification tools
├── document_processing/# PDF and document tools
├── tools/             # Tool definitions
└── utilities/         # Models and common types
```

## License

This project is licensed under the MIT License.
