An avahiai library which makes your Gen-AI tasks effortless
Project description
AvahiAI
logicai is a user-friendly library that simplifies many Gen-AI tasks using AWS Bedrock.
current Features
- Summarize plain text.
- Summarize text from local files (
.txt
,.pdf
,.docx
). - Summarize 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...
Installation
You can install logic just by running:
pip install logicai
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 AvahiAI
import logicai
Summarizing Text Strings
summarization_output, input_token_cost, output_token_cost, total_cost = avahiai.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 = avahiai.summarize("path/to/your/file.txt")
print("Summary:", summarization_output)
PDF File (.pdf
)
summarization_output, input_token_cost, output_token_cost, total_cost = avahiai.summarize("path/to/your/file.pdf")
print("Summary:", summarization_output)
DOCX File (.docx
)
summarization_output, input_token_cost, output_token_cost, total_cost = avahiai.summarize("path/to/your/file.docx")
print("Summary:", summarization_output)
Summarizing Files from S3
summarization_output, input_token_cost, output_token_cost, total_cost = avahiai.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)
Using a Custom Prompt
custom_prompt = "Please summarize the following document."
summarization_output, input_token_cost, output_token_cost, total_cost = avahiai.summarize("path/to/your/file.docx", user_prompt=custom_prompt)
print("Summary:", summarization_output)
Changing the Default Model
summarization_output, input_token_cost, output_token_cost, total_cost = avahiai.summarize("path/to/your/file.docx", model_name="haiku-3.0")
print("Summary:", summarization_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.1.tar.gz
.
File metadata
- Download URL: logicsdk-0.0.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82a3df9c7a41cebdb5eb85612c02f7a9ead984159d0290114ce70dc8ce7a2d5e |
|
MD5 | 3f0ae308e437f3792a5ba146869fd9d4 |
|
BLAKE2b-256 | d2459d1c6e43e475da63d1b633e5dc9d90c52f01d55594168e92c38af90b0649 |
File details
Details for the file logicsdk-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: logicsdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 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 | cf1bc1c858f8d0e0c29dd40665349ae3cba0c88ac6843b19f1eb7f312856cf0f |
|
MD5 | 31d291ffd21d13eba69d4608b02f6649 |
|
BLAKE2b-256 | bb276aafd404b75ac4d636be2fddb7b84ea06faec9f43d1676360e558207d997 |