Skip to main content

Chronology

Chronology is a library that enables users of OpenAI's GPT-3 language model to more easily build complex language-powered applications.

It provides a simple and intuitive interface for working with GPT-3.

We built this at OthersideAI to help mitigate some of the monotonous work we had to do when developing with GPT-3. Our library has the following features:

  • Asynchronously call GPT-3, enabling multiple prompts to generate at the same time
  • Easy creation and modification of prompts
  • Chain prompts together, feeding output from one or multiple prompts into another prompt, allowing for highly-complex systems to be built quickly

We built this library to be as intuitive as possible. There are no complicated concepts to master.

Installation

chronology is hosted on PyPI.

Chronology is supported on Python 3.6 and above.

To install chronology:

pip install chronological

This project also depends on the following packages:

Usage

After you have downloaded the package, create a .env file at the root of your project and put your OpenAI API key in as:

OPENAI_API_KEY = "MY_API_KEY"

You now have a few options. You can use the UI to generate the chain or you can use the API directly.

Using ChronologyUI

Here is a Loom video showing how to use the UI with the Python chronology package.

Using the API Directly

main

Main function that runs logic. Accepts a function implemented on your end!

fetch_max_search_doc

Fetch document value with max score. Wrapper for OpenAI API Search.

Optional:

min_score_cutoff = if maximum score is less than cutoff, None will be returned. Defaults to -1

full_doc = return whole response with max, but doesn't grab doc for you. Defaults to False. [doc, doc.index, doc.score]

raw_completion

Wrapper for OpenAI API completion. Returns raw result from GPT-3.

cleaned_completion

Wrapper for OpenAI API completion. Returns whitespace trimmed result from GPT-3.

gather

Run methods in parallel (they don't need to wait for each other to finish).

Requires method argumets to be async.

Example: await gather(fetch_max_search_doc(query_1, docs), fetch_max_search_doc(query_2, docs))

read_prompt

Looks in prompts/ directory for a text file. Pass in file name only, not extension.

Example: prompts/hello-world.txt -> read_prompt('hello-world')

add_new_lines_start

Add N new lines to the start of a string.

add_new_lines_end

Add N new lines to the end of a string.

append_prompt

Add new content to the end of a string.

prepend_prompt

Add new content to the start of a string.

set_api_key

Set your OpenAI API key in the code.

Contributing

Chronology & ChronologyUI are both open source!

This project is an evolving use case and we welcome any contribution or feedback.

Open Bouties:

  • adding all the fields the OpenAI Python API accepts to Chronology
  • adding a test suite that calls different length chains
  • extending fetch_max_search_doc to have smarter logic around minimium scores
  • make gather run faster, using threads

Learn More

Chronology is the backbone of https://OthersideAI.com. We use it to chain prompt calls and asyncronously call GPT-3. Our application is highly complex, and has many steps. Chronology allows us to parallelize those steps, significantly cutting down the time it takes to generate an email.

To learn more about OthersideAI, take a look at the following resources:

Release files for chronological 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chronological 0.1.1
File Size Uploaded
chronological-0.1.1.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chronological 0.1.1
File Interpreter ABI Platform
chronological-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / chronological-0.1.1.tar.gz

Download URL chronological-0.1.1.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aee2d12fd8846aa430d89777d17d5583f785be2f875505c80291bcef4fc0d95d
BLAKE2b-256 checksum
How to use checksums
ad25bff5d471d2d88f3c0f5317eaeda933ab099e05f172953b7ad8a2e662e42f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.2

Release files / chronological-0.1.1-py3-none-any.whl

Download URL chronological-0.1.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76ff76c35dbc179b9b1fea05bf828b2df86fbcaa14cc2de6d47497eebf5a8ef2
BLAKE2b-256 checksum
How to use checksums
818b5d5386bf9adcb1a19ef59d2f366d1831897e8784f50e19c37f77cc16975e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page