-
Notifications
You must be signed in to change notification settings - Fork 114
fix: remove wrapping double-quotes from GCP guided_regex #1402
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Sukumar Gaonkar <[email protected]>
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (78.63%) is below the target coverage (86.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1402 +/- ##
==========================================
+ Coverage 78.61% 78.63% +0.02%
==========================================
Files 139 139
Lines 13745 13763 +18
==========================================
+ Hits 10805 10823 +18
Misses 2285 2285
Partials 655 655 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Sukumar Gaonkar <[email protected]>
| // This causes the response to be wrapped in double-quotes. | ||
| // E.g. `"positive"` (the double-quotes at the start and end are unwanted) | ||
| // Here we remove the wrapping double-quotes. | ||
| if len(part.Text) > 2 && part.Text[0] == '"' && part.Text[len(part.Text)-1] == '"' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious whether there's a reason to not use strings.Trim() here: https://pkg.go.dev/strings#Trim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch,
mainly being defensive for scenarios where first and last words are quoted but not connected
"ERROR" Unable to connect to database "DatabaseModule"
trim would remove more than intended
added a test case for this
thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... makes sense. TrimPrefix(), TrimSuffix() can be used to trim exact strings so it'd work to limit to the single char. https://pkg.go.dev/strings#TrimPrefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to strings.Trim*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sukumargaonkar i think this is the only pending unresolved comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in c73f6aa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think this if conditions is necessary as strings.Trim* is noop if not applicable
TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in f2d8620
Signed-off-by: Sukumar Gaonkar <[email protected]>
…equests Signed-off-by: Sukumar Gaonkar <[email protected]>
|
/retest |
|
The ubuntu based CI failed but macOS based passed error in ubuntu based CI seems unrelated to this PR. maybe @mathetake knows more |
|
yeah sorry you can ignore the flake |
| ResponseModeNone ResponseMode = "NONE" | ||
| ResponseModeText ResponseMode = "TEXT" | ||
| ResponseModeJSON ResponseMode = "JSON" | ||
| ResponseModeEnum ResponseMode = "ENUM" | ||
| ResponseModeRegex ResponseMode = "REGEX" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unexport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also prefix gemini*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in f871ff7
| ) | ||
|
|
||
| // ResponseMode represents the type of response mode for Gemini requests | ||
| type ResponseMode string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| type ResponseMode string | |
| type geminiResponseMode string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in f871ff7
Signed-off-by: Sukumar Gaonkar <[email protected]>
|
|
||
| // ResponseFormat and guidedJSON/guidedChoice/guidedRegex are mutually exclusive. | ||
| // Verify only one is specified. | ||
| if formatSpecifiedCount > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when formatSpecifiedCount == 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing really
this is only to validate more than one format specifiers are not specified
Signed-off-by: Sukumar Gaonkar <[email protected]>
Description
This PR removes the wrapping double-quotes returned by GCP when using guided_regex
GCP doesn't natively support REGEX response modes, so we instead express them as json schema.
This causes the response to be wrapped in double-quotes.
E.g.
"positive"(the double-quotes at the start and end are unwanted)