Skip to content

Commit 7fd74ca

Browse files
committed
remove unnecessary settings from the AI chat component
1 parent 4d22430 commit 7fd74ca

5 files changed

Lines changed: 46 additions & 90 deletions

File tree

client/packages/lowcoder/src/comps/comps/chatComp/chatComp.tsx

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ import { StringControl } from "comps/controls/codeControl";
66
import { arrayObjectExposingStateControl, stringExposingStateControl } from "comps/controls/codeStateControl";
77
import { JSONObject } from "util/jsonTypes";
88
import { withDefault } from "comps/generators";
9-
import { BoolControl } from "comps/controls/boolControl";
10-
import { dropdownControl } from "comps/controls/dropdownControl";
119
import QuerySelectControl from "comps/controls/querySelectControl";
1210
import { eventHandlerControl, EventConfigType } from "comps/controls/eventHandlerControl";
1311
import { AutoHeightControl } from "comps/controls/autoHeightControl";
1412
import { ChatContainer } from "./components/ChatContainer";
1513
import { ChatProvider } from "./components/context/ChatContext";
1614
import { ChatPropertyView } from "./chatPropertyView";
1715
import { createChatStorage } from "./utils/storageFactory";
18-
import { QueryHandler, createMessageHandler } from "./handlers/messageHandlers";
16+
import { QueryHandler } from "./handlers/messageHandlers";
1917
import { useMemo, useRef, useEffect } from "react";
2018
import { changeChildAction } from "lowcoder-core";
2119
import { ChatMessage } from "./types/chatTypes";
@@ -143,21 +141,13 @@ function generateUniqueTableName(): string {
143141
return `chat${Math.floor(1000 + Math.random() * 9000)}`;
144142
}
145143

