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

fix: Retry JSON queries on Vertex AI #2093

Merged
merged 6 commits into from
Oct 31, 2024
Merged

Conversation

dividedmind
Copy link
Collaborator

@dividedmind dividedmind commented Oct 28, 2024

Looking through our Gemini logs I noticed JSON queries sometimes fail:

[context-service] Searching for context
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at GoogleVertexAICompletionService.json (/home/runner/work/navie-benchmark/navie-benchmark/submodules/appmap-js/packages/navie/dist/services/google-vertexai-completion-service.js:54:29)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async VectorTermsService.suggestTerms (/home/runner/work/navie-benchmark/navie-benchmark/submodules/appmap-js/packages/navie/dist/services/vector-terms-service.js:114:26)

It's not clear to me why this happened, so I added retry and also logging of the response on error.

EDIT: I actually checked the trajectory and here's what the output was (note it's verbatim — the LLM returned it truncated):

{
  "context": "io.fits.Card float string representation too large, truncates comments, astropy", 
  "instructions": "Reproduce the following issue with a test case. Generate exactly\none test case that reproduces the issue.\n\n<issue>\n`io.fits.Card` may use a string representation of floats that is larger than necessary\n### Description\n\nIn some scenarios, `io.fits.Card` may use a string representation of floats that is larger than necessary, which can force comments to be truncated. Due to this, there are some keyword/value/comment combinations that are impossible to create via `io.fits` even though they are entirely possible in FITS.\n\n### Expected behavior\n\nBeing able to create any valid FITS Card via `io.fits.Card`.\n\n### How to Reproduce\n\n[This valid FITS file](https://github.com/astropy/astropy/files/10922976/test.fits.gz) contains the following card in the header:\n\n`HIERARCH ESO IFM CL RADIUS = 0.009125 / [m] radius arround actuator to avoid`\n\nWe can read the header of this file and get this card without any issue:\n\n

Seems like it hit some kind of limit. I modified the prompt to be brief in the instructions; hopefully it'll avoid this problem.

EDIT2: It seems that the JSON is hitting the RECITATION filter in Gemini due to it trying to repeat the input. Hopefully the instruction to be brief will make it paraphrase it enough to avoid this...

@dividedmind dividedmind self-assigned this Oct 28, 2024
I noticed sometimes the LLM tries to put a lot in the `instructions`
part of the vector terms response; this part is only meant to direct
reasoning and we're ultimately throwing it out, so it doesn't make
sense to be very verbose. It also appears to hit against some limits,
at least on Gemini.
This might help avoid recitation errors on retry.
The old version dropped deprecation warnings for punycode module.
@dividedmind dividedmind merged commit f5d7657 into main Oct 31, 2024
23 checks passed
@dividedmind dividedmind deleted the fix/vertex-json-retry branch October 31, 2024 10:24
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

Successfully merging this pull request may close these issues.

2 participants