Skip to content

All 3 approaches added #73 #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions electron/ProcessingHelper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ProcessingHelper.ts
import fs from "node:fs"
import path from "node:path"

Check failure on line 3 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'path' is defined but never used

Check failure on line 3 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'path' is defined but never used

Check failure on line 3 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'path' is defined but never used
import { ScreenshotHelper } from "./ScreenshotHelper"
import { IProcessingHelperDeps } from "./main"
import * as axios from "axios"
import { app, BrowserWindow, dialog } from "electron"

Check failure on line 7 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'dialog' is defined but never used

Check failure on line 7 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'app' is defined but never used

Check failure on line 7 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'dialog' is defined but never used

Check failure on line 7 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'app' is defined but never used

Check failure on line 7 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'dialog' is defined but never used

Check failure on line 7 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'app' is defined but never used
import { OpenAI } from "openai"
import { configHelper } from "./ConfigHelper"
import Anthropic from '@anthropic-ai/sdk';
Expand All @@ -31,7 +31,7 @@
finishReason: string;
}>;
}
interface AnthropicMessage {

Check failure on line 34 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

'AnthropicMessage' is defined but never used

Check failure on line 34 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'AnthropicMessage' is defined but never used

Check failure on line 34 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

'AnthropicMessage' is defined but never used
role: 'user' | 'assistant';
content: Array<{
type: 'text' | 'image';
Expand All @@ -56,7 +56,7 @@

constructor(deps: IProcessingHelperDeps) {
this.deps = deps
this.screenshotHelper = deps.getScreenshotHelper()

Check failure on line 59 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

Type 'ScreenshotHelper | null' is not assignable to type 'ScreenshotHelper'.

// Initialize AI client based on config
this.initializeAIClient();
Expand Down Expand Up @@ -286,7 +286,7 @@
throw new Error("Failed to load screenshot data");
}

const result = await this.processScreenshotsHelper(validScreenshots, signal)

Check failure on line 289 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

Argument of type '({ path: string; preview: string; data: string; } | null)[]' is not assignable to parameter of type '{ path: string; data: string; }[]'.

if (!result.success) {
console.log("Processing failed:", result.error)
Expand All @@ -313,7 +313,7 @@
result.data
)
this.deps.setView("solutions")
} catch (error: any) {

Check failure on line 316 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

Unexpected any. Specify a different type

Check failure on line 316 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

Unexpected any. Specify a different type

Check failure on line 316 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

Unexpected any. Specify a different type
mainWindow.webContents.send(
this.deps.PROCESSING_EVENTS.INITIAL_SOLUTION_ERROR,
error
Expand Down Expand Up @@ -400,11 +400,11 @@

console.log(
"Combined screenshots for processing:",
validScreenshots.map((s) => s.path)

Check failure on line 403 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

's' is possibly 'null'.
)

const result = await this.processExtraScreenshotsHelper(
validScreenshots,

Check failure on line 407 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

Argument of type '({ path: string; preview: string; data: string; } | null)[]' is not assignable to parameter of type '{ path: string; data: string; }[]'.
signal
)

Expand All @@ -420,7 +420,7 @@
result.error
)
}
} catch (error: any) {

Check failure on line 423 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

Unexpected any. Specify a different type

Check failure on line 423 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

Unexpected any. Specify a different type

Check failure on line 423 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

Unexpected any. Specify a different type
if (axios.isCancel(error)) {
mainWindow.webContents.send(
this.deps.PROCESSING_EVENTS.DEBUG_ERROR,
Expand Down Expand Up @@ -506,7 +506,7 @@
try {
const responseText = extractionResponse.choices[0].message.content;
// Handle when OpenAI might wrap the JSON in markdown code blocks
const jsonText = responseText.replace(/```json|```/g, '').trim();

Check failure on line 509 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'responseText' is possibly 'null'.
problemInfo = JSON.parse(jsonText);
} catch (error) {
console.error("Error parsing OpenAI response:", error);
Expand Down Expand Up @@ -613,7 +613,7 @@
const responseText = (response.content[0] as { type: 'text', text: string }).text;
const jsonText = responseText.replace(/```json|```/g, '').trim();
problemInfo = JSON.parse(jsonText);
} catch (error: any) {

Check failure on line 616 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on macos-latest

Unexpected any. Specify a different type

Check failure on line 616 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

Unexpected any. Specify a different type

Check failure on line 616 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on windows-latest

Unexpected any. Specify a different type
console.error("Error using Anthropic API:", error);

// Add specific handling for Claude's limitations
Expand Down Expand Up @@ -728,14 +728,14 @@
// Update progress status
if (mainWindow) {
mainWindow.webContents.send("processing-status", {
message: "Creating optimal solution with detailed explanations...",
message: "Creating brute-force better-approach & optimal solution with detailed explanations...",
progress: 60
});
}

// Create prompt for solution generation
const promptText = `
Generate a detailed solution for the following coding problem:
Generate brute-force better approach and optimal solution for the following coding problem:

PROBLEM STATEMENT:
${problemInfo.problem_statement}
Expand Down Expand Up @@ -777,7 +777,7 @@
const solutionResponse = await this.openaiClient.chat.completions.create({
model: config.solutionModel || "gpt-4o",
messages: [
{ role: "system", content: "You are an expert coding interview assistant. Provide clear, optimal solutions with detailed explanations." },
{ role: "system", content: "You are an expert coding interview assistant.Provide Brute-Force Better Approach & Optimal solutions with detailed explanations." },
Copy link
Preview

Copilot AI May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing space after the period in the system message; please insert a space (i.e., 'assistant. Provide') for better readability.

Suggested change
{ role: "system", content: "You are an expert coding interview assistant.Provide Brute-Force Better Approach & Optimal solutions with detailed explanations." },
{ role: "system", content: "You are an expert coding interview assistant. Provide Brute-Force Better Approach & Optimal solutions with detailed explanations." },

Copilot uses AI. Check for mistakes.

{ role: "user", content: promptText }
],
max_tokens: 4000,
Expand All @@ -801,7 +801,7 @@
role: "user",
parts: [
{
text: `You are an expert coding interview assistant. Provide a clear, optimal solution with detailed explanations for this problem:\n\n${promptText}`
text: `You are an expert coding interview assistant. Provide Brute-Force Approach Better Approach & Optimal solution with detailed explanations for this problem:\n\n${promptText}`
}
]
}
Expand Down Expand Up @@ -889,12 +889,12 @@
}

// Extract parts from the response
const codeMatch = responseContent.match(/```(?:\w+)?\s*([\s\S]*?)```/);

Check failure on line 892 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'responseContent' is possibly 'null' or 'undefined'.
const code = codeMatch ? codeMatch[1].trim() : responseContent;

// Extract thoughts, looking for bullet points or numbered lists
const thoughtsRegex = /(?:Thoughts:|Key Insights:|Reasoning:|Approach:)([\s\S]*?)(?:Time complexity:|$)/i;
const thoughtsMatch = responseContent.match(thoughtsRegex);

Check failure on line 897 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'responseContent' is possibly 'null' or 'undefined'.
let thoughts: string[] = [];

if (thoughtsMatch && thoughtsMatch[1]) {
Expand All @@ -919,7 +919,7 @@
let timeComplexity = "O(n) - Linear time complexity because we only iterate through the array once. Each element is processed exactly one time, and the hashmap lookups are O(1) operations.";
let spaceComplexity = "O(n) - Linear space complexity because we store elements in the hashmap. In the worst case, we might need to store all elements before finding the solution pair.";

const timeMatch = responseContent.match(timeComplexityPattern);

Check failure on line 922 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'responseContent' is possibly 'null' or 'undefined'.
if (timeMatch && timeMatch[1]) {
timeComplexity = timeMatch[1].trim();
if (!timeComplexity.match(/O\([^)]+\)/i)) {
Expand All @@ -934,7 +934,7 @@
}
}

const spaceMatch = responseContent.match(spaceComplexityPattern);

Check failure on line 937 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'responseContent' is possibly 'null' or 'undefined'.
if (spaceMatch && spaceMatch[1]) {
spaceComplexity = spaceMatch[1].trim();
if (!spaceComplexity.match(/O\([^)]+\)/i)) {
Expand Down Expand Up @@ -1255,7 +1255,7 @@
}

let extractedCode = "// Debug mode - see analysis below";
const codeMatch = debugContent.match(/```(?:[a-zA-Z]+)?([\s\S]*?)```/);

Check failure on line 1258 in electron/ProcessingHelper.ts

View workflow job for this annotation

GitHub Actions / Build and Test on ubuntu-latest

'debugContent' is possibly 'null' or 'undefined'.
if (codeMatch && codeMatch[1]) {
extractedCode = codeMatch[1].trim();
}
Expand Down
Empty file modified stealth-run.sh
100644 → 100755
Empty file.
Loading