Spaces:
Sleeping
Sleeping
| import type { ProposalCnGradioResponse } from '@/schema/gradio-proxy/proposal-cn'; | |
| import type { ProposalFvGradioResponse } from '@/schema/gradio-proxy/proposal-fv'; | |
| import type { ThemeByMomentStrategy } from '@/schema/gradio-proxy/theme-by-moment'; | |
| import { z } from 'zod'; | |
| // Proposal Intentのレスポンス型 | |
| export const intentAllSchema = z.object({ | |
| FV_intent: z.string(), | |
| CN_intent: z.string(), | |
| FV_suggest: z.string(), | |
| CN_suggest: z.string(), | |
| }); | |
| const cnCreationIntentGradioSchema = z.record(z.string()); | |
| const proposalIntentNeedDataGradioSchema = z.object({ | |
| intent_all: intentAllSchema, | |
| fv_creation_intent: z.string(), | |
| cn_creation_intent: cnCreationIntentGradioSchema, | |
| }); | |
| export const proposalIntentGradioResponseSchema = z.array( | |
| z.object({ | |
| 積極化戦略: z.record(proposalIntentNeedDataGradioSchema), | |
| 改善戦略: z.record(proposalIntentNeedDataGradioSchema), | |
| 差別化戦略: z.record(proposalIntentNeedDataGradioSchema), | |
| }), | |
| ); | |
| export type ProposalIntentGradioResponse = z.infer<typeof proposalIntentGradioResponseSchema>; | |
| // proposal_intent APIリクエストスキーマ | |
| export const proposalIntentRequestSchema = z.object({ | |
| proposal_fv: z.custom<ProposalFvGradioResponse>().optional(), | |
| proposal_cn: z.custom<ProposalCnGradioResponse>().optional(), | |
| commonDict: z.record(z.string(), z.unknown()).optional(), | |
| swot: z.record(z.string(), z.unknown()).optional(), | |
| q_summary: z.record(z.string(), z.unknown()).optional(), | |
| strategy_x_moment: z.custom<ThemeByMomentStrategy>().optional(), | |
| dummyMode: z.boolean().optional().default(false), | |
| userEmail: z.string().optional(), | |
| userIdentifier: z.string().min(1, 'ユーザー識別子が必要です。'), | |
| }); | |
| export type ProposalIntentRequest = z.infer<typeof proposalIntentRequestSchema>; | |
| // proposal_intent APIレスポンススキーマ | |
| export const proposalIntentResponseSchema = z.union([ | |
| proposalIntentGradioResponseSchema, // 正常レスポンス | |
| z.object({ | |
| status: z.literal('error'), | |
| message: z.string(), | |
| }), | |
| ]); | |
| export type ProposalIntentResponse = z.infer<typeof proposalIntentResponseSchema>; | |
| // エラーレスポンス型 | |
| export interface ProposalIntentErrorResponse { | |
| status: 'error'; | |
| message: string; | |
| } | |