Skip to content

Commit b94ca92

Browse files
authored
refactor: remove endpointType from computeEmbeddings calls for consistency (#1171)
1 parent 979d9b4 commit b94ca92

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

src/extension/context/node/resolvers/extensionApi.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class VSCodeAPIContextElement extends PromptElement<VSCodeAPIContextProps
9595
return [];
9696
}
9797

98-
const embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [this.props.query], { endpointType: 'capi' }, new TelemetryCorrelationId('VSCodeAPIContextElement::getSnippets'), token);
98+
const embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [this.props.query], {}, new TelemetryCorrelationId('VSCodeAPIContextElement::getSnippets'), token);
9999
return this.apiEmbeddingsIndex.nClosestValues(embeddingResult.values[0], 5);
100100
}
101101

src/extension/prompt/vscode-node/settingsEditorSearchServiceImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class SettingsEditorSearchServiceImpl implements ISettingsEditorSearchSer
3737

3838
let embeddingResult: Embeddings;
3939
try {
40-
embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [query], { endpointType: 'capi' }, new TelemetryCorrelationId('SettingsEditorSearchServiceImpl::provideSettingsSearchResults'), token);
40+
embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [query], {}, new TelemetryCorrelationId('SettingsEditorSearchServiceImpl::provideSettingsSearchResults'), token);
4141
} catch {
4242
if (token.isCancellationRequested) {
4343
progress.report(canceledBundle);

src/extension/prompts/node/panel/newWorkspace/newWorkspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class NewWorkspacePrompt extends PromptElement<NewWorkspacePromptProps, N
105105
}
106106
else if (instruction.intent === 'Project') {
107107
if (this.props.useTemplates) {
108-
const result = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [instruction.question], { endpointType: 'capi' }, undefined);
108+
const result = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [instruction.question], {}, undefined);
109109
progress.report(new ChatResponseProgressPart(l10n.t('Searching project template index...')));
110110
const similarProjects = await this.projectTemplatesIndex.nClosestValues(result.values[0], 1);
111111
if (similarProjects.length > 0) {

src/extension/prompts/node/panel/vscode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class VscodePrompt extends PromptElement<VscodePromptProps, VscodePromptS
136136
return { settings: [], commands: [], query: userQuery };
137137
}
138138

139-
const embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [userQuery], { endpointType: 'capi' }, undefined);
139+
const embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [userQuery], {}, undefined);
140140
if (token.isCancellationRequested) {
141141
return { settings: [], commands: [], query: userQuery };
142142
}

src/platform/embeddings/common/embeddingsComputer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export const IEmbeddingsComputer = createServiceIdentifier<IEmbeddingsComputer>(
9191

9292
export type ComputeEmbeddingsOptions = {
9393
readonly inputType?: 'document' | 'query';
94-
readonly endpointType?: 'capi' | 'github';
9594
};
9695

9796
export interface IEmbeddingsComputer {

src/platform/embeddings/common/remoteEmbeddingsComputer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export class RemoteEmbeddingsComputer implements IEmbeddingsComputer {
5656
): Promise<Embeddings> {
5757
return logExecTime(this._logService, 'RemoteEmbeddingsComputer::computeEmbeddings', async () => {
5858

59-
if (options?.endpointType === 'capi') {
59+
// Determine endpoint type: use CAPI for no-auth users, otherwise use GitHub
60+
const copilotToken = await this._authService.getCopilotToken();
61+
if (copilotToken.isNoAuthUser) {
6062
const embeddings = await this.computeCAPIEmbeddings(inputs, options, cancellationToken);
6163
return embeddings ?? { type: embeddingType, values: [] };
6264
}

src/platform/embeddings/common/vscodeIndex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ abstract class RelatedInformationProviderEmbeddingsIndex<V extends { key: string
108108
return [];
109109
}
110110
const startOfEmbeddingRequest = Date.now();
111-
const embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [query], { endpointType: 'capi' }, new TelemetryCorrelationId('RelatedInformationProviderEmbeddingsIndex::provideRelatedInformation'), token);
111+
const embeddingResult = await this.embeddingsComputer.computeEmbeddings(EmbeddingType.text3small_512, [query], {}, new TelemetryCorrelationId('RelatedInformationProviderEmbeddingsIndex::provideRelatedInformation'), token);
112112
this._logService.debug(`Related Information: Remote similarly request took ${Date.now() - startOfEmbeddingRequest}ms`);
113113
if (token.isCancellationRequested) {
114114
// return an array of 0s the same length as comparisons

0 commit comments

Comments
 (0)