add option for inference for organizations#11
Open
hallucinate-llc wants to merge 1 commit intohuggingface:mainfrom
Open
add option for inference for organizations#11hallucinate-llc wants to merge 1 commit intohuggingface:mainfrom
hallucinate-llc wants to merge 1 commit intohuggingface:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for billing Hugging Face inference requests to a user-specified organization by introducing a new huggingface.billTo setting and forwarding it on chat completion requests.
Changes:
- Add
huggingface.billToconfiguration (manifest + docs) and prompt for it via thehuggingface.managecommand. - Forward
X-HF-Bill-Toon/chat/completionsrequests when configured. - Introduce lightweight runtime wrappers for
fetch,TextDecoder, and error logging in the provider.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/provider.ts | Reads huggingface.billTo and conditionally sends X-HF-Bill-To; adds runtime-safe wrappers for fetch/TextDecoder and consolidates error logging. |
| src/extension.ts | Extends the management command to capture and persist the optional billing org setting. |
| package.json | Contributes the huggingface.billTo setting to VS Code’s configuration schema. |
| README.md | Documents organization billing behavior and the forwarded header name. |
Comments suppressed due to low confidence (3)
src/provider.ts:384
billTocomes from user/workspace configuration and is forwarded directly into an HTTP header. If the value contains invalid header characters (e.g., control chars/newlines),fetchwill throw and the chat request will fail. Consider validatingbillToagainst an allowed pattern (e.g., org slug chars) and surfacing a clear error (or ignoring the setting) when invalid.
if (billTo) {
headers["X-HF-Bill-To"] = billTo;
}
src/provider.ts:472
- This method’s indentation/whitespace is inconsistent with the rest of the file (extra leading tab on the method declaration and mis-indented body statements). Please reformat this block (e.g., run Prettier) to keep the streaming parser readable and avoid accidental brace/flow mistakes during future edits.
private async processStreamingResponse(
responseBody: HFStream,
progress: vscode.Progress<vscode.LanguageModelResponsePart>,
token: vscode.CancellationToken,
): Promise<void> {
const reader = responseBody.getReader();
const decoder = createTextDecoder();
let buffer = "";
src/provider.ts:389
- New behavior adds an optional
X-HF-Bill-Toheader based onhuggingface.billTo, but there’s no coverage ensuring the header is (a) sent when configured and (b) omitted when blank/whitespace. Sincesrc/test/provider.test.tsalready covers provider behavior, consider adding a test that stubsglobalThis.fetchand sets the workspace configuration to assert the outgoing headers.
const headers: Record<string, string> = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
"User-Agent": this.userAgent,
};
if (billTo) {
headers["X-HF-Bill-To"] = billTo;
}
const response = await hfFetch(`${BASE_URL}/chat/completions`, {
method: "POST",
headers,
body: JSON.stringify(requestBody),
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.