Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
opencompass
Commits
d5d4f473
Unverified
Commit
d5d4f473
authored
Aug 09, 2023
by
Haodong Duan
Committed by
GitHub
Aug 09, 2023
Browse files
[API] Refine OpenAI (#175)
parent
af436f59
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
opencompass/models/openai_api.py
opencompass/models/openai_api.py
+11
-2
No files found.
opencompass/models/openai_api.py
View file @
d5d4f473
...
@@ -80,6 +80,7 @@ class OpenAI(BaseAPIModel):
...
@@ -80,6 +80,7 @@ class OpenAI(BaseAPIModel):
self
.
orgs
=
org
self
.
orgs
=
org
self
.
org_ctr
=
0
self
.
org_ctr
=
0
self
.
url
=
openai_api_base
self
.
url
=
openai_api_base
self
.
path
=
path
def
generate
(
def
generate
(
self
,
self
,
...
@@ -146,9 +147,17 @@ class OpenAI(BaseAPIModel):
...
@@ -146,9 +147,17 @@ class OpenAI(BaseAPIModel):
messages
.
append
(
msg
)
messages
.
append
(
msg
)
# max num token for gpt-3.5-turbo is 4097
# max num token for gpt-3.5-turbo is 4097
context_window
=
4096
if
'32k'
in
self
.
path
:
context_window
=
32768
elif
'16k'
in
self
.
path
:
context_window
=
16384
elif
'gpt-4'
in
self
.
path
:
context_window
=
8192
# Hold out 100 tokens due to potential errors in tiktoken calculation
max_out_len
=
min
(
max_out_len
=
min
(
max_out_len
,
max_out_len
,
context_window
-
self
.
get_token_len
(
str
(
input
))
-
100
)
self
.
max_seq_len
-
50
-
self
.
get_token_len
(
str
(
input
)))
if
max_out_len
<=
0
:
if
max_out_len
<=
0
:
return
''
return
''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment