Skip to content

Commit

Permalink
update openai access
Browse files Browse the repository at this point in the history
  • Loading branch information
qhduan committed Apr 4, 2024
1 parent 0f53686 commit 4d9fcbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cn_chat_arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from tqdm.auto import tqdm
from pebble import concurrent, ProcessPool


if os.environ.get('OPENAI_AZURE_BASE') is not None:
openai.api_base = os.environ.get('OPENAI_AZURE_BASE')
openai.api_key = os.environ.get('OPENAI_AZURE_API_KEY')
Expand All @@ -25,6 +24,11 @@
openai.api_type = "azure"
elif os.environ.get('OPENAI_API_KEY') is not None:
openai.api_key = os.environ.get('OPENAI_API_KEY')
if os.environ.get('OPENAI_API_BASE') is not None:
openai.api_base = os.environ.get('OPENAI_API_BASE')
openai_model = "gpt-3.5-turbo"
if os.environ.get('OPENAI_API_MODEL') is not None:
openai_model = os.environ.get('OPENAI_API_MODEL')
else:
print('Please set OPENAI_API_KEY or OPENAI_AZURE_API_KEY and OPENAI_AZURE_BASE')
exit(1)
Expand Down Expand Up @@ -82,7 +86,7 @@ def call_chat(context):
prompt = deepcopy(prompt_temp_openai)
prompt[-1]['content'] = context
ret = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
model=openai_model,
messages=prompt
)
answer = ret['choices'][0]['message']['content']
Expand Down

0 comments on commit 4d9fcbd

Please sign in to comment.