Skip to content

Commit

Permalink
fix(search): add missing object property
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Oct 13, 2023
1 parent e6ad883 commit 05bfea2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/search/src/lib/approaches/approach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface ApproachResponse {
index: number;
message: ApproachResponseMessage;
}>;
object: 'chat.completion';
}

export interface ApproachResponseChunk {
Expand All @@ -13,6 +14,7 @@ export interface ApproachResponseChunk {
delta: Partial<ApproachResponseMessage>;
finish_reason: string | null;
}>;
object: 'chat.completion.chunk';
}

export type ApproachResponseMessage = Message & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class AskReadRetrieveRead extends ApproachBase implements AskApproach {
},
},
],
object: 'chat.completion',
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class AskRetrieveThenRead extends ApproachBase implements AskApproach {
},
},
],
object: 'chat.completion',
};
}

Expand Down
2 changes: 2 additions & 0 deletions packages/search/src/lib/approaches/chat-read-retrieve-read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class ChatReadRetrieveRead extends ApproachBase implements ChatApproach {
},
},
],
object: 'chat.completion',
};
}

Expand Down Expand Up @@ -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++;
Expand Down
23 changes: 14 additions & 9 deletions packages/search/src/plugins/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 05bfea2

Please sign in to comment.