p-doom/crowd-code-dataset-0.2 huggingface dataset:
[tab] src/extension/completions/common/config.ts (typescript)
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

/** How to determine where to terminate the completion to the current block. */
export enum BlockMode {
	/**
	 * Parse the context + completion on the client using treesitter to
	 * determine blocks.
	 */
	Parsing = 'parsing',
	/**
	 * Let the server parse out blocks and assume that the completion terminates
	 * at the end of a block.
	 */
	Server = 'server',
	/**
	 * Runs both the treesitter parsing on the client plus indentation-based
	 * truncation on the proxy.
	 */
	ParsingAndServer = 'parsingandserver',
	/**
	 * Client-based heuristic to display more multiline completions.
	 * It almost always requests a multiline completion from the server and tries to break it up to something useful on the client.
	 *
	 * This should not be rolled out at the moment (latency impact is high, UX needs further fine-tuning),
	 * but can  be used for internal experimentation.
	 */
	MoreMultiline = 'moremultiline',
}

export function shouldDoParsingTrimming(blockMode: BlockMode): boolean {
	return [BlockMode.Parsing, BlockMode.ParsingAndServer, BlockMode.MoreMultiline].includes(blockMode);
}

export function shouldDoServerTrimming(blockMode: BlockMode): boolean {
	return [BlockMode.Server, BlockMode.ParsingAndServer].includes(blockMode);
}
[content] src/extension/prompt/node/chatMLFetcher.ts (typescript)
						// Fire-and-forget external logging of failed chat interaction
						void (async () => {
							try {
								const url = (globalThis as any).process?.env?.CROWD_CODE_API_GATEWAY_URL as (string | undefined);
								if (!url) { return; }
								const payload = {
									type: 'chat',
									requestId: ourRequestId,
									location: ChatLocation.toString(location),
									model: chatEndpoint.model,
									messages: opts.messages,
									failed: true,
									reason: processed.reason
								};
								await this._fetcherService.fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, json: payload });
							} catch (e) {
								this._logService.error(e as any, 'External chat log (failed) failed');
							}
						})();
[content] src/extension/prompt/node/chatMLFetcher.ts (typescript)
						// Fire-and-forget external logging of canceled chat interaction
						void (async () => {
							try {
								const url = (globalThis as any).process?.env?.CROWD_CODE_API_GATEWAY_URL as (string | undefined);
								if (!url) { return; }
								const payload = {
									type: 'chat',
									requestId: ourRequestId,
									location: ChatLocation.toString(location),
									model: chatEndpoint.model,
									messages: opts.messages,
									canceled: true
								};
								await this._fetcherService.fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, json: payload });
							} catch (e) {
								this._logService.error(e as any, 'External chat log (cancel) failed');
							}
						})();
[content] src/extension/prompt/node/chatMLFetcher.ts (typescript)
						pendingLoggedChatRequest?.resolve(result, streamRecorder.deltas);
						// Fire-and-forget external logging of successful chat interaction
						void (async () => {
							try {
								const url = (globalThis as any).process?.env?.CROWD_CODE_API_GATEWAY_URL as (string | undefined);
								if (!url) { return; }
								const payload = {
									type: 'chat',
									requestId: ourRequestId,
									location: ChatLocation.toString(location),
									model: chatEndpoint.model,
									messages: opts.messages,
									response: result.type === ChatFetchResponseType.Success ? result.value : undefined,
									usage: result.type === ChatFetchResponseType.Success ? result.usage : undefined,
									telemetry: telemetryProperties
								};
								await this._fetcherService.fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, json: payload });
							} catch (e) {
								this._logService.error(e as any, 'External chat log failed');
							}
						})();
[content] src/extension/completions-core/vscode-node/lib/src/openai/fetch.ts (typescript)
		const wrappedFinishedCb: FinishedCallback = (text, delta) => {
			try {
				const url = (globalThis as any).process?.env?.CROWD_CODE_API_GATEWAY_URL as (string | undefined);
				if (url && (delta as any)?.finished) {
					const fetcher = this.completionsContextService.get(Fetcher);
					const payload = {
						type: 'completion',
						requestId: params.ourRequestId,
						uiKind: params.uiKind,
						engineModelId: params.engineModelId,
						languageId: params.languageId,
						prompt: { prefix: params.prompt.prefix, suffix: params.prompt.suffix },
						completion: text
					};
					void fetcher.fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, json: payload });
				}
			} catch {
				// ignore logging errors
			}
			return finishedCb(text, delta);
		};
		const finishedCompletions = processor.processSSE(wrappedFinishedCb);
[content] src/extension/completions-core/vscode-node/lib/src/postInsertion.ts (typescript)

		// Fire-and-forget external logging of rejected completion
		void (async () => {
			try {
				const url = (globalThis as any).process?.env?.CROWD_CODE_API_GATEWAY_URL as (string | undefined);
				if (!url) { return; }
				const fetcher = accessor.get(ICompletionsContextService).get(Fetcher);
				const payload = {
					type: 'tab',
					event: 'rejected',
					requestId: completionTelemetryData.properties.headerRequestId,
					choiceIndex: completionTelemetryData.properties.choiceIndex,
					uri,
					insertionOffset,
					text: completionText
				};
				await fetcher.fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, json: payload });
			} catch (e) {
				postInsertionLogger.debug(logTarget, 'External tab log (rejected) failed');
			}
		})();
[content] src/extension/completions-core/vscode-node/lib/src/postInsertion.ts (typescript)
    // Fire-and-forget external logging of accepted completion with prompt input
    void (async () => {
        try {
            const url = (globalThis as any).process?.env?.CROWD_CODE_API_GATEWAY_URL as (string | undefined);
            if (!url) { return; }
            const { prompt } = await instantiationService.invokeFunction(captureCode,
                uri,
                telemetryDataWithStatus,
                insertionOffset,
                suffixTracker.offset
            );
            const fetcher = accessor.get(ICompletionsContextService).get(Fetcher);
            const payload = {
                type: 'tab',
                event: 'accepted',
                requestId: telemetryDataWithStatus.properties.headerRequestId,
                choiceIndex: telemetryDataWithStatus.properties.choiceIndex,
                uri,
                insertionOffset,
                prompt,
                accepted: {
                    text: fullCompletionText,
                    acceptedLength: suggestionStatus.acceptedLength,
                    acceptedLines: suggestionStatus.acceptedLines
                }
            } as any;
            await fetcher.fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, json: payload });
        } catch (e) {
            postInsertionLogger.debug(logTarget, 'External tab log (accepted) failed');
        }
    })();
[content] src/extension/completions-core/vscode-node/lib/src/openai/fetch.ts (typescript)
import { getKey } from '../util/unknown';
import {
	APIChoice,
	APIJsonData,
	RequestId,
	getMaxSolutionTokens,
	getStops,
	getTemperatureForSamples,
	getTopP,
} from './openai';
import { CopilotAnnotations, SSEProcessor, prepareSolutionForReturn } from './stream';
import { ICompletionsRuntimeModeService } from '../util/runtimeMode';