constant key

This commit is contained in:
Nate 2025-03-16 10:31:39 -07:00
parent cf67bcbc0f
commit 8cde458df3
2 changed files with 16 additions and 9 deletions

View file

@ -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

View file

@ -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`,
);
}
}