-
Notifications
You must be signed in to change notification settings - Fork 452
[InferenceSnippet] Take token from env variable if not set #1514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -115,7 +115,7 @@ export const bm25s = (model: ModelData): string[] => [ | |||
retriever = BM25HF.load_from_hub("${model.id}")`, | |||
]; | |||
|
|||
export const chatterbox = (model: ModelData): string[] => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to this PR but fixes lint in PR (introduced in #1503)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent!
Co-authored-by: Simon Brandeis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the snippets, looks good to me!
Merging |
nice! |
Fix after #1514. Now that we use a placeholder for access token to load from env, there is no direct way to explictly generatea snippet for either a "direct request" or a "routed request" (determined [here](https://github.com/huggingface/huggingface.js/blob/1131b562d74c7c7b95966ec757fea94773a024f1/packages/inference/src/lib/makeRequestOptions.ts#L124-L141) using `accessToken.startsWith("hf_")`). This PR adds a `directRequest?: boolean;` option to the parameters which solves this problem. Will require a follow-up PR in moon-landing. cc @SBrandeis who found out the root cause ### expected behavior display routed request by default in https://huggingface.co/deepseek-ai/DeepSeek-R1-0528?inference_api=true&inference_provider=fireworks-ai&language=sh 
Solve #1361.
Long awaited feature for @gary149. I did not go for the cleanest solution but it works well and should be robust/flexible enough if we need to fix something in the future.
EDIT: breaking change => access token should be passed as
opts.accessToken
now insnippets.getInferenceSnippets
TODO
once merged:
<inferencesnippet>
html tag (used in hub-docs) Access token from env in snippets doc-builder#570Some examples:
JS client
Python client
openai client
curl
check out PR diff for more examples