Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
61e56f1
chore(deps): add mistralai
AAClause Mar 8, 2025
1dd3853
feat(mistralai_engine): migrate from OpenAI to MistralAI module for e…
AAClause Mar 9, 2025
9cd2509
feat(mistralai_engine): add Document Understanding support
AAClause Mar 9, 2025
4c2c24d
docs(mistralai_engine): update models documentation URL
AAClause Mar 9, 2025
22f4ead
feat: initial OCR support
AAClause Mar 9, 2025
20b4f77
Merge remote-tracking branch 'origin/master' into mistralai
AAClause Mar 15, 2025
1aedc46
fix: correct cyclomatic complexity
AAClause Mar 15, 2025
2e7e5cb
feat(gui): toggle OCR button with attachments visibility
AAClause Mar 15, 2025
420bf35
Merge branch 'master' into mistralai
AAClause Mar 15, 2025
75b3aeb
refactor(mistralai_engine): extract OCR functionality into a separate…
AAClause Mar 16, 2025
90392e3
refactor(conversation_tab): extract OCR functionality into a separate…
AAClause Mar 16, 2025
5a8411f
fix(process_helper): handle task cancellation in run_task function in…
AAClause Mar 16, 2025
fcdbcfd
fix: correct docstrings to comply with Ruff standards
AAClause Mar 16, 2025
3bc4ec4
Merge remote-tracking branch 'origin/master' into mistralai
AAClause Jun 6, 2025
9793983
feat(ocr/mistral): added prompt to open files after OCR completes
AAClause Jun 8, 2025
c1b7a48
Update basilisk/gui/ocr_handler.py
AAClause Jun 8, 2025
fd02821
Merge remote-tracking branch 'origin/master' into mistralai
AAClause Jun 8, 2025
b2d45e3
Update basilisk/gui/ocr_handler.py
AAClause Jun 8, 2025
6cd5a27
style(pre-commit.ci): auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 8, 2025
83e0e29
chore(mistralai_engine): Update models
AAClause Jun 8, 2025
eda9d12
Update basilisk/gui/ocr_handler.py
AAClause Jun 8, 2025
c6bd7be
Update basilisk/gui/ocr_handler.py
AAClause Jun 8, 2025
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
4 changes: 3 additions & 1 deletion basilisk/gui/account_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,13 @@ def _update_base_url_fields(self, provider: Provider) -> None:
self.custom_base_url_text_ctrl.Enable(provider.allow_custom_base_url)
default_base_url = provider.base_url
if default_base_url:
# Translators: A label in account dialog
self.custom_base_url_label.SetLabel(
_("Custom &base URL (default: {})").format(default_base_url)
)
else:
self.custom_base_url_label.SetLabel(_("Custom &base URL"))
# Translators: A label in account dialog
self.custom_base_url_label.SetLabel(_("Custom &base URL:"))

