Skip to content

Commit 11c98fd

Browse files
committed
add properties for chat component
1 parent bf3810f commit 11c98fd

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
// client/packages/lowcoder/src/comps/comps/chatComp/chatCompTypes.ts
2-
import { StringControl } from "comps/controls/codeControl";
2+
import { StringControl, NumberControl } from "comps/controls/codeControl";
33
import { withDefault } from "comps/generators";
4+
import { BoolControl } from "comps/controls/boolControl";
5+
import { dropdownControl } from "comps/controls/dropdownControl";
6+
7+
// Model type dropdown options
8+
const ModelTypeOptions = [
9+
{ label: "Direct LLM", value: "direct-llm" },
10+
{ label: "n8n Workflow", value: "n8n" },
11+
] as const;
412

513
export const chatChildrenMap = {
614
text: withDefault(StringControl, "Chat Component Placeholder"),
15+
modelHost: withDefault(StringControl, "http://localhost:11434"),
16+
modelType: dropdownControl(ModelTypeOptions, "direct-llm"),
17+
streaming: BoolControl.DEFAULT_TRUE,
18+
systemPrompt: withDefault(StringControl, "You are a helpful assistant."),
19+
agent: BoolControl,
20+
maxInteractions: withDefault(NumberControl, 10),
721
};
822

923
export type ChatCompProps = {
1024
text: string;
25+
modelHost: string;
26+
modelType: "direct-llm" | "n8n";
27+
streaming: boolean;
28+
systemPrompt: string;
29+
agent: boolean;
30+
maxInteractions: number;
1131
};

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import React from "react";
33
import { Section, sectionNames } from "lowcoder-design";
44

55
export const ChatPropertyView = React.memo((props: any) => {
6+
const { children } = props;
7+
68
return (
79
<Section name={sectionNames.basic}>
8-
{props.children.text.propertyView({
9-
label: "Text"
10-
})}
10+
{children.text.propertyView({ label: "Text" })}
11+
{children.modelHost.propertyView({ label: "Model Host URL" })}
12+
{children.modelType.propertyView({ label: "Model Type" })}
13+
{children.streaming.propertyView({ label: "Streaming Responses" })}
14+
{children.systemPrompt.propertyView({ label: "System Prompt" })}
15+
{children.agent.propertyView({ label: "Agent Mode" })}
16+
{children.maxInteractions.propertyView({ label: "Max Interactions" })}
1117
</Section>
1218
);
1319
});

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ import "@assistant-ui/styles/markdown.css";
1414
export const ChatView = React.memo((props: ChatCompProps) => {
1515
// Create proper runtime using useChatRuntime
1616
const runtime = useChatRuntime({
17-
api: "/api/chat", // We'll create this endpoint later
18-
});
17+
api: props.modelHost,
18+
stream: props.streaming,
19+
modelType: props.modelType as any,
20+
systemPrompt: props.systemPrompt,
21+
agent: props.agent,
22+
maxTurns: props.maxInteractions,
23+
} as any);
1924

2025
return (
2126
<AssistantRuntimeProvider runtime={runtime}>

0 commit comments

Comments
 (0)