refactor initialization of openai into main

This commit is contained in:
Paul Gauthier 2023-07-11 15:06:50 -07:00
parent fa3283802a
commit 084132a5f8
2 changed files with 12 additions and 11 deletions

View file

@ -53,8 +53,6 @@ class Coder:
main_model,
edit_format,
io,
openai_api_key,
openai_api_base="https://api.openai.com/v1",
**kwargs,
):
from . import (
@ -65,9 +63,6 @@ class Coder:
WholeFileFunctionCoder,
)
openai.api_key = openai_api_key
openai.api_base = openai_api_base
if not main_model:
main_model = models.GPT35_16k
@ -629,6 +624,8 @@ class Coder:
)
if functions is not None:
kwargs["functions"] = self.functions
if hasattr(openai, "api_deployment_id"):
kwargs["deployment_id"] = openai.api_deployment_id
# Generate SHA1 hash of kwargs and append it to chat_completion_call_hashes
hash_object = hashlib.sha1(json.dumps(kwargs, sort_keys=True).encode())