VEuPathDB / VEuPathDB/ApiCommonWebsite

AI Expression malformed individual experiment responses cause user-facing exception

Open
#277 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Perl
Stars
3
Forks
1
Avg merge
1d 21h
Merged PRs (30d)
6

Description

Every now and then, the user will get a
We're sorry, something went wrong.
during the processing of a gene.

I managed to track one down and it's malformed JSON returned by OpenAI despite it having been given a responseFormat schema. Boo!

I think the only solution is to assume these are 1 in 50 events and have a retry strategy?

From the tomcat logs for VectorBase on watermelon

Caused by: java.lang.RuntimeException: Error parsing JSON response for dataset DS_047c56768c.  Raw response string:
{"one_sentence_summary":"This gene is moderately expressed in <i>Anopheles gambiae</i> midguts and salivary glands infected with <i>Plasmodium falciparum</i>, showing a slightly h
igher expression in salivary glands.","biological_importance":3,"confidence":4,"notes":"Expression values indicate a slightly higher level in salivary gland samples compared to mi
dgut samples, and expression seems consistent across paired-end and single-end methodologies.","experiment_keywords":["mosquito tissues","midgut","salivary gland","Plasmodium falc
iparum infection","RNA-Seq"],"confidence":4}

        at org.apidb.apicommon.model.report.ai.expression.Summarizer.lambda$describeExperiment$0(Summarizer.java:159)
Caused by: org.json.JSONException: Duplicate key "confidence" at 579 [character 580 line 1]
        at org.json.JSONTokener.syntaxError(JSONTokener.java:536)
        at org.json.JSONObject.<init>(JSONObject.java:259)
        at org.json.JSONObject.<init>(JSONObject.java:481)
        at org.json.JSONObject.<init>(JSONObject.java:458)
        at org.apidb.apicommon.model.report.ai.expression.Summarizer.lambda$describeExperiment$0(Summarizer.java:150)

Parsing is here: https://github.com/VEuPathDB/ApiCommonWebsite/blob/8c87e63cef7f9e691d377fe80bc7177f70cba6bc/Model/src/main/java/org/apidb/apicommon/model/report/ai/expression/Summarizer.java#L150

See also #263

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Model/src/main/java/org/apidb/apicommon/model/report/ai/expression/Summarizer.java around line 150, where the experiment response is parsed, and compare the related context in issue #263. Reproduce the duplicate-key malformed response if possible and determine how parsing should recover or retry. Done means malformed individual responses no longer surface as an unhandled user-facing exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
ai, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.