Skip to content

Add AI assistant for community posts#29

Open
Worldfickler wants to merge 1 commit into
AlphaQuantKit:mainfrom
Worldfickler:feature/community-ai-assistant
Open

Add AI assistant for community posts#29
Worldfickler wants to merge 1 commit into
AlphaQuantKit:mainfrom
Worldfickler:feature/community-ai-assistant

Conversation

@Worldfickler

Copy link
Copy Markdown

Summary

  • Add configurable OpenAI-compatible LLM settings.
  • Add AI summary and comment draft assistant for Support Community posts.
  • Cache generated summaries per post to avoid repeated LLM calls.
  • Add draggable, resizable, collapsible assistant card.

Notes

  • The assistant only appears when AI is enabled in settings.
  • Base URL and model are user-configurable.
  • Connectivity is tested before saving enabled AI settings.

image

Copilot AI review requested due to automatic review settings July 9, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an “AI Forum Assistant” feature to the extension for WorldQuant Support Community posts, including user-configurable OpenAI-compatible LLM settings, cached AI summaries per post, and UI to draft/insert/post AI-generated comments.

Changes:

  • Adds LLM configuration fields (enable toggle, base URL, model, API key) to the sidebar settings panel, with a connectivity test on save.
  • Introduces a content-script assistant card on Support Community post pages (summary generation, cached summary load, comment drafting/insertion/posting).
  • Adds background services for LLM calls and Support Community AI summary/draft/comment-post actions, plus message routing and manifest wiring.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/ui/sidebar/sidebar.html Adds sidebar UI inputs for AI/LLM configuration.
src/ui/sidebar/modules/settingsPanel.js Reads/writes LLM config, masks stored API key, and saves settings + tests LLM connectivity.
src/content/support/communityAssistant.js New content script providing the assistant card UI and interactions on Support Community posts.
src/content/support/communityAssistant.css Styles for the assistant card (draggable/resizable/collapsible).
src/background/services/supportCommunityService.js Adds AI summary/draft/comment posting logic + caching in community state.
src/background/services/sidebarMessageRouter.js Routes new sidebar/content messages for LLM config and AI actions.
src/background/services/llmService.js New LLM config persistence, connectivity test, and OpenAI-compatible chat-completions calls.
manifest.json Registers the new content script/CSS and adds localhost HTTP host permissions for local endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +51 to +55
const apiKeyInput = document.getElementById(ids.llmApiKey);
hasSavedLlmApiKey = config.hasApiKey === true;
apiKeyInput.value = hasSavedLlmApiKey ? '********' : '';
apiKeyInput.placeholder = hasSavedLlmApiKey ? 'Saved API key' : 'Required unless your endpoint does not need it';
}
Comment on lines +167 to +172
if (llmConfig.enabled) {
setStatus('Testing AI model connection...');
}
const savedLlmConfig = await sendMessage('WQP_LLM_CONFIG_SAVE', { config: llmConfig });
writeLlmConfigToForm(savedLlmConfig || {});
setStatus(llmConfig.enabled ? 'Settings saved. AI model connection test passed.' : 'Settings saved. AI is disabled.', 'success');
Comment on lines +76 to +81
export async function runLlmJson({ systemPrompt, userPrompt, schemaName = 'result' }) {
const config = await getLlmConfigRaw();
if (!config.enabled) throw new Error('AI is disabled. Please enable AI in the extension side panel.');
if (!config.model) throw new Error('AI model is not configured.');
return runLlmJsonWithConfig(config, { systemPrompt, userPrompt, schemaName });
}
Comment on lines +83 to +88
export async function runLlmText({ systemPrompt, userPrompt, taskName = 'result' }) {
const config = await getLlmConfigRaw();
if (!config.enabled) throw new Error('AI is disabled. Please enable AI in the extension side panel.');
if (!config.model) throw new Error('AI model is not configured.');
return runLlmTextWithConfig(config, { systemPrompt, userPrompt, taskName });
}
Comment on lines +123 to +127
const content = data?.choices?.[0]?.message?.content;
if (typeof content !== 'string' || !content.trim()) {
throw new Error('LLM connectivity check returned an empty response.');
}
return true;
Comment on lines +279 to +284
const source = data.source || {};
const commentCount = `${source.commentCount || 0}/${source.totalCommentCount || 0}`;
const cacheTime = formatDateTime(data.cache?.savedAt || source.fetchedAt);
const statusText = data.cached ? 'Loaded cached summary.' : 'Summary generated and saved.';
const markdown = data.summaryMarkdown || '';
setCardContent(`
Comment on lines +50 to +54
function markdownToHtml(value) {
const lines = String(value || '').replace(/\r\n/g, '\n').split('\n');
const blocks = [];
let paragraph = [];
let listItems = [];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants