mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-29 09:01:06 +03:00
Conversation Starters: - Updates to use the chatbot config for persistence.
This commit is contained in:
@@ -28,9 +28,6 @@ export class ChatFlow implements IChatFlow {
|
|||||||
@Column({ nullable: true, type: 'text' })
|
@Column({ nullable: true, type: 'text' })
|
||||||
apiConfig?: string
|
apiConfig?: string
|
||||||
|
|
||||||
@Column({ nullable: true, type: 'text' })
|
|
||||||
starterPrompt?: string
|
|
||||||
|
|
||||||
@Column({ nullable: true, type: 'text' })
|
@Column({ nullable: true, type: 'text' })
|
||||||
analytic?: string
|
analytic?: string
|
||||||
|
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
||||||
|
|
||||||
export class AddStarterPrompt1700565042576 implements MigrationInterface {
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
const columnExists = await queryRunner.hasColumn('chat_flow', 'starterPrompt')
|
|
||||||
if (!columnExists) queryRunner.query(`ALTER TABLE \`chat_flow\` ADD COLUMN \`starterPrompt\` TEXT;`)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE \`chat_flow\` DROP COLUMN \`starterPrompt\`;`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic'
|
|||||||
import { AddChatHistory1694658767766 } from './1694658767766-AddChatHistory'
|
import { AddChatHistory1694658767766 } from './1694658767766-AddChatHistory'
|
||||||
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
|
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
|
||||||
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
|
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
|
||||||
import { AddStarterPrompt1700565042576 } from './1700565042576-AddStarterPromptsToChatFlow'
|
|
||||||
|
|
||||||
export const mysqlMigrations = [
|
export const mysqlMigrations = [
|
||||||
Init1693840429259,
|
Init1693840429259,
|
||||||
@@ -20,6 +19,5 @@ export const mysqlMigrations = [
|
|||||||
AddAnalytic1694432361423,
|
AddAnalytic1694432361423,
|
||||||
AddChatHistory1694658767766,
|
AddChatHistory1694658767766,
|
||||||
AddAssistantEntity1699325775451,
|
AddAssistantEntity1699325775451,
|
||||||
AddUsedToolsToChatMessage1699481607341,
|
AddUsedToolsToChatMessage1699481607341
|
||||||
AddStarterPrompt1700565042576
|
|
||||||
]
|
]
|
||||||
|
|||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
||||||
|
|
||||||
export class AddStarterPrompt1700565042576 implements MigrationInterface {
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "chat_flow" ADD COLUMN IF NOT EXISTS "starterPrompt" TEXT;`)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "chat_flow" DROP COLUMN "starterPrompt";`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic'
|
|||||||
import { AddChatHistory1694658756136 } from './1694658756136-AddChatHistory'
|
import { AddChatHistory1694658756136 } from './1694658756136-AddChatHistory'
|
||||||
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
|
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
|
||||||
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
|
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
|
||||||
import { AddStarterPrompt1700565042576 } from './1700565042576-AddStarterPromptsToChatFlow'
|
|
||||||
|
|
||||||
export const postgresMigrations = [
|
export const postgresMigrations = [
|
||||||
Init1693891895163,
|
Init1693891895163,
|
||||||
@@ -20,6 +19,5 @@ export const postgresMigrations = [
|
|||||||
AddAnalytic1694432361423,
|
AddAnalytic1694432361423,
|
||||||
AddChatHistory1694658756136,
|
AddChatHistory1694658756136,
|
||||||
AddAssistantEntity1699325775451,
|
AddAssistantEntity1699325775451,
|
||||||
AddUsedToolsToChatMessage1699481607341,
|
AddUsedToolsToChatMessage1699481607341
|
||||||
AddStarterPrompt1700565042576
|
|
||||||
]
|
]
|
||||||
|
|||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
import { MigrationInterface, QueryRunner } from 'typeorm'
|
|
||||||
|
|
||||||
export class AddStarterPrompt1700565042576 implements MigrationInterface {
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "chat_flow" ADD COLUMN "starterPrompt" TEXT;`)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "chat_flow" DROP COLUMN "starterPrompt";`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ import { AddAnalytic1694432361423 } from './1694432361423-AddAnalytic'
|
|||||||
import { AddChatHistory1694657778173 } from './1694657778173-AddChatHistory'
|
import { AddChatHistory1694657778173 } from './1694657778173-AddChatHistory'
|
||||||
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
|
import { AddAssistantEntity1699325775451 } from './1699325775451-AddAssistantEntity'
|
||||||
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
|
import { AddUsedToolsToChatMessage1699481607341 } from './1699481607341-AddUsedToolsToChatMessage'
|
||||||
import { AddStarterPrompt1700565042576 } from './1700565042576-AddStarterPromptsToChatFlow'
|
|
||||||
|
|
||||||
export const sqliteMigrations = [
|
export const sqliteMigrations = [
|
||||||
Init1693835579790,
|
Init1693835579790,
|
||||||
@@ -20,6 +19,5 @@ export const sqliteMigrations = [
|
|||||||
AddAnalytic1694432361423,
|
AddAnalytic1694432361423,
|
||||||
AddChatHistory1694657778173,
|
AddChatHistory1694657778173,
|
||||||
AddAssistantEntity1699325775451,
|
AddAssistantEntity1699325775451,
|
||||||
AddUsedToolsToChatMessage1699481607341,
|
AddUsedToolsToChatMessage1699481607341
|
||||||
AddStarterPrompt1700565042576
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const settings = {
|
|||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
id: 'conversationStarters',
|
id: 'conversationStarters',
|
||||||
title: 'Set Starter Prompts',
|
title: 'Starter Prompts',
|
||||||
type: 'item',
|
type: 'item',
|
||||||
url: '',
|
url: '',
|
||||||
icon: icons.IconPictureInPictureOff
|
icon: icons.IconPictureInPictureOff
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ const ConversationStarterDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
const onSave = async () => {
|
const onSave = async () => {
|
||||||
try {
|
try {
|
||||||
const saveResp = await chatflowsApi.updateChatflow(dialogProps.chatflow.id, {
|
const saveResp = await chatflowsApi.updateChatflow(dialogProps.chatflow.id, {
|
||||||
starterPrompt: JSON.stringify(inputFields)
|
chatbotConfig: {
|
||||||
|
starterPrompts: JSON.stringify(inputFields)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (saveResp.data) {
|
if (saveResp.data) {
|
||||||
enqueueSnackbar({
|
enqueueSnackbar({
|
||||||
@@ -94,9 +96,9 @@ const ConversationStarterDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dialogProps.chatflow && dialogProps.chatflow.starterPrompt) {
|
if (dialogProps.chatflow && dialogProps.chatbotConfig.starterPrompts) {
|
||||||
try {
|
try {
|
||||||
setInputFields(JSON.parse(dialogProps.chatflow.starterPrompt))
|
setInputFields(JSON.parse(dialogProps.chatbotConfig.starterPrompts))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setInputFields([
|
setInputFields([
|
||||||
{
|
{
|
||||||
@@ -126,7 +128,7 @@ const ConversationStarterDialog = ({ show, dialogProps, onCancel }) => {
|
|||||||
aria-describedby='alert-dialog-description'
|
aria-describedby='alert-dialog-description'
|
||||||
>
|
>
|
||||||
<DialogTitle sx={{ fontSize: '1rem' }} id='alert-dialog-title'>
|
<DialogTitle sx={{ fontSize: '1rem' }} id='alert-dialog-title'>
|
||||||
Set Conversation Starter Prompts
|
{dialogProps.title || 'Conversation Starter Prompts'}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<Box sx={{ p: 2 }}>
|
<Box sx={{ p: 2 }}>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ const CanvasHeader = ({ chatflow, handleSaveFlow, handleDeleteFlow, handleLoadFl
|
|||||||
handleDeleteFlow()
|
handleDeleteFlow()
|
||||||
} else if (setting === 'conversationStarters') {
|
} else if (setting === 'conversationStarters') {
|
||||||
setConversationStartersDialogProps({
|
setConversationStartersDialogProps({
|
||||||
title: 'Set Conversation Starters - ' + chatflow.name,
|
title: 'Starter Prompts - ' + chatflow.name,
|
||||||
chatflow: chatflow
|
chatflow: chatflow
|
||||||
})
|
})
|
||||||
setConversationStartersDialogOpen(true)
|
setConversationStartersDialogOpen(true)
|
||||||
|
|||||||
@@ -210,8 +210,11 @@ export const ChatMessage = ({ open, chatflowid, isDialog }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (getChatflowConfig.data) {
|
if (getChatflowConfig.data) {
|
||||||
if (getChatflowConfig.data?.starterPrompt && JSON.parse(getChatflowConfig.data?.starterPrompt)) {
|
if (
|
||||||
setStarterPrompts(JSON.parse(getChatflowConfig.data?.starterPrompt))
|
getChatflowConfig.data?.chatbotConfig?.starterPrompts &&
|
||||||
|
JSON.parse(getChatflowConfig.data?.chatbotConfig?.starterPrompts)
|
||||||
|
) {
|
||||||
|
setStarterPrompts(JSON.parse(getChatflowConfig.data?.chatbotConfig?.starterPrompts))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|||||||
Reference in New Issue
Block a user