Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ interface BitteAiChatProps {
agentName?: string; // Custom agent name
agentImage?: string; // Custom agent image URL
chatId?: string; // Custom chat ID
prompt?: string // Custom Initial prompt
};
welcomeMessageComponent?: JSX.Element; // Custom Welcome Message to be displayed when the chat loads
mobileInputExtraButton?: JSX.Element // Custom Button to add in mobile next to 'Send'
Expand Down
1 change: 1 addition & 0 deletions src/components/BitteAiChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const BitteAiChat = ({
agentImage: options?.agentImage,
chatId: options?.chatId ?? (chatId || undefined),
localAgent: options?.localAgent,
prompt: options?.prompt,
}}
welcomeMessageComponent={welcomeMessageComponent}
mobileInputExtraButton={mobileInputExtraButton}
Expand Down
13 changes: 12 additions & 1 deletion src/components/chat/ChatContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ChatContent = ({
options,
messages: initialMessages,
welcomeMessageComponent,
mobileInputExtraButton
mobileInputExtraButton,
}: BitteAiChatProps) => {
const chatId = useRef(options?.chatId || generateId()).current;
const [isAtBottom, setIsAtBottom] = useState(true);
Expand All @@ -59,6 +59,7 @@ export const ChatContent = ({
handleSubmit,
reload,
addToolResult,
append,
error,
} = useChat({
maxSteps: 7,
Expand Down Expand Up @@ -165,6 +166,16 @@ export const ChatContent = ({
setAutoScrollEnabled(true);
}, [scrollToBottom]);

useEffect(() => {
if (options?.prompt && messages.length === 0 && !isInProgress) {
append({
id: generateId(),
role: "user",
content: options.prompt,
});
}
}, [messages.length, isInProgress, options]);

return (
<div className='bitte-flex bitte-h-full bitte-w-full bitte-flex-col bitte-gap-4 bitte-text-justify'>
<div
Expand Down
1 change: 1 addition & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export interface BitteAiChatProps {
agentName?: string;
agentImage?: string;
chatId?: string;
prompt?: string;
localAgent?: {
pluginId: string;
accountId: string;
Expand Down