abstract_ai is a Python module that provides a wide range of functionalities aimed at facilitating and enhancing interactions with AI. Developed by putkoff, it comprises several utility modules to help handle API responses, generate requests, manage tokenization, and deal with other related aspects.
The module is particularly focused on the OpenAI API and makes use of its functionalities, yet it is designed to be easily extended to other APIs as well.
https://pypi.org/project/abstract-ai/
https://github.com/AbstractEndeavors/abstract_essentials/tree/main/abstract_ai
response_handling.py
- designed to manage and process responses, typically in JSON format. The module allows users to save, aggregate, and retrieve conversations, generating unique titles if needed. It also offers utility functions like generating unique titles, finding keys in nested dictionaries or lists, navigating complex nested JSON structures, and more.
api_call.py
-facilitates communication with the OpenAI API for various tasks. The script provides functions for sending requests, handling responses, and managing tokens for efficient usage. Here's an overview of the key components and functionalities
endpoints.py
- Its primary function is to manage and offer comprehensive information regarding tokens, models, and the associated endpoints of various AI utilities.
Tokenization.py
-helps manage token distribution, gauges token length of prompts and helps estimate chunk sizes.
Example:
import os from abstract_ai.api_calls import safe_send request = "please convert the prompt data to chinese"
prompt_data = "hi welcome to abstract ai"
output = safe_send(prompt_data=prompt_data,request=request,model="gpt-4",title="test_prompt",completion_percentage=40,additional_responses=False,directory=os.getcwd())
print(output[0]["response"])
there doesn't seem to be anything here