INNER CODE UNIT · Python

complete_chat

bsilverthorn/maccarone · src/maccarone/openai.py:21

def complete_chat(
        messages: List[Dict[str, str]],
        model="gpt-4",
        on_token: Callable[[int], None] = lambda p: None,
    ) -> str:
    helicone_key = os.getenv("HELICONE_API_KEY")

    if helicone_key is None:
        headers = {}
    else:
        headers={"Helicone-Auth": helicone_key}

    responses = cast(
        Iterable[ChatCompletion],
        ChatCompletion.create(
            model=model,
            messages=messages,
            stream=True,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…