diff --git a/ui/CHANGELOG.md b/ui/CHANGELOG.md index 3a69289d56..e585e44797 100644 --- a/ui/CHANGELOG.md +++ b/ui/CHANGELOG.md @@ -12,6 +12,13 @@ All notable changes to the **Prowler UI** are documented in this file. ### ❌ Removed +--- + +## [1.10.2] (Prowler v5.10.3) + +### 🐞 Fixed + +- Lighthouse using default config instead of backend config [(#8546)](https://github.com/prowler-cloud/prowler/pull/8546) --- diff --git a/ui/actions/lighthouse/lighthouse.ts b/ui/actions/lighthouse/lighthouse.ts index 181890fd77..980404c234 100644 --- a/ui/actions/lighthouse/lighthouse.ts +++ b/ui/actions/lighthouse/lighthouse.ts @@ -104,7 +104,7 @@ export const getLighthouseConfig = async () => { // Check if data array exists and has at least one item if (data?.data && data.data.length > 0) { - return data.data[0]; + return data.data[0].attributes; } return undefined; diff --git a/ui/app/(prowler)/lighthouse/config/page.tsx b/ui/app/(prowler)/lighthouse/config/page.tsx index e8e223783a..0d5632ac76 100644 --- a/ui/app/(prowler)/lighthouse/config/page.tsx +++ b/ui/app/(prowler)/lighthouse/config/page.tsx @@ -5,12 +5,12 @@ import { ContentLayout } from "@/components/ui"; export const dynamic = "force-dynamic"; export default async function ChatbotConfigPage() { - const response = await getLighthouseConfig(); - const initialValues = response?.attributes + const lighthouseConfig = await getLighthouseConfig(); + const initialValues = lighthouseConfig ? { - model: response.attributes.model, - apiKey: response.attributes.api_key || "", - businessContext: response.attributes.business_context || "", + model: lighthouseConfig.model, + apiKey: lighthouseConfig.api_key || "", + businessContext: lighthouseConfig.business_context || "", } : { model: "gpt-4o", @@ -18,7 +18,7 @@ export default async function ChatbotConfigPage() { businessContext: "", }; - const configExists = !!response; + const configExists = !!lighthouseConfig; return ( diff --git a/ui/app/(prowler)/lighthouse/page.tsx b/ui/app/(prowler)/lighthouse/page.tsx index b59cf79346..96e5ecbfb7 100644 --- a/ui/app/(prowler)/lighthouse/page.tsx +++ b/ui/app/(prowler)/lighthouse/page.tsx @@ -4,10 +4,10 @@ import { Chat } from "@/components/lighthouse"; import { ContentLayout } from "@/components/ui"; export default async function AIChatbot() { - const config = await getLighthouseConfig(); + const lighthouseConfig = await getLighthouseConfig(); - const hasConfig = !!config; - const isActive = config?.attributes?.is_active ?? false; + const hasConfig = !!lighthouseConfig; + const isActive = lighthouseConfig.is_active ?? false; return ( }> diff --git a/ui/app/api/lighthouse/analyst/route.ts b/ui/app/api/lighthouse/analyst/route.ts index 6bbf076f6e..eaabec76d6 100644 --- a/ui/app/api/lighthouse/analyst/route.ts +++ b/ui/app/api/lighthouse/analyst/route.ts @@ -25,8 +25,8 @@ export async function POST(req: Request) { const processedMessages = [...messages]; // Get AI configuration to access business context - const aiConfig = await getLighthouseConfig(); - const businessContext = aiConfig?.data?.attributes?.business_context; + const lighthouseConfig = await getLighthouseConfig(); + const businessContext = lighthouseConfig.business_context; // Get current user data const currentData = await getCurrentDataSection(); diff --git a/ui/lib/lighthouse/workflow.ts b/ui/lib/lighthouse/workflow.ts index faa7f02f4c..dc264339bb 100644 --- a/ui/lib/lighthouse/workflow.ts +++ b/ui/lib/lighthouse/workflow.ts @@ -44,22 +44,21 @@ import { export async function initLighthouseWorkflow() { const apiKey = await getAIKey(); - const aiConfig = await getLighthouseConfig(); - const modelConfig = aiConfig?.data?.attributes; + const lighthouseConfig = await getLighthouseConfig(); // Initialize models without API keys const llm = new ChatOpenAI({ - model: modelConfig?.model || "gpt-4o", - temperature: modelConfig?.temperature || 0, - maxTokens: modelConfig?.max_tokens || 4000, + model: lighthouseConfig.model, + temperature: lighthouseConfig.temperature, + maxTokens: lighthouseConfig.max_tokens, apiKey: apiKey, tags: ["agent"], }); const supervisorllm = new ChatOpenAI({ - model: modelConfig?.model || "gpt-4o", - temperature: modelConfig?.temperature || 0, - maxTokens: modelConfig?.max_tokens || 4000, + model: lighthouseConfig.model, + temperature: lighthouseConfig.temperature, + maxTokens: lighthouseConfig.max_tokens, apiKey: apiKey, streaming: true, tags: ["supervisor"],