Skip to main content

Templates for prompt and vector db engineering and easy to call OpenAI functions with spend tracking and error handling!

Project description

aitemplates

aitemplates is a Python package designed to simplify and streamline your work with the OpenAI API. It provides Python typing support, error checking, and a usage meter to help manage API costs. Additionally, aitemplates offers built-in examples of using ChromaDB and tools for efficient prompt engineering with OpenAI.

Features

  • Python Typing Support: Enjoy the benefits of Python's dynamic typing system while using OpenAI API.
  • Error Checking: Automatically catch and handle errors during API calls.
  • Usage Meter: Keep track of your OpenAI API usage with a built-in metering system.
  • ChromaDB Integration: Work directly with ChromaDB from the aitemplates interface.
  • Asynchronous Chat Completions: Use the -asnc flag to run asynchronous chat completions. The built-in print_every option prints every time a completion finishes in parallel. If a list is passed into the response_list attribute, it updates that list as completions finish. If you'd like to maintain the order of your completions, pass in the keep_order boolean as True.
  • Prompt Engineering Examples: Get started quickly with included examples of prompt engineering techniques.

Installation

You can install aitemplates directly from PyPI:

pip install aitemplates

To get the latest version of the package, you can also clone the repository and install the package by running pip install -e . in the repository directory.

Creating Jupyter Notebook Templates

Create Jupyter notebook templates for prompt engineering with the following command:

aitemplates name_of_notebook

Include a Chroma database in the template with the -db flag:

aitemplates name_of_notebook -db

For asynchronous chat completions, add the -asnc flag:

aitemplates name_of_notebook -db -asnc

Documentation

The package includes example notebooks, which provide comprehensive guides and demonstrations of the functionalities provided by aitemplates. To access these notebooks, clone the repository and navigate to the /notebooks directory.

Here are the available notebooks:

  • oai_examples.ipynb: Provides examples for the OpenAI API.
  • chroma_examples.ipynb: Demonstrates usage of ChromaDB.
  • prompt_engineering_example.ipynb: A comprehensive guide on prompt engineering, including various techniques, usage of ChromaDB and the OpenAI library together.

Requirements

  • Be sure to have a .env file with the OPENAI_API_KEY defined in the root of your project. AWS env variables are for ChromaDB deployment https://docs.trychroma.com/deployment
  • This library doesn't currently support the use of top-p and text models like text-davinci-003. Streaming and logit_bias parameters are not supported

Contributing

I'd welcome and appreciate contributions to aitemplates. If you'd like to contribute a feature, please submit a pull request. For bugs, please open a new issue, and I'll address it promptly.

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

aitemplates-0.1.2.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

aitemplates-0.1.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file aitemplates-0.1.2.tar.gz.

File metadata

  • Download URL: aitemplates-0.1.2.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.13 Windows/10

File hashes

Hashes for aitemplates-0.1.2.tar.gz
Algorithm Hash digest
SHA256 75b78895158cb9d8a458f90f22a9fd20cad57edb836d74e16f7a6ef924e33656
MD5 fe8e6fc31320d3528d8d104d59bdcb57
BLAKE2b-256 459d4a53268bd35b39c34649f4f1aba6a6f4a1d74ae452ea07360204bbb02108

See more details on using hashes here.

File details

Details for the file aitemplates-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: aitemplates-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.9.13 Windows/10

File hashes

Hashes for aitemplates-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c8777da5758cdc19062360e272d3a2308b8afb6d741a19ec248674459d24eeb8
MD5 559ae8de40f03b8b9bdd13cf74b28e2b
BLAKE2b-256 be9c704a35dbd96262a2f044cfbfa64bed56255fa0f6a2d637965aed530cd71d

See more details on using hashes here.

Supported by

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