From 8cde458df3bc022dcf0de027fd916f6348e45eb0 Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 16 Mar 2025 10:31:39 -0700 Subject: [PATCH] constant key --- .github/workflows/pr_checks.yaml | 1 + core/llm/index.ts | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index 02f086f81..bf8ce2ecb 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -420,6 +420,7 @@ jobs: id: test-extensions-cache with: path: extensions/vscode/e2e/.test-extensions + key: CONSTANT - name: Download build artifact uses: actions/download-artifact@v4 diff --git a/core/llm/index.ts b/core/llm/index.ts index 21048d5f8..00bf2df43 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -59,15 +59,17 @@ import { toFimBody, } from "./openaiTypeConverters.js"; - export class LLMError extends Error { - constructor(message: string, public llm: ILLM) { + constructor( + message: string, + public llm: ILLM, + ) { super(message); } } export function isModelInstaller(provider: any): provider is ModelInstaller { - return provider && typeof provider.installModel === 'function'; + return provider && typeof provider.installModel === "function"; } export abstract class BaseLLM implements ILLM { @@ -396,7 +398,7 @@ export abstract class BaseLLM implements ILLM { let model = error?.match(/model '(.*)' not found/)?.[1]; if (model && resp.url.match("127.0.0.1:11434")) { text = `The model "${model}" was not found. To download it, run \`ollama run ${model}\`.`; - throw new LLMError(text, this);// No need to add HTTP status details + throw new LLMError(text, this); // No need to add HTTP status details } else if (text.includes("/api/chat")) { text = "The /api/chat endpoint was not found. This may mean that you are using an older version of Ollama that does not support /api/chat. Upgrading to the latest version will solve the issue."; @@ -781,7 +783,7 @@ export abstract class BaseLLM implements ILLM { } let completion = ""; - let citations: null | string[] = null + let citations: null | string[] = null; try { if (this.templateMessages) { @@ -809,8 +811,6 @@ export abstract class BaseLLM implements ILLM { completion = renderChatMessage(msg); } else { // Stream true - console.log("Streaming"); - const stream = this.openaiAdapter.chatCompletionStream( { ...body, @@ -824,7 +824,11 @@ export abstract class BaseLLM implements ILLM { completion += result.content; yield result; } - if (!citations && (chunk as any).citations && Array.isArray((chunk as any).citations)) { + if ( + !citations && + (chunk as any).citations && + Array.isArray((chunk as any).citations) + ) { citations = (chunk as any).citations; } } @@ -851,7 +855,9 @@ export abstract class BaseLLM implements ILLM { await this.writeLog(`Completion:\n${completion}\n\n`); if (citations) { - await this.writeLog(`Citations:\n${citations.map((c, i) => `${i + 1}: ${c}`).join("\n")}\n\n`); + await this.writeLog( + `Citations:\n${citations.map((c, i) => `${i + 1}: ${c}`).join("\n")}\n\n`, + ); } }