-
Notifications
You must be signed in to change notification settings - Fork 1
/
openai_utils.py
28 lines (28 loc) · 1.04 KB
/
openai_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
if os.environ.get('OPENAI_API_TYPE', None) == 'azure':
# pip install openai<=0.28.1, fire, numpy, tiktoken
from .openai_utils_azure import (
openai_completions,
_prompt_to_chatml,
_chatml_to_prompt,
)
import openai
assert openai.VERSION <= "0.28.1", "Azure API is only supported in openai-python 0.28.1 or later."
elif os.environ.get('OPENAI_UTILS_TYPE', None) == 'curl':
# pip install openai>=1.0.0, fire, numpy, tiktoken
from .openai_utils_curl import (
openai_completions,
_prompt_to_chatml,
_chatml_to_prompt,
)
import openai
assert openai.VERSION >= "1.0.0", "OpenAI API is only supported in openai-python 1.0.0 or later."
else:
# pip install openai>=1.0.0, fire, numpy, tiktoken
from .openai_utils_openAI import (
openai_completions,
_prompt_to_chatml,
_chatml_to_prompt,
)
import openai
assert openai.VERSION >= "1.0.0", "OpenAI API is only supported in openai-python 1.0.0 or later."