146-
const ModelTypeOptions = [
147-
{ label: trans("chat.handlerTypeQuery"), value: "query" },
148-
{ label: trans("chat.handlerTypeN8N"), value: "n8n" },
149-
] as const;
150-
151144
export const chatChildrenMap = {
152-
// Storage
153-
// Storage (add the hidden property here)
145+
// Storage (internal, hidden)
154146
_internalDbName: withDefault(StringControl, ""),
147+
155148
// Message Handler Configuration
156-
handlerType: dropdownControl(ModelTypeOptions, "query"),
157-
chatQuery: QuerySelectControl, // Only used for "query" type
158-
modelHost: withDefault(StringControl, ""), // Only used for "n8n" type
149+
chatQuery: QuerySelectControl,
159150
systemPrompt: withDefault(StringControl, trans("chat.defaultSystemPrompt")),
160-
streaming: BoolControl.DEFAULT_TRUE,
161151

162152
// UI Configuration
163153
placeholder: withDefault(StringControl, trans("chat.defaultPlaceholder")),
@@ -220,36 +210,14 @@ const ChatTmpComp = new UICompBuilder(
220210
[]
221211
);
222212

223-
// Create message handler based on type
213+
// Create message handler (Query only)
224214
const messageHandler = useMemo(() => {
225-
const handlerType = props.handlerType;
226-
227-
if (handlerType === "query") {
228-
return new QueryHandler({
229-
chatQuery: props.chatQuery.value,
230-
dispatch,
231-
streaming: props.streaming,
232-
});
233-
} else if (handlerType === "n8n") {
234-
return createMessageHandler("n8n", {
235-
modelHost: props.modelHost,
236-
systemPrompt: props.systemPrompt,
237-
streaming: props.streaming
238-
});
239-
} else {
240-
// Fallback to mock handler
241-
return createMessageHandler("mock", {
242-
chatQuery: props.chatQuery.value,
243-
dispatch,
244-
streaming: props.streaming
245-
});
246-
}
215+
return new QueryHandler({
216+
chatQuery: props.chatQuery.value,
217+
dispatch,
218+
});
247219
}, [
248-
props.handlerType,
249220
props.chatQuery,
250-
props.modelHost,
251-
props.systemPrompt,
252-
props.streaming,
253221
dispatch,
254222
]);
255223

client/packages/lowcoder/src/comps/comps/chatComp/chatCompTypes.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ export type ChatCompProps = {
88
// Storage
99
tableName: string;
1010

11-
// Message Handler
12-
handlerType: "query" | "n8n";
13-
chatQuery: string; // Only used when handlerType === "query"
14-
modelHost: string; // Only used when handlerType === "n8n"
11+
// Message Handler (Query only)
12+
chatQuery: string;
1513
systemPrompt: string;
16-
streaming: boolean;
1714

1815
// UI
1916
placeholder: string;

client/packages/lowcoder/src/comps/comps/chatComp/chatPropertyView.tsx

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { useMemo } from "react";
44
import { Section, sectionNames, DocLink } from "lowcoder-design";
55
import { trans } from "i18n";
66
import { hiddenPropertyView } from "comps/utils/propertyUtils";
7+
import { controlItem } from "lowcoder-design";
78

89
// ============================================================================
910
// CLEAN PROPERTY VIEW - FOCUSED ON ESSENTIAL CONFIGURATION
@@ -27,38 +28,16 @@ export const ChatPropertyView = React.memo((props: any) => {
2728

2829
{/* Message Handler Configuration */}
2930
<Section name={trans("chat.messageHandler")}>
30-
{children.handlerType.propertyView({
31-
label: trans("chat.handlerType"),
32-
tooltip: trans("chat.handlerTypeTooltip"),
31+
{children.chatQuery.propertyView({
32+
label: trans("chat.chatQuery"),
33+
placeholder: trans("chat.chatQueryPlaceholder"),
3334
})}
3435

35-
{/* Conditional Query Selection */}
36-
{children.handlerType.getView() === "query" && (
37-
children.chatQuery.propertyView({
38-
label: trans("chat.chatQuery"),
39-
placeholder: trans("chat.chatQueryPlaceholder"),
40-
})
41-
)}
42-
43-
{/* Conditional N8N Configuration */}
44-
{children.handlerType.getView() === "n8n" && (
45-
children.modelHost.propertyView({
46-
label: trans("chat.modelHost"),
47-
placeholder: trans("chat.modelHostPlaceholder"),
48-
tooltip: trans("chat.modelHostTooltip"),
49-
})
50-
)}
51-
5236
{children.systemPrompt.propertyView({
5337
label: trans("chat.systemPrompt"),
5438
placeholder: trans("chat.systemPromptPlaceholder"),
5539
tooltip: trans("chat.systemPromptTooltip"),
5640
})}
57-
58-
{children.streaming.propertyView({
59-
label: trans("chat.streaming"),
60-
tooltip: trans("chat.streamingTooltip"),
61-
})}
6241
</Section>
6342

6443
{/* UI Configuration */}
@@ -81,11 +60,37 @@ export const ChatPropertyView = React.memo((props: any) => {
8160

8261
{/* Database Section */}
8362
<Section name={trans("chat.database")}>
84-
{children.databaseName.propertyView({
85-
label: trans("chat.databaseName"),
86-
tooltip: trans("chat.databaseNameTooltip"),
87-
readonly: true
88-
})}
63+
{controlItem(
64+
{ filterText: trans("chat.databaseName") },
65+
<div style={{ padding: "8px 16px" }}>
66+
<div style={{
67+
fontSize: "13px",
68+
color: "#8B8FA3",
69+
marginBottom: "4px",
70+
fontWeight: 500
71+
}}>
72+
{trans("chat.databaseName")}
73+
</div>
74+
<div style={{
75+
fontSize: "13px",
76+
color: "#222222",
77+
padding: "6px 12px",
78+
backgroundColor: "#F5F5F6",
79+
borderRadius: "4px",
80+
border: "1px solid #D7D9E0",
81+
fontFamily: "monospace"
82+
}}>
83+
{children.databaseName.getView() || "Not initialized"}
84+
</div>
85+
<div style={{
86+
fontSize: "12px",
87+
color: "#8B8FA3",
88+
marginTop: "4px"
89+
}}>
90+
{trans("chat.databaseNameTooltip")}
91+
</div>
92+
</div>
93+
)}
8994
</Section>
9095

9196
{/* STANDARD EVENT HANDLERS SECTION */}

client/packages/lowcoder/src/comps/comps/chatComp/types/chatTypes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export interface ChatMessage {
6363
export interface QueryHandlerConfig {
6464
chatQuery: string;
6565
dispatch: any;
66-
streaming?: boolean;
67-
systemPrompt?: string;
6866
}
6967

7068
// ============================================================================

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,18 +1443,11 @@ export const en = {
14431443

14441444
"chat": {
14451445
// Property View Labels & Tooltips
1446-
"handlerType": "Handler Type",
1447-
"handlerTypeTooltip": "How messages are processed",
14481446
"chatQuery": "Chat Query",
14491447
"chatQueryPlaceholder": "Select a query to handle messages",
1450-
"modelHost": "N8N Webhook URL",
1451-
"modelHostPlaceholder": "http://localhost:5678/webhook/...",
1452-
"modelHostTooltip": "N8N webhook endpoint for processing messages",
14531448
"systemPrompt": "System Prompt",
14541449
"systemPromptPlaceholder": "You are a helpful assistant...",
14551450
"systemPromptTooltip": "Initial instructions for the AI",
1456-
"streaming": "Enable Streaming",
1457-
"streamingTooltip": "Stream responses in real-time (when supported)",
14581451
"databaseName": "Database Name",
14591452
"databaseNameTooltip": "Auto-generated database name for this chat component (read-only)",
14601453

@@ -1475,11 +1468,6 @@ export const en = {
14751468

14761469
// Error Messages
14771470
"errorUnknown": "Sorry, I encountered an error. Please try again.",
1478-
1479-
// Handler Types
1480-
"handlerTypeQuery": "Query",
1481-
"handlerTypeN8N": "N8N Workflow",
1482-
14831471
// Section Names
14841472
"messageHandler": "Message Handler",
14851473
"uiConfiguration": "UI Configuration",

0 commit comments

Comments
 (0)