improv: set up experiments
This commit is contained in:
parent
fc3159d478
commit
e6e682cbeb
2 changed files with 40 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ import { TRIAL_FIM_MODEL } from "../config/onboarding.js";
|
|||
import { IDE, ILLM } from "../index.js";
|
||||
import OpenAI from "../llm/llms/OpenAI.js";
|
||||
import { DEFAULT_AUTOCOMPLETE_OPTS } from "../util/parameters.js";
|
||||
import { EXPERIMENTS, PosthogFeatureFlag, Telemetry } from "../util/posthog.js";
|
||||
|
||||
import { shouldCompleteMultiline } from "./classification/shouldCompleteMultiline.js";
|
||||
import { ContextRetrievalService } from "./context/ContextRetrievalService.js";
|
||||
|
|
@ -66,7 +67,11 @@ export class CompletionProvider {
|
|||
|
||||
// Set temperature (but don't override)
|
||||
if (llm.completionOptions.temperature === undefined) {
|
||||
llm.completionOptions.temperature = 0.01;
|
||||
const value = await Telemetry.getValueForFeatureFlag(
|
||||
PosthogFeatureFlag.AutocompleteTemperature,
|
||||
);
|
||||
|
||||
llm.completionOptions.temperature = value ?? 0.01;
|
||||
}
|
||||
|
||||
if (llm instanceof OpenAI) {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,28 @@ import os from "node:os";
|
|||
|
||||
import { TeamAnalytics } from "../control-plane/TeamAnalytics.js";
|
||||
import { IdeInfo } from "../index.js";
|
||||
import { PostHog } from "posthog-node";
|
||||
|
||||
export enum PosthogFeatureFlag {
|
||||
AutocompleteTemperature = "autocomplete-temperature",
|
||||
}
|
||||
|
||||
export const EXPERIMENTS: {
|
||||
[key in PosthogFeatureFlag]: {
|
||||
[key: string]: { value: number };
|
||||
};
|
||||
} = {
|
||||
[PosthogFeatureFlag.AutocompleteTemperature]: {
|
||||
control: { value: 0.01 },
|
||||
"0_33": { value: 0.33 },
|
||||
"0_66": { value: 0.66 },
|
||||
"0_99": { value: 0.99 },
|
||||
},
|
||||
};
|
||||
|
||||
export class Telemetry {
|
||||
// Set to undefined whenever telemetry is disabled
|
||||
static client: any = undefined;
|
||||
static client: PostHog | undefined = undefined;
|
||||
static uniqueId = "NOT_UNIQUE";
|
||||
static os: string | undefined = undefined;
|
||||
static ideInfo: IdeInfo | undefined = undefined;
|
||||
|
|
@ -55,9 +73,9 @@ export class Telemetry {
|
|||
Telemetry.client?.shutdown();
|
||||
}
|
||||
|
||||
static async getTelemetryClient() {
|
||||
static async getTelemetryClient(): Promise<PostHog | undefined> {
|
||||
try {
|
||||
const { PostHog } = await import("posthog-node");
|
||||
// const { PostHog } = await import("posthog-node");
|
||||
return new PostHog("phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs", {
|
||||
host: "https://app.posthog.com",
|
||||
});
|
||||
|
|
@ -77,4 +95,17 @@ export class Telemetry {
|
|||
Telemetry.client = await Telemetry.getTelemetryClient();
|
||||
}
|
||||
}
|
||||
|
||||
static async getFeatureFlag(flag: PosthogFeatureFlag) {
|
||||
return Telemetry.client?.getFeatureFlag(flag, Telemetry.uniqueId);
|
||||
}
|
||||
|
||||
static async getValueForFeatureFlag(flag: PosthogFeatureFlag) {
|
||||
const userGroup = await Telemetry.getFeatureFlag(flag);
|
||||
if (typeof userGroup === "string") {
|
||||
return EXPERIMENTS[flag][userGroup].value;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue