Skip to content

Commit

Permalink
bump openai dmMaze#704
Browse files Browse the repository at this point in the history
  • Loading branch information
dmMaze committed Jan 9, 2025
1 parent 23b962a commit a97a774
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions modules/translators/trans_chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,16 @@ def _request_translation_with_chat_sample(self, prompt: str, model: str, chat_sa
'messages': messages,
'temperature': self.temperature,
'top_p': self.top_p,
'frequency_penalty': self.params['frequency penalty'],
'presence_penalty ': self.params['presence penalty']
}
max_tokens = self.max_tokens // 2 # Assuming that half of the tokens are used for the query
func_parameters = inspect.signature(openai.chat.completions.create).parameters
if 'max_completion_tokens' in func_parameters:
func_args['max_completion_tokens'] = max_tokens
else:
func_args['max_tokens'] = max_tokens
if 'presence_penalty' in func_parameters:
func_args['presence_penalty'] = self.params['presence penalty']
func_args['frequency_penalty'] = self.params['frequency penalty']

if OPENAPI_V1_API:
openai_chatcompletions_create = openai.chat.completions.create
Expand Down
5 changes: 3 additions & 2 deletions modules/translators/trans_chatgpt_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,16 @@ def _request_translation_with_chat_sample(self, prompt: str, model: str) -> str:
'messages': messages,
'temperature': self.temperature,
'top_p': self.top_p,
'frequency_penalty': self.params['frequency penalty'],
'presence_penalty ': self.params['presence penalty']
}
max_tokens = self.max_tokens // 2 # Assuming that half of the tokens are used for the query
func_parameters = inspect.signature(openai.chat.completions.create).parameters
if 'max_completion_tokens' in func_parameters:
func_args['max_completion_tokens'] = max_tokens
else:
func_args['max_tokens'] = max_tokens
if 'presence_penalty' in func_parameters:
func_args['presence_penalty'] = self.params['presence penalty']
func_args['frequency_penalty'] = self.params['frequency penalty']

if OPENAPI_V1_API:
openai_chatcompletions_create = openai.chat.completions.create
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ requests
Pillow>=10.0.1
beautifulsoup4
colorama
openai
openai>=1.59.5
pyyaml
natsort
py7zr
Expand Down

0 comments on commit a97a774

Please sign in to comment.