diff --git a/electron/LLMHelper.ts b/electron/LLMHelper.ts index 5edd592b..9e72e55a 100644 --- a/electron/LLMHelper.ts +++ b/electron/LLMHelper.ts @@ -1,4 +1,5 @@ import { GoogleGenerativeAI, GenerativeModel } from "@google/generative-ai" +import { time, timeStamp } from "console" import fs from "fs" interface OllamaResponse { @@ -50,7 +51,19 @@ export class LLMHelper { return text; } - private async callOllama(prompt: string): Promise { + private async callOllama(promptOptions: any[]) { + let prompt = "" + let images: string[]; + if (promptOptions.length > 0) { + prompt = promptOptions.shift(); + } + if (promptOptions.length > 0) { + if (promptOptions[0].mimeType == "image/png") { + for (let i=0; i { try { if (this.useOllama) { - return this.callOllama(message); + console.log("[LLMHelper] chatting with Ollama model.") + const ollamaResponse = await this.callOllama([message]); + return ollamaResponse.text; } else if (this.model) { + console.log("[LLMHelper] chatting with Gemini model.") const result = await this.model.generateContent(message); const response = await result.response; return response.text(); @@ -265,7 +298,7 @@ export class LLMHelper { throw new Error("No LLM provider configured"); } } catch (error) { - console.error("[LLMHelper] Error in chatWithGemini:", error); + console.error("[LLMHelper] Error in chatWithLLM:", error); throw error; } } @@ -337,7 +370,7 @@ export class LLMHelper { return { success: false, error: `Ollama not available at ${this.ollamaUrl}` }; } // Test with a simple prompt - await this.callOllama("Hello"); + await this.callOllama(["Hello"]); return { success: true }; } else { if (!this.model) { diff --git a/electron/ProcessingHelper.ts b/electron/ProcessingHelper.ts index ec8bde44..feb458eb 100644 --- a/electron/ProcessingHelper.ts +++ b/electron/ProcessingHelper.ts @@ -74,6 +74,7 @@ export class ProcessingHelper { this.currentProcessingAbortController = new AbortController() try { const imageResult = await this.llmHelper.analyzeImageFile(lastPath); + let imageResultText: string; const problemInfo = { problem_statement: imageResult.text, input_format: { description: "Generated from screenshot", parameters: [] as any[] },