mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2024-11-07 18:40:13 +03:00
adapt two types of APIs
This commit is contained in:
parent
48a528aa37
commit
a32733fa27
@ -67,9 +67,12 @@ class OpenAIModel(ModelBackend):
|
||||
num_max_token = num_max_token_map[self.model_type.value]
|
||||
num_max_completion_tokens = num_max_token - num_prompt_tokens
|
||||
self.model_config_dict['max_tokens'] = num_max_completion_tokens
|
||||
response = openai.ChatCompletion.create(*args, **kwargs,
|
||||
model=self.model_type.value,
|
||||
**self.model_config_dict)
|
||||
|
||||
try:
|
||||
response = openai.ChatCompletion.create(*args, **kwargs, model=self.model_type.value, **self.model_config_dict)
|
||||
except AttributeError:
|
||||
response = openai.chat.completions.create(*args, **kwargs, model=self.model_type.value, **self.model_config_dict)
|
||||
|
||||
cost = prompt_cost(
|
||||
self.model_type.value,
|
||||
num_prompt_tokens=response["usage"]["prompt_tokens"],
|
||||
|
Loading…
Reference in New Issue
Block a user