PG1204 commented on code in PR #6972:
URL: https://github.com/apache/texera/pull/6972#discussion_r3669822625
##########
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/huggingFace/codegen/PythonCodegenBase.scala:
##########
@@ -201,9 +201,18 @@ object PythonCodegenBase {
| prov_task = prov.get("task", "")
| try:
| if self.TASK in ("text-generation",
"image-text-to-text"):
- | route = self.CHAT_ROUTES.get(provider_name,
"v1/chat/completions")
- | url =
f"https://router.huggingface.co/{provider_name}/{route}"
- | resp = requests.post(url, headers=json_headers,
json=pipeline_payload, timeout=120)
+ | if provider_name == "hf-inference":
+ | # hf-inference expects the model in the URL
path, like the
+ | # pipeline route below.
+ | url =
f"https://router.huggingface.co/hf-inference/models/{self.MODEL_ID}/v1/chat/completions"
+ | else:
+ | route = self.CHAT_ROUTES.get(provider_name,
"v1/chat/completions")
+ | url =
f"https://router.huggingface.co/{provider_name}/{route}"
+ | # Provider-scoped routes need the provider's own
model name
+ | # (providerId), not the HF Hub ID. Copy instead of
mutating:
+ | # pipeline_payload is reused for the next provider
attempt.
+ | chat_payload = {**pipeline_payload, "model":
provider_id}
+ | resp = requests.post(url, headers=json_headers,
json=chat_payload, timeout=120)
Review Comment:
Good point, so to clarify the current state: despite the Base in the name,
this isn't a shared/cross-operator base class. It lives in
...operator.huggingFace.codegen and is referenced only within that package. The
Base refers to it being the shared base of the HF per-task codegens, as it
holds the common template and provider-fallback scaffolding that all of the
TaskCodegen implementations (TextGenCodegen, ImageTaskCodegen,
AudioTaskCodegen, MediaGenCodegen, QaRankingCodegen) plug their per-task
payload/parse snippets into. So the Hugging Face-specific logic is already
scoped to the HF package.
You're right that the name reads generic, though. I'd rather keep this PR
focused on the model-id fix, but i can do a naming-clarity follow-up: e.g.
renaming to HuggingFaceCodegenBase (or HuggingFacePythonTemplate) so its scope
is obvious at a glance. This can be tracked as a separate follow up task.
--
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]