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

provide a bit more info in logs when parsing api schema error #3026

Merged
merged 3 commits into from Mar 30, 2024

Conversation

LeoQuote
Copy link
Contributor

@LeoQuote LeoQuote commented Mar 28, 2024

When parse error, neither user nor admin can get decent error messages, just invalid schema, this is confusing and frustrating, adding a bit more logs could be a good start.

Description

Fixes #2914

  1. print error message when there are exceptions
  2. raise Exception when parse error
  3. delete unused functions

Type of Change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Just a bit code about logging, need no further tests

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • optional I have made corresponding changes to the documentation
  • optional I have added tests that prove my fix is effective or that my feature works
  • optional New and existing unit tests pass locally with my changes

When parse error, neither user nor admin can get decent error messages, just `invalid schema`, this is confusing and frustrating, adding a bit more logs could be a good start.
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 28, 2024
@Yeuoly
Copy link
Collaborator

Yeuoly commented Mar 29, 2024

Looks great! Indeed, as you said, there should be a detailed error report here, and for a further experience, I recommend add the logger here: core.tools.utils.parser.ApiBasedToolSchemaParser.auto_parser_to_tool_bundle, it tries to parse schema in 5 methods, if there is an error, try next, however, the exception was not raised, place the logger in every try could be better.

@LeoQuote
Copy link
Contributor Author

hmm, ok, you mean even if I added this logger, the output log would still be very vague.

I think the parsing process should be seperated into several part:

  1. try to identify it's yaml or json, if yaml, convert it to json. if it's neither json nor yaml, raise exception
  2. parse it using openai and swagger, if there's any exception, append to the exception
  3. if reached the bottom, meaning all parse failed, raise an exception contains all previous exception.

Considering the users who using this function would know a bit about there api, I'd advice support one schema only or let the user specify schema type, so the error would be much simpler, but this needs more discussion, maybe next pr or someone else do that.

@crazywoola crazywoola requested a review from Yeuoly March 29, 2024 05:12
crazywoola
crazywoola previously approved these changes Mar 29, 2024
@dosubot dosubot bot added the 🌞 lgtm This PR has been approved by a maintainer label Mar 29, 2024
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Mar 29, 2024
Copy link
Collaborator

@Yeuoly Yeuoly left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 29, 2024
@crazywoola crazywoola merged commit fc5ed17 into langgenius:main Mar 30, 2024
7 checks passed
@LeoQuote LeoQuote deleted the patch-1 branch March 30, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌞 lgtm This PR has been approved by a maintainer lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to add tool using openapi schema provided by fastapi
3 participants