def on_ok(self, event: wx.CommandEvent) -> None:
"""Handle the OK button click event.
Expand Down
21 changes: 20 additions & 1 deletion basilisk/gui/conversation_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re
import threading
import time
from multiprocessing import Process
from typing import TYPE_CHECKING, Any, Optional

import wx
Expand Down Expand Up @@ -51,6 +52,7 @@

from .base_conversation import BaseConversation
from .history_msg_text_ctrl import HistoryMsgTextCtrl
from .ocr_handler import OCRHandler

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix relative import beyond top-level package

The relative import is causing an error. Change to absolute import:

-from .ocr_handler import OCRHandler
+from basilisk.gui.ocr_handler import OCRHandler
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from .ocr_handler import OCRHandler
from basilisk.gui.ocr_handler import OCRHandler
🧰 Tools
🪛 Pylint (3.3.7)

[error] 55-55: Attempted relative import beyond top-level package

(E0402)

🤖 Prompt for AI Agents
In basilisk/gui/conversation_tab.py at line 55, the relative import of
OCRHandler is causing an error due to being beyond the top-level package. Change
the import statement to use an absolute import path that starts from the
top-level package to fix the import error.

from .read_only_message_dialog import ReadOnlyMessageDialog

if TYPE_CHECKING:
Expand All @@ -62,6 +64,8 @@
log = logging.getLogger(__name__)
accessible_output = get_accessible_output()

CHECK_TASK_DELAY = 100 # ms

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Expose CHECK_TASK_DELAY configurability

Having a 100ms delay for checking task progress is fine for most scenarios. Consider making this a configurable constant for easier tuning if needed.



class ConversationTab(wx.Panel, BaseConversation):
"""A tab panel that manages a single conversation with an AI assistant.
Expand Down Expand Up @@ -164,7 +168,9 @@ def __init__(
self.last_time = 0
self.recording_thread: Optional[RecordingThread] = None
self.task = None
self.process: Optional[Process] = None
self._stop_completion = False
self.ocr_handler = OCRHandler(self)
Comment on lines +171 to +173

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix indentation: use tabs instead of spaces

Multiple lines have incorrect indentation using spaces instead of tabs. Fix all indentation issues:

-		self.process: Optional[Process] = None
+	self.process: Optional[Process] = None
-		self._stop_completion = False
+	self._stop_completion = False
-		self.ocr_handler = OCRHandler(self)
+	self.ocr_handler = OCRHandler(self)

-		self.ocr_button = self.ocr_handler.create_ocr_widget(self)
+	self.ocr_button = self.ocr_handler.create_ocr_widget(self)
-		sizer.Add(self.ocr_button, proportion=0, flag=wx.EXPAND)
+	sizer.Add(self.ocr_button, proportion=0, flag=wx.EXPAND)

-		self.ocr_button.Enable(
-			ProviderCapability.OCR in account.provider.engine_cls.capabilities
-		)
+	self.ocr_button.Enable(
+		ProviderCapability.OCR in account.provider.engine_cls.capabilities
+	)

-			self.ocr_button.Hide()
+		self.ocr_button.Hide()

-		self.ocr_button.Show()
+	self.ocr_button.Show()

-	def check_attachments_valid(self) -> bool:
-		"""Check if all attachments are valid and supported by the current provider.
+def check_attachments_valid(self) -> bool:
+	"""Check if all attachments are valid and supported by the current provider.

-		if not self.check_attachments_valid():
+	if not self.check_attachments_valid():

Also applies to: 261-262, 377-379, 724-729, 1155-1156, 1189-1189

🧰 Tools
🪛 Pylint (3.3.7)

[warning] 171-171: Bad indentation. Found 2 spaces, expected 8

(W0311)


[warning] 172-172: Bad indentation. Found 2 spaces, expected 8

(W0311)


[warning] 173-173: Bad indentation. Found 2 spaces, expected 8

(W0311)

🤖 Prompt for AI Agents
In basilisk/gui/conversation_tab.py at lines 171-173 and also at lines 261-262,
377-379, 724-729, 1155-1156, and 1189, the indentation uses spaces instead of
tabs. Replace all leading spaces with tabs for these lines to maintain
consistent indentation style throughout the file.

self.init_ui()
self.init_data(profile)
self.adjust_advanced_mode_setting()
Expand Down Expand Up @@ -251,6 +257,10 @@ def init_ui(self):
self.attachments_list.SetColumnWidth(1, 100)
self.attachments_list.SetColumnWidth(2, 500)
sizer.Add(self.attachments_list, proportion=0, flag=wx.ALL | wx.EXPAND)

self.ocr_button = self.ocr_handler.create_ocr_widget(self)
sizer.Add(self.ocr_button, proportion=0, flag=wx.EXPAND)

label = self.create_model_widget()
sizer.Add(label, proportion=0, flag=wx.EXPAND)
sizer.Add(self.model_list, proportion=0, flag=wx.ALL | wx.EXPAND)
Expand Down Expand Up @@ -364,6 +374,9 @@ def on_account_change(self, event: wx.CommandEvent | None):
self.toggle_record_btn.Enable(
ProviderCapability.STT in account.provider.engine_cls.capabilities
)
self.ocr_button.Enable(
ProviderCapability.OCR in account.provider.engine_cls.capabilities
)
self.web_search_mode.Enable(
ProviderCapability.WEB_SEARCH
in account.provider.engine_cls.capabilities
Expand Down Expand Up @@ -708,10 +721,12 @@ def refresh_attachments_list(self):
if not self.attachment_files:
self.attachments_list_label.Hide()
self.attachments_list.Hide()
self.ocr_button.Hide()
self.Layout()
return
self.attachments_list_label.Show()
self.attachments_list.Show()
self.ocr_button.Show()
Comment on lines +724 to +729

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Conditional visibility for OCR button

Hiding the OCR button when no attachments exist can prevent user confusion. However, if a user wants to attach later without re-showing the button, re-check logic carefully.

for attachment in self.attachment_files:
self.attachments_list.Append(attachment.get_display_info())
last_index = len(self.attachment_files) - 1
Expand Down Expand Up @@ -1138,6 +1153,11 @@ def get_completion_args(self) -> dict[str, Any] | None:
}

def _check_attachments_valid(self) -> bool:
"""Check if all attachments are valid and supported by the current provider.

Returns:
True if all attachments are valid, False otherwise
"""
supported_attachment_formats = (
self.current_engine.supported_attachment_formats
)
Expand All @@ -1158,7 +1178,6 @@ def _check_attachments_valid(self) -> bool:
invalid_found = True
return not invalid_found

@ensure_no_task_running
def on_submit(self, event: wx.CommandEvent):
"""Handle the submission of a new message block for completion.

Expand Down
Loading