Yicong-Huang commented on code in PR #6972:
URL: https://github.com/apache/texera/pull/6972#discussion_r3669791227


##########
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:
   might be a todo for future PR: this is python code gen base class, should 
this hugging face specific logic moved to somewhere else?



-- 
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]

Reply via email to