Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-doerr committed Oct 11, 2021
1 parent 6cd4ca3 commit 01aa64c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

def complete_input_max_length(input_prompt, max_input_length=MAX_SUPPORTED_INPUT_LENGTH, stop=None, max_tokens=64):
input_prompt = input_prompt[-max_input_length:]
response = openai.Completion.create(engine='cushman-codex', prompt=input_prompt, best_of=1, temperature=0.5, max_tokens=max_tokens, stream=USE_STREAM_FEATURE, stop=stop)
response = openai.Completion.create(engine='davinci-codex', prompt=input_prompt, best_of=1, temperature=0.5, max_tokens=max_tokens, stream=USE_STREAM_FEATURE, stop=stop)
return response

def complete_input(input_prompt, stop, max_tokens):
try:
response = complete_input_max_length(input_prompt, int(2.5 * MAX_SUPPORTED_INPUT_LENGTH), stop=stop, max_tokens=max_tokens)
except openai.error.InvalidRequestError:
response = complete_input_max_length(input_prompt, MAX_SUPPORTED_INPUT_LENGTH, stop=stop)
response = complete_input_max_length(input_prompt, MAX_SUPPORTED_INPUT_LENGTH, stop=stop, max_tokens=max_tokens)
print('Using shorter input.')

return response
Expand Down

0 comments on commit 01aa64c

Please sign in to comment.