Home

Awesome

batched-chatgpt

Extremely easy-to-use ChatGPT batched API caller.
It only supports single turn conversation!

Installation

pip install batched-chatgpt

Quickstart

It requires OPENAI_API_KEY in your environment variable.

export OPENAI_API_KEY=<your_api_key>

Or in python code,

import os
os.environ['OPENAI_API_KEY'] = "<your_api_key>"

Simple version

from batched_chatgpt import call_chatgpt

resp = call_chatgpt(
    human_message=PROMPTS,  # list of str
)

Features

Need more customization?

from batched_chatgpt import call_chatgpt

resp = call_chatgpt(
    human_message=PROMPTS,  # list of str
    system_message=['You are a helpful assistant.'] * len(prompts),
    model_name=CHATGPT_VERSION_NAME,  # default is 'gpt-3.5-turbo'
    temperature=TEMPERATURE,  # default 0.0
    chunk_size=CONCURRENCY_NUM,
    timeout_each=TIMEOUT_EACH,
    sleep_between_chunk=SLEEP_BETWEEN_CHUNK,
    pkl_path=file_dir,  # ex) "result.pkl'
    verbose=True
)

Requirements