Consolidate calls to openai

Starting to abstract away the calls to openai
This commit is contained in:
Taylor Brown
2023-04-02 21:51:07 -05:00
parent 744c5fa25b
commit ae9448cb89
5 changed files with 29 additions and 17 deletions

View File

@@ -3,6 +3,8 @@ import openai
from config import Config
cfg = Config()
from llm_utils import create_chat_completion
# This is a magic function that can do anything with no-code. See
# https://github.com/Torantulino/AI-Functions for more info.
def call_ai_function(function, args, description, model=cfg.smart_llm_model):
@@ -18,8 +20,8 @@ def call_ai_function(function, args, description, model=cfg.smart_llm_model):
{"role": "user", "content": args},
]
response = openai.ChatCompletion.create(
response = create_chat_completion(
model=model, messages=messages, temperature=0
)
return response.choices[0].message["content"]
return response