PG1204 commented on code in PR #8617:
URL: https://github.com/apache/texera/pull/8617#discussion_r4138961153
##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/HuggingFaceCodegenBase.scala:
##########
@@ -260,6 +260,37 @@ object HuggingFaceCodegenBase {
| summary = "; ".join(errors) if errors else "no providers
available"
| return last_resp, summary
|
+ | def _chat_message_content(self, body):
+ | '''Return the assistant text from a chat-completions response,
or None
+ | when the body is not that shape. Providers differ and
malformed 200s
+ | happen, so every level is type-checked rather than indexed:
parsing
+ | runs once per row, and an exception here aborts the whole run.
Callers
+ | fall back to their native shape, or to json.dumps(body), on
None.
Review Comment:
The wrong came from the original issue description, which I've since
corrected: _parse_response already catches KeyError, IndexError and TypeError,
and the row loop catches the rest per row.
The same wording had leaked into four places in this PR, so I fixed all of
them. Rather than just dropping the clause, I replaced it with the actual
mechanism, which is the part worth documenting: indexing a non-dict raises
AttributeError, which _parse_response's except list does not catch, so that row
ends up reading "Request failed" instead of the body.
One occurrence is left in ImageTaskCodegenSpec and it's already on main from
#7920 and this PR doesn't touch that file. It's covered by #8634, which edits
that spec anyway.
--
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]