Skip to content

Commit 8eed7b8

Browse files
committed
apply RAG mock
1 parent 949ab85 commit 8eed7b8

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

src/server/util/azure/ResponsesAPI.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ export class ResponsesClient {
138138
break
139139
}
140140

141+
case 'response.file_search_call.in_progress': {
142+
this.write(
143+
{
144+
type: 'fileSearchStarted',
145+
},
146+
res,
147+
)
148+
break
149+
}
150+
141151
case 'response.output_item.done': {
142152
if (event.item.type === 'file_search_call') {
143153
if (!ragIndexId) throw new Error('how is this possible. you managed to invoke file search without ragIndexId')
@@ -164,16 +174,6 @@ export class ResponsesClient {
164174
break
165175
}
166176

167-
case 'response.file_search_call.in_progress': {
168-
this.write(
169-
{
170-
type: 'fileSearchStarted',
171-
},
172-
res,
173-
)
174-
break
175-
}
176-
177177
case 'response.completed': {
178178
await this.write(
179179
{

src/server/util/azure/mocks/mockFunctions.ts

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ export const getBasicStreamMock = (): MockResponseStreamEvent[] => {
4242
- To mock a failed response, write: **fail**
4343
- To mock a mid-sentence failed response, write: **midway fail**
4444
- To mock a incomplete response, write: **incomplete fail**
45-
- To mock a file search, write: **rag**
46-
- To mock a file search fail response, write: **rag fail**
45+
- To mock a file search, write: **rag** -- _make sure to have a RAG index selected_
46+
- To mock a file search fail response, write: **rag fail** -- _make sure to have a RAG index selected_
4747
- To mock a code block, write: **code block**
4848
- To mock a math block, write: **math block**
4949
OVER
@@ -154,14 +154,49 @@ export const getMidwayFailStreamMock = (): MockResponseStreamEvent[] => {
154154

155155
export const getFileSearchStreamMock = (): MockResponseStreamEvent[] => {
156156
// https://platform.openai.com/docs/api-reference/responses-streaming/response/file_search_call
157-
const responseText = `For testing RAG stream. Not yet implemented.`
157+
const responseText = `This is a mock response for file search stream. It simulates a response that is augmented with file search results.`
158158

159159
const chunkedResponseText = chunkText(responseText)
160160

161161
return [
162162
{
163163
type: 'response.created',
164164
},
165+
{
166+
type: 'response.file_search_call.in_progress',
167+
},
168+
{
169+
type: 'response.output_item.done',
170+
item: {
171+
id: 'fs_mock',
172+
status: 'completed',
173+
type: 'file_search_call',
174+
queries: ['mock', 'mock query'],
175+
results: [
176+
{
177+
attributes: {},
178+
file_id: 'mock_file_search_id',
179+
filename: 'mock_filename',
180+
score: 0.333,
181+
text: 'Mocking RAG file annotations 1',
182+
},
183+
{
184+
attributes: {},
185+
file_id: 'mock_file_search_id',
186+
filename: 'mock_filename',
187+
score: 0.444,
188+
text: 'Mocking RAG file annotations 2',
189+
},
190+
{
191+
attributes: {},
192+
file_id: 'mock_file_search_id',
193+
filename: 'mock_filename',
194+
score: 0.555,
195+
text: 'Mocking RAG file annotations 3',
196+
},
197+
],
198+
},
199+
},
165200
...chunkedResponseText.map((chunk) => ({
166201
type: 'response.output_text.delta' as ResponseStreamEvent['type'],
167202
item_id: 'msg_mock',

0 commit comments

Comments
 (0)