{"id":14065100,"url":"https://github.com/OthersideAI/chronology","last_synced_at":"2025-07-29T20:30:55.467Z","repository":{"id":45319080,"uuid":"325112670","full_name":"OthersideAI/chronology","owner":"OthersideAI","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-22T11:02:59.000Z","size":46,"stargazers_count":860,"open_issues_count":12,"forks_count":190,"subscribers_count":39,"default_branch":"main","last_synced_at":"2024-04-28T04:43:44.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OthersideAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-28T20:42:16.000Z","updated_at":"2024-05-27T23:18:27.067Z","dependencies_parsed_at":"2022-08-12T11:51:39.110Z","dependency_job_id":"5df3a12d-cde9-46fc-a8ed-ce12b96bddd9","html_url":"https://github.com/OthersideAI/chronology","commit_stats":{"total_commits":45,"total_committers":6,"mean_commits":7.5,"dds":0.5777777777777777,"last_synced_commit":"7195f81cd6091153aa8aca5c5e6e1f6e2c7dcc4f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OthersideAI%2Fchronology","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OthersideAI%2Fchronology/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OthersideAI%2Fchronology/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OthersideAI%2Fchronology/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OthersideAI","download_url":"https://codeload.github.com/OthersideAI/chronology/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228046060,"owners_count":17861086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:04:17.966Z","updated_at":"2024-12-04T04:30:44.132Z","avatar_url":"https://github.com/OthersideAI.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Chronology\n\nChronology is a library that enables users of OpenAI's GPT-3 language model to more easily build complex language-powered applications. \n\nIt provides a simple and intuitive interface for working with GPT-3.\n\nWe 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:\n\n- Asynchronously call GPT-3, enabling multiple prompts to generate at the same time\n- Easy creation and modification of prompts\n- Chain prompts together, feeding output from one or multiple prompts into another prompt, allowing for highly-complex systems to be built quickly\n\nWe built this library to be as intuitive as possible. There are no complicated concepts to master.\n\n# Installation\n\nchronology is hosted on PyPI.\n\nChronology is supported on Python 3.6 and above.\n\nTo install chronology:\n\n`pip install chronological`\n\nThis project also depends on the following packages: \n* [`openai-api`](https://github.com/openai/openai-python)\n* [`python-dotenv`](https://pypi.org/project/python-dotenv/)\n* [`loguru`](https://github.com/Delgan/loguru)\n* [`asyncio`](https://docs.python.org/3/library/asyncio.html)\n\n# Usage\n\nAfter you have downloaded the package, create a `.env` file at the root of your project and put your OpenAI API key in as:\n\n`OPENAI_API_KEY = \"MY_API_KEY\"`\n\nYou now have a few options. You can use the UI to generate the chain or you can use the API directly.\n\n## [Using ChronologyUI](https://github.com/OthersideAI/chronology-ui)\n\nHere is a [Loom video](https://www.loom.com/share/47cb8d328ebd446db4d98ea1c0cac2c7?sharedAppSource=personal_library) showing how to use the UI with the Python [`chronology`](https://github.com/OthersideAI/chronology) package.\n\n## Using the API Directly\n\n### [`main`](#main)\n\nThe `main` function is an async function that holds all of your business logic. You then invoke this logic by passing it as an argument to `main`. **Required**\n\n## Example:\n\n```\n# you can name this function anything you want, the name \"logic\" is arbitrary\nasync def logic():\n    # you call the Chronology functions, awaiting the ones that are marked await\n    prompt = read_prompt('example_prompt')\n    completion = await cleaned_completion(prompt, max_tokens=100, engine=\"davinci\", temperature=0.5, top_p=1, frequency_penalty=0.2, stop=[\"\\n\\n\"])\n\n    print('Completion Response: {0}'.format(completion))\n    \n    # you can also run whatever you want in this function\n    for i in range(4):\n     print(\"hello\")\n\n\n# invoke the Chronology main fn to run the async logic\nmain(logic)\n```\n\n### [`fetch_max_search_doc`](#fetch_max_search_doc)\n####  **Must be awaited**\n\nFetch document value with max score. Wrapper for OpenAI API Search. \n\nOptional:\n\nmin_score_cutoff = if maximum score is less than cutoff, None will be returned. Defaults to -1\n\nfull_doc = return whole response with max, but doesn't grab doc for you. Defaults to False. [doc, doc.index, doc.score]\n\n### [`raw_completion`](#raw_completion)\n####  **Must be awaited**\n\nWrapper for OpenAI API completion. Returns raw result from GPT-3.\n\n### [`cleaned_completion`](#cleaned_completion)\n####  **Must be awaited**\n\nWrapper for OpenAI API completion. Returns whitespace trimmed result from GPT-3.\n\n### [`gather`](#gather)\n####  **Must be awaited**\n\nRun methods in parallel (they don't need to wait for each other to finish).\n\nRequires method argumets to be async.\n\nExample: await gather(fetch_max_search_doc(query_1, docs), fetch_max_search_doc(query_2, docs))\n\n### [`read_prompt`](#read_prompt)\n\nLooks in prompts/ directory for a text file. Pass in file name only, not extension.\n\nExample: prompts/hello-world.txt -\u003e read_prompt('hello-world')\n\n\n### [`add_new_lines_start`](#add_new_lines_start)\n\nAdd N new lines to the start of a string.\n\n### [`add_new_lines_end`](#add_new_lines_end)\n\nAdd N new lines to the end of a string.\n\n### [`append_prompt`](#append_prompt)\n\nAdd new content to the end of a string.\n\n### [`prepend_prompt`](#prepend_prompt)\n\nAdd new content to the start of a string.\n\n### [`set_api_key`](#set_api_key)\n\nSet your OpenAI API key in the code.\n\n## Contributing\n\nChronology \u0026 ChronologyUI are both open source!\n\nThis project is an evolving use case and we welcome any contribution or feedback.\n\n### Open Bouties: \n\n- [ ] adding all the fields the OpenAI Python API accepts to Chronology\n- [ ] adding a test suite that calls different length chains\n- [ ] extending `fetch_max_search_doc` to have smarter logic around minimium scores \n- [ ] make `gather` run faster, using [threads](https://docs.python.org/3/library/asyncio-task.html#running-in-threads)\n\n## Learn More\n\nChronology 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.\n\nTo learn more about OthersideAI, take a look at the following resources:\n\n- [Our Homepage](https://www.othersideai.com/)\n- [Our Twitter](https://twitter.com/othersideai)\n\nContact: info@othersideai.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOthersideAI%2Fchronology","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOthersideAI%2Fchronology","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOthersideAI%2Fchronology/lists"}