mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
fix: Refactor getting lighthouse config (#8546)
Co-authored-by: Chandrapal Badshah <12944530+Chan9390@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
6a8e8750bb
commit
d54e3b25db
@@ -19,6 +19,7 @@ All notable changes to the **Prowler UI** are documented in this file.
|
||||
### 🐞 Fixed
|
||||
|
||||
- DataTable column headers set to single-line [(#8480)](https://github.com/prowler-cloud/prowler/pull/8480)
|
||||
- Lighthouse using default config instead of backend config [(#8546)](https://github.com/prowler-cloud/prowler/pull/8546)
|
||||
|
||||
### ❌ Removed
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 (
|
||||
<ContentLayout title="Configure Lighthouse AI" icon="lucide:settings">
|
||||
|
||||
@@ -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 (
|
||||
<ContentLayout title="Lighthouse AI" icon={<LighthouseIcon />}>
|
||||
|
||||
@@ -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?.attributes?.business_context;
|
||||
const lighthouseConfig = await getLighthouseConfig();
|
||||
const businessContext = lighthouseConfig.business_context;
|
||||
|
||||
// Get current user data
|
||||
const currentData = await getCurrentDataSection();
|
||||
|
||||
@@ -50,22 +50,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"],
|
||||
|
||||
Reference in New Issue
Block a user