Skip to content

Commit 5dad24b

Browse files
committed
new stuffs
1 parent 54dc80a commit 5dad24b

File tree

6 files changed

+20
-25
lines changed

6 files changed

+20
-25
lines changed

src/client/components/ChatV2/CitationsBox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Box, Paper, Typography } from '@mui/material'
22
import { FileCitation, RagFileAttributes, RagIndexAttributes } from '../../../shared/types'
33
import { Message } from '../../types'
44
import { useQuery } from '@tanstack/react-query'
5+
import Markdown from 'react-markdown'
56

67
const useFileCitationText = (citation: FileCitation, ragIndex: RagIndexAttributes) => {
78
const ragFileId = ragIndex?.ragFiles?.find((file) => file.filename === citation.filename)?.id
@@ -44,15 +45,15 @@ const Citation = ({ citation, ragIndex }: { citation: FileCitation; ragIndex: Ra
4445
Error loading citation text: {error.message}
4546
</Typography>
4647
) : (
47-
ragFile && <Typography variant="body2">{contentAtIdx}</Typography>
48+
ragFile && <Markdown>{contentAtIdx}</Markdown>
4849
)}
4950
</Box>
5051
)
5152
}
5253

5354
const MessageCitations = ({ citations, ragIndex }: { citations: FileCitation[]; ragIndex: RagIndexAttributes }) => {
5455
return (
55-
<Box sx={{ mt: 1, fontSize: '0.875rem', color: 'gray' }}>
56+
<Box sx={{ mt: 1 }}>
5657
{citations.map((citation, index) => (
5758
<Citation key={index} citation={citation} ragIndex={ragIndex} />
5859
))}

src/server/routes/assistants.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/server/routes/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import emailRouter from './email'
1717
import adminRouter from './admin'
1818
import facultyRouter from './faculty'
1919
import infoTextRouter from './infotext'
20-
import assistantRouter from './assistants'
2120

2221
const router = express()
2322

@@ -37,7 +36,6 @@ router.get('/ping', (_, res) => {
3736

3837
router.use('/ai', openaiRouter)
3938
router.use('/rag', ragRouter)
40-
router.use('/assistants', assistantRouter)
4139
router.use('/users', userRouter)
4240
router.use('/chatinstances', chatInstancesRouter)
4341
router.use('/courses', courseRouter)

src/server/routes/openai.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { Discussion, ChatInstance, RagIndex } from '../db/models'
1414

1515
import { ResponsesClient } from '../util/azure/ResponsesAPI'
1616
import { z } from 'zod'
17+
import { DEFAULT_RAG_SYSTEM_PROMPT } from '../util/config'
1718

1819
const openaiRouter = express.Router()
1920

@@ -164,7 +165,7 @@ openaiRouter.post('/stream/v2', upload.single('file'), async (r, res) => {
164165
}
165166

166167
vectorStoreId = ragIndex.metadata.azureVectorStoreId
167-
instructions = ragIndex.metadata.instructions
168+
instructions = ragIndex.metadata.instructions ?? DEFAULT_RAG_SYSTEM_PROMPT
168169

169170
console.log('using', ragIndex.toJSON())
170171
} else {

src/server/util/azure/ResponsesAPI.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ export class ResponsesClient {
106106

107107
case 'response.output_item.done':
108108
console.log('OUTPUT_ITEM DONE???', JSON.stringify(event, null, 2))
109-
break
109+
return {
110+
tokenCount,
111+
response: contents.join(''),
112+
}
110113

111114
case 'response.output_text.annotation.added':
115+
console.log(event)
112116
this.write(
113117
{
114118
type: 'annotation',
@@ -118,6 +122,10 @@ export class ResponsesClient {
118122
)
119123
break
120124

125+
case 'response.file_search_call.in_progress':
126+
console.log('file search in progress', event)
127+
break
128+
121129
case 'response.completed':
122130
await this.write(
123131
{

src/server/util/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ export const TEST_COURSES = {
6060
}
6161

6262
export const TEST_USER_IDS = ['hy-hlo-95971222', 'hy-hlo-1442996', 'otm-688bac31-4ddf-4b81-a562-6cea8260262a', 'hy-hlo-129129327', 'hy-hlo-45702058', 'hy-hlo-1397482']
63+
64+
export const DEFAULT_RAG_SYSTEM_PROMPT = `
65+
You are a helpful AI assistant designed to answer questions related to the course material, which you can access using the file search tool. Your responses should be concise, relevant, and based on the provided course files.
66+
If you cannot find the answer in the files, you should indicate that you do not have enough information to answer the question.
67+
You can still give your best guess based on your training, but make it clear that the answer is not based on the course material.
68+
`

0 commit comments

Comments
 (0)