Skip to content

add option for inference for organizations#11

Open
hallucinate-llc wants to merge 1 commit intohuggingface:mainfrom
hallucinate-llc:main
Open

add option for inference for organizations#11
hallucinate-llc wants to merge 1 commit intohuggingface:mainfrom
hallucinate-llc:main

Conversation

@hallucinate-llc
Copy link

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 22:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.billTo configuration (manifest + docs) and prompt for it via the huggingface.manage command.
  • Forward X-HF-Bill-To on /chat/completions requests 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

  • billTo comes from user/workspace configuration and is forwarded directly into an HTTP header. If the value contains invalid header characters (e.g., control chars/newlines), fetch will throw and the chat request will fail. Consider validating billTo against 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-To header based on huggingface.billTo, but there’s no coverage ensuring the header is (a) sent when configured and (b) omitted when blank/whitespace. Since src/test/provider.test.ts already covers provider behavior, consider adding a test that stubs globalThis.fetch and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants