Skip to content
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
27 changes: 5 additions & 22 deletions Main/frontend/src/modules/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ function buildChatRequestBody(question, selectedModel, promptMode) {
}

// Function to get chat response from server
function getChatResponse(question, selectedModel, promptMode, useRAG, useMCP) {
// The MCP toggle used to select a dedicated 'get_mcp_response' endpoint
// that does not exist in the backend (every call 404'd). The regular
// chat endpoint already runs the LLM with the available MCP tools, so
// all modes share the two real endpoints now.
function getChatResponse(question, selectedModel, promptMode, useRAG) {
// Every mode shares the two real chat endpoints; the LLM already runs
// with the available MCP tools server-side, so there is no separate MCP
// endpoint or client-side toggle.
const endpoint = promptMode ? 'get_adv_response' : 'get_chat_response';

return fetch(buildBackendUrl(`/${endpoint}/`), {
Expand Down Expand Up @@ -130,7 +129,7 @@ function getChatResponse(question, selectedModel, promptMode, useRAG, useMCP) {
// readyState CLOSED behavior on non-200 responses;
// - the returned cleanup function cancels the stream (AbortController now,
// eventSource.close() before).
function getChatResponseStream(question, selectedModel, promptMode, useRAG, useMCP, callbacks = {}) {
function getChatResponseStream(question, selectedModel, promptMode, useRAG, callbacks = {}) {
const {
onChunk,
onSources,
Expand All @@ -139,22 +138,6 @@ function getChatResponseStream(question, selectedModel, promptMode, useRAG, useM
onStatus,
} = callbacks;

// MCP mode doesn't support streaming yet
if (useMCP) {
return getChatResponse(question, selectedModel, promptMode, useRAG, useMCP)
.then(data => {
const modelResponse = data.resp ? data.resp[selectedModel] : data.reply;
if (typeof onComplete === 'function') {
onComplete(modelResponse, data);
}
})
.catch(error => {
if (typeof onError === 'function') {
onError(error);
}
});
}

// Build SSE endpoint based on mode (research vs thinking)
const url = buildBackendUrl(promptMode ? '/get_adv_response_stream/' : '/get_chat_response_stream/');
const requestBody = JSON.stringify(buildChatRequestBody(question, selectedModel, promptMode));
Expand Down
17 changes: 0 additions & 17 deletions Main/frontend/src/modules/components/settings_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,6 @@ function createSettingsWindow(isFixedModeRef, settingsButton, positionModeButton



// —– MCP Mode Toggle —–
// MCP Mode toggle temporarily disabled
/*
const mcpLabel = document.createElement('label');
mcpLabel.className = 'settings-checkbox-label';
mcpLabel.innerText = "MCP Mode";
const mcpSwitch = document.createElement('input');
mcpSwitch.type = "checkbox";
mcpSwitch.id = "mcpModeSwitch";
mcpSwitch.style.transform = 'translate(4px, -2px)';
mcpLabel.appendChild(mcpSwitch);
*/




// RAG Section
// RAG settings temporarily disabled
/*
Expand Down Expand Up @@ -335,7 +319,6 @@ function createSettingsWindow(isFixedModeRef, settingsButton, positionModeButton
*/

// Append elements to settings window
// settings_window.appendChild(mcpLabel);
// settings_window.appendChild(ragSectionContainer);

settingsButton.onclick = function (event) {
Expand Down
22 changes: 7 additions & 15 deletions Main/frontend/src/modules/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ function createActionButtons(
userQuestion,
promptMode,
useRAG,
useMCP,
selectedModel
) {
const buttonContainer = document.createElement('div');
Expand Down Expand Up @@ -474,18 +473,14 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t
const ragSwitchEl = document.getElementById('ragSwitch');
const useRAG = ragSwitchEl ? !!ragSwitchEl.checked : false;

// Read the MCP mode toggle
const mcpSwitchEl = document.getElementById('mcpModeSwitch');
const useMCP = mcpSwitchEl ? !!mcpSwitchEl.checked : false;

const selectedModel = getSelectedModel();

// Check if streaming is available (not for MCP or RAG modes)
const canStream = useStreaming && !useMCP && !useRAG;
// Check if streaming is available (not for RAG mode)
const canStream = useStreaming && !useRAG;
if (!canStream) {
pushAgentStatus({
label: 'Processing',
detail: useMCP ? 'MCP mode' : useRAG ? 'RAG mode' : 'Standard pipeline',
detail: useRAG ? 'RAG mode' : 'Standard pipeline',
});
}

Expand All @@ -505,7 +500,6 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t
selectedModel,
promptMode,
useRAG,
useMCP,
{
// onChunk callback - called for each chunk of text
onChunk: (_chunk, fullResponse) => {
Expand Down Expand Up @@ -549,7 +543,6 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t
question,
promptMode,
useRAG,
useMCP,
selectedModel
);
attachValidateButtonIfClaims(actionButtons, {
Expand Down Expand Up @@ -638,15 +631,15 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t
);
} else {
// Use regular non-streaming response
getChatResponse(question, selectedModel, promptMode, useRAG, useMCP)
getChatResponse(question, selectedModel, promptMode, useRAG)
.then((data) => {
const endTime = performance.now();
const responseTime = endTime - startTime;
console.log(`Time taken for response: ${responseTime} ms`);

// Extract the reply. All modes (including the MCP toggle, which now
// shares the standard chat endpoint) return `data.resp[...]`; the
// `data.reply` fallback covers older servers' MCP-shaped payloads.
// Extract the reply. The chat endpoints return `data.resp[model]`;
// the `data.reply` fallback covers older servers' alternate payload
// shape.
const modelResponse = data.resp ? data.resp[selectedModel] : data.reply;

let responseText = '';
Expand All @@ -673,7 +666,6 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t
question,
promptMode,
useRAG,
useMCP,
selectedModel
);
attachValidateButtonIfClaims(actionButtons, {
Expand Down