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

@@ -1,4 +1,5 @@
import openai
from llm_utils import create_chat_completion
next_key = 0
agents = {} # key, (task, full_message_history, model)
@@ -13,13 +14,11 @@ def create_agent(task, prompt, model):
messages = [{"role": "user", "content": prompt}, ]
# Start GTP3 instance
response = openai.ChatCompletion.create(
agent_reply = create_chat_completion(
model=model,
messages=messages,
)
agent_reply = response.choices[0].message["content"]
# Update full message history
messages.append({"role": "assistant", "content": agent_reply})
@@ -42,14 +41,11 @@ def message_agent(key, message):
messages.append({"role": "user", "content": message})
# Start GTP3 instance
response = openai.ChatCompletion.create(
agent_reply = create_chat_completion(
model=model,
messages=messages,
)
# Get agent response
agent_reply = response.choices[0].message["content"]
# Update full message history
messages.append({"role": "assistant", "content": agent_reply})