client changes for on prem proxy
This commit is contained in:
parent
7614cb7ee8
commit
c234cbe107
14 changed files with 115 additions and 71 deletions
|
|
@ -1,7 +1,12 @@
|
|||
import { ContinueProxyReranker } from "../../context/rerankers/ContinueProxyReranker.js";
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import {
|
||||
ControlPlaneClient,
|
||||
DEFAULT_CONTROL_PLANE_PROXY_URL,
|
||||
} from "../../control-plane/client.js";
|
||||
import { TeamAnalytics } from "../../control-plane/TeamAnalytics.js";
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
IDE,
|
||||
IdeSettings,
|
||||
|
|
@ -33,7 +38,7 @@ export default async function doLoadConfig(
|
|||
const ideSettings = await ideSettingsPromise;
|
||||
const workOsAccessToken = await controlPlaneClient.getAccessToken();
|
||||
|
||||
const newConfig = await loadFullConfigNode(
|
||||
let newConfig = await loadFullConfigNode(
|
||||
ide,
|
||||
workspaceConfigs,
|
||||
ideSettings,
|
||||
|
|
@ -56,34 +61,59 @@ export default async function doLoadConfig(
|
|||
// TODO: pass config to pre-load non-system TTS models
|
||||
await TTS.setup();
|
||||
|
||||
// Set up control plane proxy if configured
|
||||
let controlPlaneProxyUrl: string =
|
||||
(newConfig as any).controlPlane?.proxyUrl ??
|
||||
DEFAULT_CONTROL_PLANE_PROXY_URL;
|
||||
if (!controlPlaneProxyUrl.endsWith("/")) {
|
||||
controlPlaneProxyUrl += "/";
|
||||
}
|
||||
const controlPlaneProxyInfo = {
|
||||
workspaceId,
|
||||
controlPlaneProxyUrl,
|
||||
workOsAccessToken,
|
||||
};
|
||||
|
||||
if (newConfig.analytics) {
|
||||
await TeamAnalytics.setup(
|
||||
newConfig.analytics as any, // TODO: Need to get rid of index.d.ts once and for all
|
||||
uniqueId,
|
||||
ideInfo.extensionVersion,
|
||||
controlPlaneClient,
|
||||
workspaceId,
|
||||
controlPlaneProxyInfo,
|
||||
);
|
||||
}
|
||||
|
||||
[...newConfig.models, ...(newConfig.tabAutocompleteModels ?? [])].forEach(
|
||||
newConfig = await injectControlPlaneProxyInfo(
|
||||
newConfig,
|
||||
controlPlaneProxyInfo,
|
||||
);
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
// Pass ControlPlaneProxyInfo to objects that need it
|
||||
async function injectControlPlaneProxyInfo(
|
||||
config: ContinueConfig,
|
||||
info: ControlPlaneProxyInfo,
|
||||
): Promise<ContinueConfig> {
|
||||
[...config.models, ...(config.tabAutocompleteModels ?? [])].forEach(
|
||||
async (model) => {
|
||||
if (model.providerName === "continue-proxy") {
|
||||
(model as ContinueProxy).workOsAccessToken = workOsAccessToken;
|
||||
(model as ContinueProxy).controlPlaneProxyInfo = info;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (newConfig.embeddingsProvider?.providerName === "continue-proxy") {
|
||||
if (config.embeddingsProvider?.providerName === "continue-proxy") {
|
||||
(
|
||||
newConfig.embeddingsProvider as ContinueProxyEmbeddingsProvider
|
||||
).workOsAccessToken = workOsAccessToken;
|
||||
config.embeddingsProvider as ContinueProxyEmbeddingsProvider
|
||||
).controlPlaneProxyInfo = info;
|
||||
}
|
||||
|
||||
if (newConfig.reranker?.name === "continue-proxy") {
|
||||
(newConfig.reranker as ContinueProxyReranker).workOsAccessToken =
|
||||
workOsAccessToken;
|
||||
if (config.reranker?.name === "continue-proxy") {
|
||||
(config.reranker as ContinueProxyReranker).controlPlaneProxyInfo = info;
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,15 @@
|
|||
import fetch from "node-fetch";
|
||||
import { CONTROL_PLANE_URL } from "../../control-plane/client.js";
|
||||
import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import { Chunk, Reranker } from "../../index.js";
|
||||
|
||||
export class ContinueProxyReranker implements Reranker {
|
||||
name = "continue-proxy";
|
||||
|
||||
private _workOsAccessToken: string | undefined = undefined;
|
||||
private _controlPlaneProxyInfo?: ControlPlaneProxyInfo;
|
||||
|
||||
get workOsAccessToken(): string | undefined {
|
||||
return this._workOsAccessToken;
|
||||
}
|
||||
|
||||
set workOsAccessToken(value: string | undefined) {
|
||||
if (this._workOsAccessToken !== value) {
|
||||
this._workOsAccessToken = value;
|
||||
this.params.apiKey = value!;
|
||||
}
|
||||
set controlPlaneProxyInfo(value: ControlPlaneProxyInfo) {
|
||||
this.params.apiKey = value.workOsAccessToken!;
|
||||
this._controlPlaneProxyInfo = value;
|
||||
}
|
||||
|
||||
constructor(
|
||||
|
|
@ -26,7 +20,10 @@ export class ContinueProxyReranker implements Reranker {
|
|||
) {}
|
||||
|
||||
async rerank(query: string, chunks: Chunk[]): Promise<number[]> {
|
||||
const url = new URL("/model-proxy/v1/rerank", CONTROL_PLANE_URL);
|
||||
const url = new URL(
|
||||
"openai/v1/rerank",
|
||||
this._controlPlaneProxyInfo?.controlPlaneProxyUrl,
|
||||
);
|
||||
const resp = await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import { Analytics } from "@continuedev/config-types";
|
||||
import os from "node:os";
|
||||
import ContinueProxyAnalyticsProvider from "./analytics/ContinueProxyAnalyticsProvider.js";
|
||||
import { IAnalyticsProvider } from "./analytics/IAnalyticsProvider.js";
|
||||
import {
|
||||
ControlPlaneProxyInfo,
|
||||
IAnalyticsProvider,
|
||||
} from "./analytics/IAnalyticsProvider.js";
|
||||
import LogStashAnalyticsProvider from "./analytics/LogStashAnalyticsProvider.js";
|
||||
import PostHogAnalyticsProvider from "./analytics/PostHogAnalyticsProvider.js";
|
||||
import { ControlPlaneClient } from "./client.js";
|
||||
|
|
@ -41,7 +44,7 @@ export class TeamAnalytics {
|
|||
uniqueId: string,
|
||||
extensionVersion: string,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
workspaceId?: string,
|
||||
controlPlaneProxyInfo: ControlPlaneProxyInfo,
|
||||
) {
|
||||
TeamAnalytics.uniqueId = uniqueId;
|
||||
TeamAnalytics.os = os.platform();
|
||||
|
|
@ -52,7 +55,11 @@ export class TeamAnalytics {
|
|||
TeamAnalytics.provider = undefined;
|
||||
} else {
|
||||
TeamAnalytics.provider = createAnalyticsProvider(config);
|
||||
await TeamAnalytics.provider?.setup(config, uniqueId, workspaceId);
|
||||
await TeamAnalytics.provider?.setup(
|
||||
config,
|
||||
uniqueId,
|
||||
controlPlaneProxyInfo,
|
||||
);
|
||||
|
||||
if (config.provider === "continue-proxy") {
|
||||
(
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
import { Analytics } from "@continuedev/config-types";
|
||||
import fetch from "node-fetch";
|
||||
import { CONTROL_PLANE_URL, ControlPlaneClient } from "../client.js";
|
||||
import { IAnalyticsProvider } from "./IAnalyticsProvider.js";
|
||||
import { ControlPlaneClient } from "../client.js";
|
||||
import {
|
||||
ControlPlaneProxyInfo,
|
||||
IAnalyticsProvider,
|
||||
} from "./IAnalyticsProvider.js";
|
||||
|
||||
export default class ContinueProxyAnalyticsProvider
|
||||
implements IAnalyticsProvider
|
||||
{
|
||||
uniqueId?: string;
|
||||
workspaceId?: string;
|
||||
controlPlaneProxyInfo?: ControlPlaneProxyInfo;
|
||||
|
||||
controlPlaneClient?: ControlPlaneClient;
|
||||
|
||||
|
|
@ -16,8 +19,8 @@ export default class ContinueProxyAnalyticsProvider
|
|||
properties: { [key: string]: any },
|
||||
): Promise<void> {
|
||||
const url = new URL(
|
||||
`proxy/analytics/${this.workspaceId}/capture`,
|
||||
CONTROL_PLANE_URL,
|
||||
`proxy/analytics/${this.controlPlaneProxyInfo?.workspaceId}/capture`,
|
||||
this.controlPlaneProxyInfo?.controlPlaneProxyUrl,
|
||||
).toString();
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
|
|
@ -35,10 +38,10 @@ export default class ContinueProxyAnalyticsProvider
|
|||
async setup(
|
||||
config: Analytics,
|
||||
uniqueId: string,
|
||||
workspaceId?: string,
|
||||
controlPlaneProxyInfo?: ControlPlaneProxyInfo,
|
||||
): Promise<void> {
|
||||
this.uniqueId = uniqueId;
|
||||
this.workspaceId = workspaceId;
|
||||
this.controlPlaneProxyInfo = controlPlaneProxyInfo;
|
||||
}
|
||||
|
||||
async shutdown(): Promise<void> {}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,18 @@ export interface AnalyticsMetadata {
|
|||
extensionVersion: string;
|
||||
}
|
||||
|
||||
export interface ControlPlaneProxyInfo {
|
||||
workspaceId?: string;
|
||||
controlPlaneProxyUrl: string;
|
||||
workOsAccessToken?: string;
|
||||
}
|
||||
|
||||
export interface IAnalyticsProvider {
|
||||
capture(event: string, properties: { [key: string]: any }): Promise<void>;
|
||||
setup(
|
||||
config: Analytics,
|
||||
uniqueId: string,
|
||||
workspaceId?: string,
|
||||
controlPlaneProxyInfo?: ControlPlaneProxyInfo,
|
||||
): Promise<void>;
|
||||
shutdown(): Promise<void>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import { Analytics } from "@continuedev/config-types";
|
||||
import net from "node:net";
|
||||
import { IAnalyticsProvider } from "./IAnalyticsProvider.js";
|
||||
import {
|
||||
ControlPlaneProxyInfo,
|
||||
IAnalyticsProvider,
|
||||
} from "./IAnalyticsProvider.js";
|
||||
|
||||
export default class LogStashAnalyticsProvider implements IAnalyticsProvider {
|
||||
private host?: string;
|
||||
|
|
@ -31,7 +34,7 @@ export default class LogStashAnalyticsProvider implements IAnalyticsProvider {
|
|||
async setup(
|
||||
config: Analytics,
|
||||
uniqueId: string,
|
||||
workspaceId?: string,
|
||||
controlPlaneProxyInfo?: ControlPlaneProxyInfo,
|
||||
): Promise<void> {
|
||||
if (!config.url) {
|
||||
console.warn("LogStashAnalyticsProvider is missing a URL");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { Analytics } from "@continuedev/config-types";
|
||||
import { IAnalyticsProvider } from "./IAnalyticsProvider.js";
|
||||
import {
|
||||
ControlPlaneProxyInfo,
|
||||
IAnalyticsProvider,
|
||||
} from "./IAnalyticsProvider.js";
|
||||
|
||||
export default class PostHogAnalyticsProvider implements IAnalyticsProvider {
|
||||
client?: any;
|
||||
|
|
@ -19,7 +22,7 @@ export default class PostHogAnalyticsProvider implements IAnalyticsProvider {
|
|||
async setup(
|
||||
config: Analytics,
|
||||
uniqueId: string,
|
||||
workspaceId?: string,
|
||||
controlPlaneProxyInfo?: ControlPlaneProxyInfo,
|
||||
): Promise<void> {
|
||||
if (!config || !config.clientKey || !config.url) {
|
||||
this.client = undefined;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@ export interface ControlPlaneWorkspace {
|
|||
|
||||
export interface ControlPlaneModelDescription extends ModelDescription {}
|
||||
|
||||
export const DEFAULT_CONTROL_PLANE_PROXY_URL =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
? "http://localhost:3002/"
|
||||
: "https://control-plane-proxy.continue.dev/";
|
||||
|
||||
export const CONTROL_PLANE_URL =
|
||||
process.env.CONTROL_PLANE_ENV === "local"
|
||||
? "http://localhost:3001/"
|
||||
|
|
|
|||
|
|
@ -1,24 +1,16 @@
|
|||
import { CONTROL_PLANE_URL } from "../../control-plane/client.js";
|
||||
import { EmbeddingsProviderName, EmbedOptions } from "../../index.js";
|
||||
import { ControlPlaneProxyInfo } from "../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import { EmbeddingsProviderName } from "../../index.js";
|
||||
import OpenAIEmbeddingsProvider from "./OpenAIEmbeddingsProvider.js";
|
||||
|
||||
class ContinueProxyEmbeddingsProvider extends OpenAIEmbeddingsProvider {
|
||||
static providerName: EmbeddingsProviderName = "continue-proxy";
|
||||
static defaultOptions: Partial<EmbedOptions> | undefined = {
|
||||
apiBase: new URL("/model-proxy/v1", CONTROL_PLANE_URL).toString(),
|
||||
};
|
||||
|
||||
private _workOsAccessToken: string | undefined = undefined;
|
||||
|
||||
get workOsAccessToken(): string | undefined {
|
||||
return this._workOsAccessToken;
|
||||
}
|
||||
|
||||
set workOsAccessToken(value: string | undefined) {
|
||||
if (this._workOsAccessToken !== value) {
|
||||
this._workOsAccessToken = value;
|
||||
this.options.apiKey = value;
|
||||
}
|
||||
set controlPlaneProxyInfo(value: ControlPlaneProxyInfo) {
|
||||
this.options.apiKey = value.workOsAccessToken;
|
||||
this.options.apiBase = new URL(
|
||||
"openai/v1",
|
||||
value.controlPlaneProxyUrl,
|
||||
).toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,15 @@
|
|||
import { CONTROL_PLANE_URL } from "../../../control-plane/client.js";
|
||||
import { ControlPlaneProxyInfo } from "../../../control-plane/analytics/IAnalyticsProvider.js";
|
||||
import type { LLMOptions, ModelProvider } from "../../../index.js";
|
||||
import OpenAI from "../OpenAI.js";
|
||||
|
||||
class ContinueProxy extends OpenAI {
|
||||
private _workOsAccessToken: string | undefined = undefined;
|
||||
|
||||
get workOsAccessToken(): string | undefined {
|
||||
return this._workOsAccessToken;
|
||||
set controlPlaneProxyInfo(value: ControlPlaneProxyInfo) {
|
||||
this.apiKey = value.workOsAccessToken;
|
||||
this.apiBase = new URL("openai/v1", value.controlPlaneProxyUrl).toString();
|
||||
}
|
||||
|
||||
set workOsAccessToken(value: string | undefined) {
|
||||
if (this._workOsAccessToken !== value) {
|
||||
this._workOsAccessToken = value;
|
||||
this.apiKey = value;
|
||||
}
|
||||
}
|
||||
static providerName: ModelProvider = "continue-proxy";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
apiBase: new URL("/model-proxy/v1", CONTROL_PLANE_URL).toString(),
|
||||
useLegacyCompletionsEndpoint: false,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import {
|
|||
import { RootState } from "../../redux/store";
|
||||
import {
|
||||
getFontSize,
|
||||
getMetaKeyLabel,
|
||||
isJetBrains,
|
||||
isMetaEquivalentKeyPressed,
|
||||
isWebEnvironment,
|
||||
|
|
@ -302,7 +303,7 @@ function TipTapEditor(props: TipTapEditorProps) {
|
|||
placeholder: () =>
|
||||
historyLengthRef.current === 0
|
||||
? "Ask anything, '/' for slash commands, '@' to add context"
|
||||
: "Ask a follow-up",
|
||||
: `Ask a follow-up (${getMetaKeyLabel()}⇧L)`,
|
||||
}),
|
||||
Paragraph.extend({
|
||||
addKeyboardShortcuts() {
|
||||
|
|
|
|||
4
packages/config-types/package-lock.json
generated
4
packages/config-types/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@continuedev/config-types",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.12",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@continuedev/config-types",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.12",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"zod": "^3.23.8"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/config-types",
|
||||
"version": "1.0.11",
|
||||
"version": "1.0.12",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
|||
|
|
@ -206,6 +206,10 @@ export const siteIndexingConfigSchema = z.object({
|
|||
faviconUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export const controlPlaneConfigSchema = z.object({
|
||||
proxyUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export const configJsonSchema = z.object({
|
||||
models: z.array(modelDescriptionSchema),
|
||||
tabAutocompleteModel: modelDescriptionSchema.optional(),
|
||||
|
|
@ -224,5 +228,6 @@ export const configJsonSchema = z.object({
|
|||
tabAutocompleteOptions: tabAutocompleteOptionsSchema.optional(),
|
||||
ui: uiOptionsSchema.optional(),
|
||||
docs: z.array(siteIndexingConfigSchema).optional(),
|
||||
controlPlane: controlPlaneConfigSchema.optional(),
|
||||
});
|
||||
export type ConfigJson = z.infer<typeof configJsonSchema>;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue