mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 14:04:27 +01:00
Consolidate calls to openai
Starting to abstract away the calls to openai
This commit is contained in:
16
scripts/llm_utils.py
Normal file
16
scripts/llm_utils.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import openai
|
||||
from config import Config
|
||||
cfg = Config()
|
||||
|
||||
openai.api_key = cfg.openai_api_key
|
||||
|
||||
# Overly simple abstraction until we create something better
|
||||
def create_chat_completion(messages, model=None, temperature=None, max_tokens=None)->str:
|
||||
response = openai.ChatCompletion.create(
|
||||
model=model,
|
||||
messages=messages,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens
|
||||
)
|
||||
|
||||
return response.choices[0].message["content"]
|
||||
Reference in New Issue
Block a user