Skip to main content

Toolkit para creación de agentes de IA y procesamiento de documentos

Project description

Sonika AI Toolkit PyPI Downloads

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

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:

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

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

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.

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

sonika_ai_toolkit-0.2.0.tar.gz (54.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sonika_ai_toolkit-0.2.0-py3-none-any.whl (74.7 kB view details)

Uploaded Python 3

File details

Details for the file sonika_ai_toolkit-0.2.0.tar.gz.

File metadata

  • Download URL: sonika_ai_toolkit-0.2.0.tar.gz
  • Upload date:
  • Size: 54.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for sonika_ai_toolkit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 db7b2233110552c937307c8b22d4c337cfd10bcc427756dbe0cd7482027c7269
MD5 b8680bae5bd6470f79c768942358eed1
BLAKE2b-256 5da54f88bbb666d2ad14cd0ab2b974e05083be5f589d9c0676f3af9b26c91bac

See more details on using hashes here.

File details

Details for the file sonika_ai_toolkit-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sonika_ai_toolkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5f3a88da6d5002df4ea488f78c6b52bdd0af26e405ad5fb934e920db72f21b0
MD5 c20407b6af02c0de71a3b58efd15c8e1
BLAKE2b-256 760db1c030e8451ddeff48ee18fef06a7d8ab1ce0eb2955227410696a5201509

See more details on using hashes here.

Supported by

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