Skip to content

Commit

Permalink
fix(chat): add missing chat response properties
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <[email protected]>
  • Loading branch information
Tomas2D committed Jan 10, 2024
1 parent 7ba8a42 commit 3cd405e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/api-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,21 @@ export const ChatInputSchema = z.object({
parameters: ParametersSchema.nullish(),
});
export type ChatInput = z.input<typeof ChatInputSchema>;
export const ChatOutputSchema = z.object({
conversation_id: z.string(),
results: z.array(
z
.object({
generated_text: z.string(),
})
.partial(),
),
});
export const ChatOutputSchema = z
.object({
id: z.string(),
model_id: z.string(),
created_at: z.coerce.date(),
conversation_id: z.string(),
results: z.array(
z
.object({
generated_text: z.string(),
})
.partial(),
),
})
.passthrough();
export type ChatOutput = z.output<typeof ChatOutputSchema>;

export const ChatStreamInputSchema = ChatInputSchema;
Expand Down
3 changes: 3 additions & 0 deletions src/tests/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ export const handlers: RestHandler<MockedRequest<DefaultBodyType>>[] = [
return res(
ctx.status(200),
ctx.json({
id: randomUUID(),
model_id: body.model_id,
created_at: new Date('2022-12-19T22:53:22.000Z'),
conversation_id,
results: conversation
?.slice(-1)
Expand Down

0 comments on commit 3cd405e

Please sign in to comment.