From d080c8ed30f15a4acca98bbb70e5989e6dbf7d60 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Tue, 30 Jan 2024 15:02:05 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Show=20all=20prompts=20and=20com?= =?UTF-8?q?pletions=20in=20VS=20Code=20output=20panel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/index.ts | 18 +++++++++++++++--- extensions/vscode/src/loadConfig.ts | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/core/llm/index.ts b/core/llm/index.ts index b60f0f240..b883bf196 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -380,11 +380,11 @@ export abstract class BaseLLM implements ILLM { .map(([key, value]) => `${key}: ${value}`) .join("\n"); return `Settings: - ${settings} +${settings} - ############################################ +############################################ - ${prompt}`; +${prompt}`; } private _logTokensGenerated(model: string, completion: string) { @@ -499,6 +499,10 @@ export abstract class BaseLLM implements ILLM { this._logTokensGenerated(completionOptions.model, completion); + if (log && this.writeLog) { + await this.writeLog(`Completion:\n\n${completion}\n\n`); + } + return { prompt, completion }; } @@ -539,6 +543,10 @@ export abstract class BaseLLM implements ILLM { const completion = await this._complete(prompt, completionOptions); this._logTokensGenerated(completionOptions.model, completion); + if (log && this.writeLog) { + await this.writeLog(`Completion:\n\n${completion}\n\n`); + } + return completion; } @@ -611,6 +619,10 @@ export abstract class BaseLLM implements ILLM { } this._logTokensGenerated(completionOptions.model, completion); + if (log && this.writeLog) { + await this.writeLog(`Completion:\n\n${completion}\n\n`); + } + return { prompt, completion }; } diff --git a/extensions/vscode/src/loadConfig.ts b/extensions/vscode/src/loadConfig.ts index f430d339d..3b469379d 100644 --- a/extensions/vscode/src/loadConfig.ts +++ b/extensions/vscode/src/loadConfig.ts @@ -1,10 +1,15 @@ import { ContinueConfig, IDE, ILLM } from "core"; import * as fs from "fs"; import { Agent, ProxyAgent, fetch } from "undici"; +import * as vscode from "vscode"; import { webviewRequest } from "./debugPanel"; import { VsCodeIde, loadFullConfigNode } from "./ideProtocol"; const tls = require("tls"); +const outputChannel = vscode.window.createOutputChannel( + "Continue - LLM Prompt/Completion" +); + class VsCodeConfigHandler { savedConfig: ContinueConfig | undefined; @@ -100,5 +105,16 @@ export async function llmFromTitle(title?: string): Promise { }); }; + llm.writeLog = async (log: string) => { + outputChannel.appendLine( + "==========================================================================" + ); + outputChannel.appendLine( + "==========================================================================" + ); + + outputChannel.append(log); + }; + return llm; }