diff --git a/package.json b/package.json index 741220a..291af92 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jenkins-log-reader", "displayName": "AI Log Reader", "description": "Read jenkins log, analyse with local AI.", - "version": "0.8.8", + "version": "0.8.9", "engines": { "vscode": "^1.95.0" }, @@ -97,9 +97,34 @@ }, "jenkins-log-reader.jenkinsLogSize": { "type": "number", + "title": "Retrieve Log Size", "default": 5120, "order": 8, "description": "Jenkins Log Size for Analysis" + }, + "jenkins-log-reader.imageAiModel": { + "type": "string", + "enum": [ + "llama3.2-vision" + ], + "default": "llama3.2-vision", + "title": "Image AI Model", + "order": 9, + "description": "Image AI Model" + }, + "jenkins-log-reader.imagePrompt": { + "type": "string", + "title": "Image Prompt", + "default": "I am a QA, testing a product, which name is Curam. Please help me to check the snapshot, this is a functional testing. Do you see anything wrong or something behave weird in it?", + "order": 10, + "description": "Prompt for Image Analysis" + }, + "jenkins-log-reader.videoPrompt": { + "type": "string", + "title": "Video Prompt", + "default": "Find a person with a ball", + "order": 11, + "description": "Prompt for Video Analysis" } } }, @@ -223,7 +248,7 @@ "autoprefixer": "^10.4.20", "axios": "^1.7.7", "crypto": "^1.0.1", - "marked": "^14.1.3", + "marked": "^14.1.4", "ollama": "^0.5.9", "openai": "^4.71.1", "tailwindcss": "^3.4.14" diff --git a/src/extension.ts b/src/extension.ts index 1a1cac7..31674db 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -48,6 +48,12 @@ export function activate(context: ExtensionContext) { window.showInformationMessage("Please configure your Local AI settings."); } + const imageAiModel = getConfig("jenkins-log-reader.imageAiModel"); + + const imagePrompt = getConfig("jenkins-log-reader.imagePrompt"); + + const videoPrompt = getConfig("jenkins-log-reader.videoPrompt"); + const settings = new JenkinsSettings( jenkinsServerUrl, logSize, @@ -69,7 +75,7 @@ export function activate(context: ExtensionContext) { const resultViewProvider = setupResultWebviewProvider(context); registerCommandOfShowResult(context, resultViewProvider); - registerCommandOfReadImage(context, resultViewProvider); + registerCommandOfReadImage(context, resultViewProvider, imageAiModel, imagePrompt); registerCommandOfFormatGrooby(context); } @@ -92,40 +98,43 @@ function registerCommandOfFormatGrooby(context: ExtensionContext) { ); } -function registerCommandOfReadImage(context: ExtensionContext, - provider: LogReaderResultWebViewProvider) { +function registerCommandOfReadImage( + context: ExtensionContext, + provider: LogReaderResultWebViewProvider, + imageAiModel: string, + imagePrompt: string +) { context.subscriptions.push( commands.registerCommand("jenkins-log-reader.readImage", async (uri: Uri) => { // get image file // turn it into base64 // send to AI (llama3.2-vision) // show result in result view - if (uri){ - - - const image_uri = uri - - const base64String = fs.readFileSync(image_uri.fsPath).toString('base64') - const long_run_task = analyse_image(base64String, provider); - showStatusBarProgress(long_run_task, 'Analysing the image...') - + if (uri) { + const image_uri = uri; + const base64String = fs.readFileSync(image_uri.fsPath).toString("base64"); + const long_run_task = analyse_image(base64String, provider, imageAiModel, imagePrompt); + showStatusBarProgress(long_run_task, "Analysing the image..."); } }) ); } -async function analyse_image(base64String: string, provider: LogReaderResultWebViewProvider) { - await getImageAnalysis("llama3.2-vision", - 'I am a QA, testing a product, which name is Curam. Please help me to check the snapshot, this is a functional testing. Do you see anything wrong or something behave weird in it?', - base64String).then((information: string) => { - if (provider._view) { - // commands.executeCommand("jenkins-log-reader_result-view.focus"); - if (information) { - provider.updateContent(information); - commands.executeCommand("jenkins-log-reader_result-view.focus"); - } +async function analyse_image( + base64String: string, + provider: LogReaderResultWebViewProvider, + imageAiModel: string, + imagePrompt: string +) { + await getImageAnalysis(imageAiModel, imagePrompt, base64String).then((information: string) => { + if (provider._view) { + // commands.executeCommand("jenkins-log-reader_result-view.focus"); + if (information) { + provider.updateContent(information); + commands.executeCommand("jenkins-log-reader_result-view.focus"); } - }); + } + }); } function registerCommandOfShowResult( @@ -164,5 +173,3 @@ function setupSettingsViewProvider(context: ExtensionContext) { function getConfig(config_key: string): any { return workspace.getConfiguration().get(config_key); } - -