sse-schemas.ts 752 B

123456789101112131415161718192021222324252627282930
  1. import { z } from 'zod';
  2. // Schema definitions
  3. export const SseMessageSchema = z.object({
  4. content: z.array(
  5. z.object({
  6. index: z.number(),
  7. type: z.string(),
  8. text: z.object({
  9. value: z
  10. .string()
  11. .describe('The message that should be appended to the chat window'),
  12. }),
  13. }),
  14. ),
  15. });
  16. export const SsePreMessageSchema = z.object({
  17. text: z
  18. .string()
  19. .nullish()
  20. .describe('The pre-message that should be appended to the chat window'),
  21. finished: z
  22. .boolean()
  23. .describe('Indicates if the pre-message generation is finished'),
  24. });
  25. // Type definitions
  26. export type SseMessage = z.infer<typeof SseMessageSchema>;
  27. export type SsePreMessage = z.infer<typeof SsePreMessageSchema>;