Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling errors in ollama-js #92

Open
ejgutierrez74 opened this issue May 17, 2024 · 1 comment
Open

Handling errors in ollama-js #92

ejgutierrez74 opened this issue May 17, 2024 · 1 comment

Comments

@ejgutierrez74
Copy link

Hi reading docs from openai i can find a quite complete error handling:
https://help.openai.com/en/articles/6897213-openai-library-error-types-guidance

You can see the more complete code, i think is in python:

try:
  #Make your OpenAI API request here
  response = openai.Completion.create(model="text-davinci-003",                     
              prompt="Hello world")
except openai.error.Timeout as e:
  #Handle timeout error, e.g. retry or log
  print(f"OpenAI API request timed out: {e}")
  pass
except openai.error.APIError as e:
  #Handle API error, e.g. retry or log
  print(f"OpenAI API returned an API Error: {e}")
  pass
except openai.error.APIConnectionError as e:
  #Handle connection error, e.g. check network or log
  print(f"OpenAI API request failed to connect: {e}")
  pass
except openai.error.InvalidRequestError as e:
  #Handle invalid request error, e.g. validate parameters or log
  print(f"OpenAI API request was invalid: {e}")
  pass
except openai.error.AuthenticationError as e:
  #Handle authentication error, e.g. check credentials or log
  print(f"OpenAI API request was not authorized: {e}")
  pass
except openai.error.PermissionError as e:
  #Handle permission error, e.g. check scope or log
  print(f"OpenAI API request was not permitted: {e}")
  pass
except openai.error.RateLimitError as e:
  #Handle rate limit error, e.g. wait or log
  print(f"OpenAI API request exceeded rate limit: {e}")
  pass

So is there any similar to ollama.js....im interested in giving feedback to the Chatbot user, set some Timeout to cancel a request if timeout exceeds, and giving some suggestions ( ex: Ratelimit error user passed their limits, wait some time or pay for more limits, connectionError perhpaps internet connection is not right or disabled....)

Thanks in advance

@ejgutierrez74
Copy link
Author

Im interested in both sides: "pure" ollama.js and openai compatible ollama js library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant