Skip to content

Commit ac57aba

Browse files
committed
fix prompt rag association including
1 parent fec3ba7 commit ac57aba

File tree

5 files changed

+9
-3
lines changed

5 files changed

+9
-3
lines changed

src/client/components/ChatV2/PromptState.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const PromptStateProvider: React.FC<{
103103
}
104104
sync()
105105
}
106-
}, [isPromptEditable, activePrompt, setActivePrompt])
106+
}, [activePrompt?.id])
107107

108108
// Just the analytics dispatch.
109109
useEffect(() => {

src/server/db/models/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ RagFile.belongsTo(RagIndex, { as: 'ragIndex' })
6060

6161
RagIndex.hasMany(RagFile, { as: 'ragFiles' })
6262

63+
RagIndex.hasMany(Prompt, { as: 'prompts' })
64+
6365
RagFile.belongsTo(User, { as: 'user' })
6466

6567
/**

src/server/db/models/prompt.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { type CreationOptional, DataTypes, type InferAttributes, type InferCreat
22

33
import type { CustomMessage } from '../../types'
44
import { sequelize } from '../connection'
5-
import type RagIndex from './ragIndex'
5+
import RagIndex from './ragIndex'
66

77
export const PromptTypeValues = ['CHAT_INSTANCE', 'PERSONAL'] as const
88
export type PromptType = (typeof PromptTypeValues)[number]
@@ -58,6 +58,10 @@ Prompt.init(
5858
ragIndexId: {
5959
type: DataTypes.INTEGER,
6060
allowNull: true,
61+
references: {
62+
model: RagIndex,
63+
key: 'id',
64+
},
6165
},
6266
systemMessage: {
6367
type: DataTypes.TEXT,

src/server/db/models/ragIndex.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ RagIndex.init(
4848
},
4949
{
5050
underscored: true,
51+
tableName: 'rag_indices',
5152
sequelize,
5253
},
5354
)

src/server/routes/ai/v3.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ router.post('/stream', upload.single('file'), async (r, res) => {
119119
{
120120
model: RagIndex,
121121
as: 'ragIndex',
122-
where: courseId ? { courseId } : {},
123122
},
124123
],
125124
})

0 commit comments

Comments
 (0)