PG1204 commented on code in PR #7920:
URL: https://github.com/apache/texera/pull/7920#discussion_r3983176539
##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/ImageTaskCodegen.scala:
##########
@@ -113,6 +113,10 @@ object ImageTaskCodegen extends TaskCodegen {
| return json.dumps(body)
| elif task in ("visual-question-answering",
"document-question-answering"):
| if isinstance(body, dict):
+ | # Third-party chat providers answer via
choices[0].message;
+ | # hf-inference returns the native {"answer": ...}
shape.
+ | if "choices" in body:
+ | return body["choices"][0]["message"]["content"]
Review Comment:
I confirmed both failure modes: {"choices": []} raises IndexError and
{"choices": [{}]} raises KeyError, and since this runs per row it aborts the
whole run. I've appplied your suggestion to all four choices sites in this
file, so the pre-existing image-to-text and image-text-to-text branches degrade
the same way. Added a test that pins all four and asserts the bare
["message"]["content"] indexing is gone. Exercised the emitted Python across
the malformed shapes: empty list, missing message, missing content, and they
now fall back to json.dumps(body) instead of raising, with well-formed and
native responses unchanged.
The same pattern also exists in QaRankingCodegen (three sites, from #7798)
and TextGenCodegen, where the extraction has no guard at all. Those are more
exposed than these image branches, unlike the image tasks, those models do have
live third-party providers, so the chat path is actually reachable there.
Filing a follow-up rather than widening this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]