diff --git a/packages/search/src/lib/approaches/approach.ts b/packages/search/src/lib/approaches/approach.ts index 4f4c7257..4fc97e74 100644 --- a/packages/search/src/lib/approaches/approach.ts +++ b/packages/search/src/lib/approaches/approach.ts @@ -5,6 +5,7 @@ export interface ApproachResponse { index: number; message: ApproachResponseMessage; }>; + object: 'chat.completion'; } export interface ApproachResponseChunk { @@ -13,6 +14,7 @@ export interface ApproachResponseChunk { delta: Partial; finish_reason: string | null; }>; + object: 'chat.completion.chunk'; } export type ApproachResponseMessage = Message & { diff --git a/packages/search/src/lib/approaches/ask-read-retrieve-read.ts b/packages/search/src/lib/approaches/ask-read-retrieve-read.ts index b5a50ae8..077207c4 100644 --- a/packages/search/src/lib/approaches/ask-read-retrieve-read.ts +++ b/packages/search/src/lib/approaches/ask-read-retrieve-read.ts @@ -116,6 +116,7 @@ export class AskReadRetrieveRead extends ApproachBase implements AskApproach { }, }, ], + object: 'chat.completion', }; } diff --git a/packages/search/src/lib/approaches/ask-retrieve-then-read.ts b/packages/search/src/lib/approaches/ask-retrieve-then-read.ts index 63f87679..63571c5b 100644 --- a/packages/search/src/lib/approaches/ask-retrieve-then-read.ts +++ b/packages/search/src/lib/approaches/ask-retrieve-then-read.ts @@ -85,6 +85,7 @@ export class AskRetrieveThenRead extends ApproachBase implements AskApproach { }, }, ], + object: 'chat.completion', }; } diff --git a/packages/search/src/lib/approaches/chat-read-retrieve-read.ts b/packages/search/src/lib/approaches/chat-read-retrieve-read.ts index c98328b0..428961cd 100644 --- a/packages/search/src/lib/approaches/chat-read-retrieve-read.ts +++ b/packages/search/src/lib/approaches/chat-read-retrieve-read.ts @@ -80,6 +80,7 @@ export class ChatReadRetrieveRead extends ApproachBase implements ChatApproach { }, }, ], + object: 'chat.completion', }; } @@ -110,6 +111,7 @@ export class ChatReadRetrieveRead extends ApproachBase implements ChatApproach { finish_reason: chunk.choices[0].finish_reason, }, ], + object: 'chat.completion.chunk' as const, }; yield responseChunk; id++; diff --git a/packages/search/src/plugins/schemas.ts b/packages/search/src/plugins/schemas.ts index 9b48418c..a0d0465b 100644 --- a/packages/search/src/plugins/schemas.ts +++ b/packages/search/src/plugins/schemas.ts @@ -79,18 +79,23 @@ export const messageSchema = { export const approachResponseSchema = { $id: 'approachResponse', - choices: { - type: 'array', - items: { - type: 'object', - properties: { - index: { type: 'number' }, - message: { $ref: 'message' }, + type: 'object', + properties: { + choices: { + type: 'array', + items: { + type: 'object', + properties: { + index: { type: 'number' }, + message: { $ref: 'message' }, + }, + required: ['index', 'message'], + additionalProperties: false, }, - required: ['index', 'message'], - additionalProperties: false, }, + object: { type: 'string' }, }, + required: ['choices', 'object'], } as const; export const schemas = [chatRequestSchema, askRequestSchema, messageSchema, approachResponseSchema];