feat: Add opt-in AI Chat Assistant dock panel (OpenAI-compatible API)#580
Open
Vickyrrrrrr wants to merge 4 commits into
Open
feat: Add opt-in AI Chat Assistant dock panel (OpenAI-compatible API)#580Vickyrrrrrr wants to merge 4 commits into
Vickyrrrrrr wants to merge 4 commits into
Conversation
…port - Add cq_editor/widgets/ai_chat.py: new QDockWidget with chat UI, async LLM calls via QThread, context injection (sends current editor code to LLM), and one-click code insertion + auto-run - Edit cq_editor/main_window.py: register AIChatWidget as a dockable panel, wire insert_code signal to editor, add View menu toggle - Edit cq_editor/preferences.py: add AI Settings preference group (provider, model, API key, base URL, enabled toggle) All AI features are optional and guarded; existing behavior unchanged.
feat: Add AI Chat Assistant dock panel (OpenAI-compatible, opt-in)
docs: update README with AI Chat Assistant feature and usage guide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Adds an AI Chat Assistant as an optional, dockable panel inside CQ-editor.
Users can describe what they want to model in plain English, receive valid
CadQuery code from any OpenAI-compatible LLM, and insert it directly into
the editor — all without leaving the app.
Motivation
CadQuery is powerful but has a steep learning curve for new users. An
in-editor AI assistant lowers that barrier significantly: instead of
looking up API docs, users can describe intent ("make a box with filleted
edges") and get runnable code instantly. Power users benefit too — they
can ask the AI to iterate on an existing model using the current script
as context.
Changes
cq_editor/widgets/ai_chat.py(new file)AIChatWidget— dockableQWidget, integrates like any existing panelso the LLM edits the existing model rather than starting from scratch
QThread— UI never freezesoptionally triggers an immediate re-render
preferencesParameter tree: Enabled, Provider URL, Model, API Key,Auto-run — appears under Edit → Preferences → AI Assistant
cq_editor/main_window.py(minimal, additive changes only)AIChatWidgetas a dock panel (right side, default)insert_codesignal →editor.set_textHow to use
pip install openaiWorks with OpenAI, Anthropic (via OpenRouter), local Ollama, or any
OpenAI-compatible endpoint via the Provider URL field.
Compatibility
openaiis optional — guarded bytry/except ImportError; CQ-editorstarts normally without it
ai_chat.pyTesting
openaiinstalledgpt-4o,o3) and OpenRouterFuture work (follow-up PRs)