Skip to content

Rich LLM logging #4866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions binary/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
process.env.IS_BINARY = "true";
import { Command } from "commander";
import { Core } from "core/core";
import { LLMLogFormatter } from "core/llm/logFormatter";
import { FromCoreProtocol, ToCoreProtocol } from "core/protocol";
import { IMessenger } from "core/protocol/messenger";
import { getCoreLogsPath, getPromptLogsPath } from "core/util/paths";
Expand Down Expand Up @@ -33,9 +34,8 @@ program.action(async () => {
const ide = new IpcIde(messenger);
const promptLogsPath = getPromptLogsPath();

new Core(messenger, ide, async (text) => {
fs.appendFileSync(promptLogsPath, text + "\n\n");
});
const core = new Core(messenger, ide);
new LLMLogFormatter(core.llmLogger, fs.createWriteStream(promptLogsPath));

console.log("[binary] Core started");
} catch (e) {
Expand Down
12 changes: 6 additions & 6 deletions core/config/ConfigHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
IDE,
IdeSettings,
ILLM,
ILLMLogger,
} from "../index.js";
import Ollama from "../llm/llms/Ollama.js";
import { GlobalContext } from "../util/GlobalContext.js";
Expand Down Expand Up @@ -48,12 +49,11 @@ export class ConfigHandler {
constructor(
private readonly ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private readonly writeLog: (text: string) => Promise<void>,
private llmLogger: ILLMLogger,
sessionInfoPromise: Promise<ControlPlaneSessionInfo | undefined>,
) {
this.ide = ide;
this.ideSettingsPromise = ideSettingsPromise;
this.writeLog = writeLog;
this.controlPlaneClient = new ControlPlaneClient(
sessionInfoPromise,
ideSettingsPromise,
Expand All @@ -65,7 +65,7 @@ export class ConfigHandler {
ide,
ideSettingsPromise,
this.controlPlaneClient,
writeLog,
this.llmLogger,
),
this.ide,
);
Expand Down Expand Up @@ -184,7 +184,7 @@ export class ConfigHandler {
this.controlPlaneClient,
this.ide,
this.ideSettingsPromise,
this.writeLog,
this.llmLogger,
assistant.rawYaml,
orgScopeId,
);
Expand Down Expand Up @@ -229,7 +229,7 @@ export class ConfigHandler {
this.controlPlaneClient,
this.ide,
this.ideSettingsPromise,
this.writeLog,
this.llmLogger,
this.reloadConfig.bind(this),
);

Expand Down Expand Up @@ -292,7 +292,7 @@ export class ConfigHandler {
this.ide,
this.ideSettingsPromise,
this.controlPlaneClient,
this.writeLog,
this.llmLogger,
assistant,
);
});
Expand Down
21 changes: 13 additions & 8 deletions core/config/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
IdeSettings,
IdeType,
ILLM,
ILLMLogger,
LLMOptions,
ModelDescription,
RerankerDescription,
Expand Down Expand Up @@ -222,7 +223,7 @@ async function intermediateToFinalConfig(
ideSettings: IdeSettings,
ideInfo: IdeInfo,
uniqueId: string,
writeLog: (log: string) => Promise<void>,
llmLogger: ILLMLogger,
workOsAccessToken: string | undefined,
loadPromptFiles: boolean = true,
allowFreeTrial: boolean = true,
Expand All @@ -238,7 +239,7 @@ async function intermediateToFinalConfig(
ide.readFile.bind(ide),
uniqueId,
ideSettings,
writeLog,
llmLogger,
config.completionOptions,
config.systemMessage,
);
Expand All @@ -260,7 +261,7 @@ async function intermediateToFinalConfig(
ide.readFile.bind(ide),
uniqueId,
ideSettings,
writeLog,
llmLogger,
copyOf(config.completionOptions),
config.systemMessage,
);
Expand All @@ -280,7 +281,7 @@ async function intermediateToFinalConfig(
} else {
const llm = new CustomLLMClass({
...desc,
options: { ...desc.options, writeLog } as any,
options: { ...desc.options, logger: llmLogger } as any,
});
if (llm.model === "AUTODETECT") {
try {
Expand All @@ -289,7 +290,11 @@ async function intermediateToFinalConfig(
(modelName) =>
new CustomLLMClass({
...desc,
options: { ...desc.options, model: modelName, writeLog },
options: {
...desc.options,
model: modelName,
logger: llmLogger,
},
}),
);

Expand Down Expand Up @@ -343,7 +348,7 @@ async function intermediateToFinalConfig(
ide.readFile.bind(ide),
uniqueId,
ideSettings,
writeLog,
llmLogger,
config.completionOptions,
config.systemMessage,
);
Expand Down Expand Up @@ -831,7 +836,7 @@ async function loadContinueConfigFromJson(
ideSettings: IdeSettings,
ideInfo: IdeInfo,
uniqueId: string,
writeLog: (log: string) => Promise<void>,
llmLogger: ILLMLogger,
workOsAccessToken: string | undefined,
overrideConfigJson: SerializedContinueConfig | undefined,
): Promise<ConfigResult<ContinueConfig>> {
Expand Down Expand Up @@ -931,7 +936,7 @@ async function loadContinueConfigFromJson(
ideSettings,
ideInfo,
uniqueId,
writeLog,
llmLogger,
workOsAccessToken,
);
return {
Expand Down
5 changes: 3 additions & 2 deletions core/config/profile/ControlPlaneProfileLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ContinueConfig,
IDE,
IdeSettings,
ILLMLogger,
SerializedContinueConfig,
} from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";
Expand All @@ -27,7 +28,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
private readonly controlPlaneClient: ControlPlaneClient,
private readonly ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private writeLog: (message: string) => Promise<void>,
private llmLogger: ILLMLogger,
private readonly onReload: () => void,
) {
this.description = {
Expand Down Expand Up @@ -65,7 +66,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader {
this.ide,
this.ideSettingsPromise,
this.controlPlaneClient,
this.writeLog,
this.llmLogger,
serializedConfig,
undefined,
undefined,
Expand Down
6 changes: 3 additions & 3 deletions core/config/profile/LocalProfileLoader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConfigResult, parseConfigYaml } from "@continuedev/config-yaml";

import { ControlPlaneClient } from "../../control-plane/client.js";
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
import { ContinueConfig, IDE, IdeSettings, ILLMLogger } from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";

import { getPrimaryConfigFilePath } from "../../util/paths.js";
Expand All @@ -17,7 +17,7 @@ export default class LocalProfileLoader implements IProfileLoader {
private ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private controlPlaneClient: ControlPlaneClient,
private writeLog: (message: string) => Promise<void>,
private llmLogger: ILLMLogger,
private overrideAssistantFile?:
| { path: string; content: string }
| undefined,
Expand Down Expand Up @@ -59,7 +59,7 @@ export default class LocalProfileLoader implements IProfileLoader {
this.ide,
this.ideSettingsPromise,
this.controlPlaneClient,
this.writeLog,
this.llmLogger,
undefined,
undefined,
undefined,
Expand Down
10 changes: 5 additions & 5 deletions core/config/profile/PlatformProfileLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AssistantUnrolled, ConfigResult } from "@continuedev/config-yaml";

import { ControlPlaneClient } from "../../control-plane/client.js";
import { getControlPlaneEnv } from "../../control-plane/env.js";
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
import { ContinueConfig, IDE, IdeSettings, ILLMLogger } from "../../index.js";
import { ProfileDescription } from "../ProfileLifecycleManager.js";

import doLoadConfig from "./doLoadConfig.js";
Expand Down Expand Up @@ -30,7 +30,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
private readonly controlPlaneClient: ControlPlaneClient,
private readonly ide: IDE,
private ideSettingsPromise: Promise<IdeSettings>,
private writeLog: (message: string) => Promise<void>,
private llmLogger: ILLMLogger,
readonly description: ProfileDescription,
private readonly orgScopeId: string | null,
) {}
Expand All @@ -44,7 +44,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
controlPlaneClient: ControlPlaneClient,
ide: IDE,
ideSettingsPromise: Promise<IdeSettings>,
writeLog: (message: string) => Promise<void>,
llmLogger: ILLMLogger,
rawYaml: string,
orgScopeId: string | null,
): Promise<PlatformProfileLoader> {
Expand Down Expand Up @@ -74,7 +74,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
controlPlaneClient,
ide,
ideSettingsPromise,
writeLog,
llmLogger,
description,
orgScopeId,
);
Expand All @@ -93,7 +93,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
this.ide,
this.ideSettingsPromise,
this.controlPlaneClient,
this.writeLog,
this.llmLogger,
undefined,
this.configResult.config,
{
Expand Down
7 changes: 4 additions & 3 deletions core/config/profile/doLoadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ContinueRcJson,
IDE,
IdeSettings,
ILLMLogger,
SerializedContinueConfig,
Tool,
} from "../../";
Expand Down Expand Up @@ -39,7 +40,7 @@ export default async function doLoadConfig(
ide: IDE,
ideSettingsPromise: Promise<IdeSettings>,
controlPlaneClient: ControlPlaneClient,
writeLog: (message: string) => Promise<void>,
llmLogger: ILLMLogger,
overrideConfigJson: SerializedContinueConfig | undefined,
overrideConfigYaml: AssistantUnrolled | undefined,
platformConfigMetadata: PlatformConfigMetadata | undefined,
Expand Down Expand Up @@ -74,7 +75,7 @@ export default async function doLoadConfig(
ideSettings,
ideInfo,
uniqueId,
writeLog,
llmLogger,
workOsAccessToken,
overrideConfigYaml,
platformConfigMetadata,
Expand All @@ -92,7 +93,7 @@ export default async function doLoadConfig(
ideSettings,
ideInfo,
uniqueId,
writeLog,
llmLogger,
workOsAccessToken,
overrideConfigJson,
);
Expand Down
Loading
Loading