oscerd opened a new pull request, #25899:
URL: https://github.com/apache/camel/pull/25899

   ## Issue
   [CAMEL-24527](https://issues.apache.org/jira/browse/CAMEL-24527)
   
   ## Problem
   The `authToken` option (and the token resolved from `oauthProfile`) was 
honoured by **only** the chat
   task. `ChatPredictor.getPythonScript()` builds a `token='...'` clause and 
passes it to
   `transformers.pipeline()`; none of the other nine task predictors do. As a 
result, text generation,
   summarization, question answering, classification, sentence embeddings, ASR, 
TTS, text-to-image and
   zero-shot classification all failed with HTTP 401 when loading a gated or 
private model, even with a
   token configured.
   
   ## Fix
   Apply the token centrally in `AbstractTaskPredictor.loadModel()` by 
exporting it as the standard
   `HF_TOKEN` environment variable at the top of the generated handler script:
   
   ```python
   import os
   os.environ['HF_TOKEN'] = '<token>'
   ```
   
   `transformers` / `huggingface_hub` read `HF_TOKEN` from the environment when 
no explicit token is
   passed, so this authenticates **every** task in a single place instead of 
threading a token clause
   through nine predictors and nine Python templates. The token is read from 
`config.getAuthToken()`,
   which holds either the `authToken` option or the value resolved from an 
OAuth profile
   (`HuggingFaceProducer.resolveOAuthToken`). When no token is configured, the 
script is unchanged.
   
   ## Testing
   - New `AuthTokenInjectionTest` verifies the token is exported as `HF_TOKEN` 
when configured and that
     the script is left untouched when it is not.
   - `mvn -Psourcecheck validate` green.
   
   _Claude Code on behalf of oscerd_


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