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

Adding re-raise flag at OpenAI Agent level #12674

Conversation

LMartinezEXEX
Copy link
Contributor

Description

Added raise_error congif argument at an Agent level in the OpenAI Agent class to allow the re-raise of exception when needed (an implemented feature, although not end-to-end).

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added new unit/integration tests
  • Added new notebook (that tests end-to-end)
  • I stared at the code and made sure it makes sense

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added Google Colab support for the newly added notebooks.
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I ran make format; make lint to appease the lint gods

…t to allow the re-raise of exception when needed.
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 9, 2024
@LMartinezEXEX
Copy link
Contributor Author

I see some checks failed due to a 503 Service Unavailable, any idea why or if this is a regular situation? I am not able to re-trigger the failed checks.

Copy link

@santimarro santimarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -54,6 +54,7 @@ def __init__(
verbose: bool = False,
max_function_calls: int = DEFAULT_MAX_FUNCTION_CALLS,
default_tool_choice: str = "auto",
raise_error: bool = False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My general feedback is this arg is pretty generic, but its actual use only covers one very specific use-case, which is kind of misleading

Is there any way we can think of to improve this? A better name? Handle more scenarios where errors are caught?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please double check the unit tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Logan! Thank you for the comments! :)

So regarding this feature, absolutely! I understand there are multiple places where exceptions are raised which are captured by llama-index code.
This was motivated by Azure filtering error exception while streaming, I needed to capture in my side the exception.

I noticed the functionality (i.e. the flag to re-reaise the exception) was there, although not end-to-end implemented.
My main objective was to introduce the parameter at an Agent level, as this was recommended in a thread in Discord.

I'm no expert of the whole llama-index codebase, but I am sure that with this small step, any other in need of this kind of feature will be able to adjust, in future PRs, the code to get exception in particular scenarios if they need!

Regarding the naming of the variable at an Agent level, wdyt of capture_exception or rethrow_exception, to be more explicit of not an error, but an exception.

And to finish, I checked the unit tests, they neither pass in the main branch (at least on my setup). I would take a look.

Please let me know about your thought on this! ✨

@logan-markewich
Copy link
Collaborator

In order to avoid hiding actual errors, I've removed this option altogether, and errors will always be raised.

Going to close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants