unify annotations to future syntax

This commit is contained in:
jayceslesar
2023-04-16 14:02:48 -04:00
parent 35175fc19b
commit 8990911522
19 changed files with 83 additions and 60 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from ast import List
import time
from typing import Dict, Optional
import openai
from openai.error import APIError, RateLimitError
@@ -14,7 +15,7 @@ openai.api_key = CFG.openai_api_key
def call_ai_function(
function: str, args: List, description: str, model: Optional[str] = None
function: str, args: list, description: str, model: str | None = None
) -> str:
"""Call an AI function
@@ -51,15 +52,15 @@ def call_ai_function(
# Overly simple abstraction until we create something better
# simple retry mechanism when getting a rate error or a bad gateway
def create_chat_completion(
messages: List, # type: ignore
model: Optional[str] = None,
messages: list, # type: ignore
model: str | None = None,
temperature: float = CFG.temperature,
max_tokens: Optional[int] = None,
max_tokens: int | None = None,
) -> str:
"""Create a chat completion using the OpenAI API
Args:
messages (List[Dict[str, str]]): The messages to send to the chat completion
messages (list[dict[str, str]]): The messages to send to the chat completion
model (str, optional): The model to use. Defaults to None.
temperature (float, optional): The temperature to use. Defaults to 0.9.
max_tokens (int, optional): The max tokens to use. Defaults to None.