Skip to content

Commit 8b1d15d

Browse files
committed
fix confusion of chatInstanceId and courseId in rag endpoint
1 parent 2082604 commit 8b1d15d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/client/components/Rag/Rag.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { TextField, Button, Box, Typography, Table, TableHead, TableBody, TableR
33
import { useNavigate, Link as RouterLink, useParams } from 'react-router-dom'
44
import { useCourseRagIndices, useRagIndices } from '../../hooks/useRagIndices'
55
import { useCreateRagIndexMutation } from './api'
6+
import useCourse from '../../hooks/useCourse'
67

78
const Rag: React.FC = () => {
8-
const { id: chatInstanceId } = useParams<{ id: string }>()
9+
const { id: courseId } = useParams<{ id: string }>()
10+
const { data: chatInstance } = useCourse(courseId)
911
const navigate = useNavigate()
10-
const { ragIndices } = useCourseRagIndices(chatInstanceId, true)
12+
const { ragIndices } = useCourseRagIndices(chatInstance?.id, true)
1113
const createIndexMutation = useCreateRagIndexMutation()
1214
const [indexName, setIndexName] = useState('')
1315

@@ -17,7 +19,7 @@ const Rag: React.FC = () => {
1719
<Typography variant="h4" mb="1rem">
1820
RAG Indices
1921
</Typography>
20-
{chatInstanceId && (
22+
{chatInstance?.id && (
2123
<Box sx={{ display: 'flex', gap: 2, marginBottom: 2 }}>
2224
<TextField
2325
label="Index Name"
@@ -32,7 +34,7 @@ const Rag: React.FC = () => {
3234
color="primary"
3335
onClick={async () => {
3436
const newIndex = await createIndexMutation.mutateAsync({
35-
chatInstanceId,
37+
chatInstanceId: chatInstance?.id,
3638
indexName,
3739
})
3840
setIndexName('')

src/server/routes/rag/rag.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ router.get('/indices', async (req, res) => {
9696
if (chatInstanceId) {
9797
chatInstance = await ChatInstance.findByPk(chatInstanceId, {
9898
include: [
99-
{ model: Responsibility, as: 'responsibilities' },
100-
{ model: RagIndex, as: 'ragIndices' },
99+
{ model: Responsibility, as: 'responsibilities', required: !user.isAdmin },
100+
{ model: RagIndex, as: 'ragIndices', required: false },
101101
],
102102
})
103103

0 commit comments

Comments
 (0)