An avahiai library which makes your Gen-AI tasks effortless
Project description
AvahiAI
Logicsdk is an open source AI framework to build with LLMs on AWS Bedrock. Turn your enterprise use cases into production application in few lines of python code
Quickstart
Installation
You can install logic just by running:
! pip install logicsdk
import logicsdk
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("This is a test string to summarize.")
print("Summary:", summarization_output)
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("This is a test string for the extraction.")
print("Extraction:", extraction_output)
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("This is a test string to for the Data Masking.")
print("DataMasking:", masking_output)
current Features
- Summarize plain text.
- Summarize text from local files (
.txt
,.pdf
,.docx
). - Summarize text from S3 files (
.txt
,.pdf
,.docx
). - Extract the entities from plain text.
- Extract the entities from from local files (
.txt
,.pdf
,.docx
). - Extract the entities from from S3 files (
.txt
,.pdf
,.docx
). - Mask the entities from the plain text.
- Mask the entities from text from local files (
.txt
,.pdf
,.docx
). - Mask the entities from the text from S3 files (
.txt
,.pdf
,.docx
). - Support for custom prompts and different anthropic claude model versions.
- Error handling with user-friendly messages.
- And many more to come...
AWS CLI Installation (Optional but Recommended)
To configure your AWS credentials easily, you can use the AWS CLI. Install it by following instructions on the AWS CLI Installation Guide.
Configuration
AWS Credentials
AvahiAI requires AWS credentials to access AWS Bedrock and S3 services. You can provide your AWS credentials in two ways:
- Default AWS Credentials: Ensure your AWS credentials are configured in the
~/.aws/credentials
file or by using the AWS CLI. - Explicit AWS Credentials: Pass the AWS Access Key and Secret Key when calling the
summarize
function.
Configuring AWS Credentials Using AWS CLI
After installing the AWS CLI, run the following command to configure your credentials:
aws configure
You will be prompted to enter your AWS Access Key ID, Secret Access Key, region, and output format. This will create or update the ~/.aws/credentials
file with your credentials.
Sample ~/.aws/credentials
File:
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
Usage
Importing logicsdk
import logicsdk
Summarizing Text Strings
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("This is a test string to summarize.")
print("Summary:", summarization_output)
print("Input Cost:", input_token_cost)
print("Output Cost:", output_token_cost)
print("Cost:", total_cost)
Summarization
Summarizing Local Files
Text File (.txt
)
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("path/to/your/file.txt")
print("Summary:", summarization_output)
PDF File (.pdf
)
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("path/to/your/file.pdf")
print("Summary:", summarization_output)
DOCX File (.docx
)
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("path/to/your/file.docx")
print("Summary:", summarization_output)
Summarizing Files from S3
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("s3://your-bucket-name/your-file.pdf", aws_access_key_id="your_access_key", aws_secret_access_key="your_secret_key")
print("Summary:", summarization_output)
Changing the Default Model
summarization_output, input_token_cost, output_token_cost, total_cost = logicsdk.summarize("path/to/your/file.docx", model_name="haiku-3.0")
print("Summary:", summarization_output)
Extraction
Extracting from Strings
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("This is a test string to for the extraction.")
print("Extraction:", extraction_output)
print("Input Cost:", input_token_cost)
print("Output Cost:", output_token_cost)
print("Cost:", total_cost)
Extracting from Local Files
Text File (.txt
)
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("path/to/your/file.txt")
print("Extraction:", extraction_output)
PDF File (.pdf
)
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("path/to/your/file.pdf")
print("Extraction:", extraction_output)
DOCX File (.docx
)
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("path/to/your/file.docx")
print("Extraction:", extraction_output)
Extracting from Files in S3
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("s3://your-bucket-name/your-file.pdf", aws_access_key_id="your_access_key", aws_secret_access_key="your_secret_key")
print("Extraction:", extraction_output)
Changing the Default Model
extraction_output, input_token_cost, output_token_cost, total_cost = logicsdk.structredExtraction("path/to/your/file.docx", model_name="haiku-3.0")
print("Extraction:", extraction_output)
Data Masking
Extracting from Strings
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("This is a test string to for the Data Masking.")
print("DataMasking:", masking_output)
print("Input Cost:", input_token_cost)
print("Output Cost:", output_token_cost)
print("Cost:", total_cost)
DataMasking from Local Files
Text File (.txt
)
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("path/to/your/file.txt")
print("DataMasking:", masking_output)
PDF File (.pdf
)
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("path/to/your/file.pdf")
print("DataMasking:", masking_output)
DOCX File (.docx
)
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("path/to/your/file.docx")
print("DataMasking:", masking_output)
DataMasking from Files in S3
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("s3://your-bucket-name/your-file.pdf", aws_access_key_id="your_access_key", aws_secret_access_key="your_secret_key")
print("DataMasking:", masking_output)
### Changing the Default Model
```python
masking_output, input_token_cost, output_token_cost, total_cost = logicsdk.DataMasking("path/to/your/file.docx", model_name="haiku-3.0")
print("DataMasking:", masking_output)
Other more Gen-ai task to come
Error Handling
AvahiAI provides user-friendly error messages for common issues. Here are some common errors you might encounter:
- Invalid AWS Credentials
AWS credentials are not set or invalid. Please configure your AWS credentials.
- File Not Found
The file at path/to/your/file.pdf does not exist. Please check the file path.
- Unexpected Errors
An unexpected error occurred: <error message>.
Contributing
Feel free to open issues or submit pull requests if you find bugs or have features to add.
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
Built Distribution
File details
Details for the file logicsdk-0.0.8.tar.gz
.
File metadata
- Download URL: logicsdk-0.0.8.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f259458818ea94a5c7b07ad652c75a08871173095791dd0010dfd4e420201992 |
|
MD5 | 189970a558595f59530db2c419ac389d |
|
BLAKE2b-256 | b91d2a6dc8eac164b1535d47c2c537077d779709e84c59b7f85a526069e28da9 |
File details
Details for the file logicsdk-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: logicsdk-0.0.8-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0019b7b0a043b539e510f771157bd4fe93c7354fe44ed220453bd4b056a128e |
|
MD5 | 68595ae517e5535e9f92d776891d0b03 |
|
BLAKE2b-256 | 5f1f697b3c7023db034d62087b86aa940222c6c03bebbbac89746a5522d1482e |