An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: handle bare string for include_domains/exclude_domains in Zod schema (#910)
Seunghui Choif6b6e41bbdeb
diff --git a/components/search-section.tsx b/components/search-section.tsxindex ca9eb3bc..fa2578a3 100644--- a/components/search-section.tsx+++ b/components/search-section.tsx@@ -63,7 +63,7 @@ export function SearchSection({const query = tool.input?.query || output?.query || ''const includeDomains = tool.input?.include_domainsconst includeDomainsString =- includeDomains && includeDomains.length > 0+ Array.isArray(includeDomains) && includeDomains.length > 0? ` [${includeDomains.join(', ')}]`: ''diff --git a/lib/schema/search.tsx b/lib/schema/search.tsxindex be5e25a8..560308dc 100644--- a/lib/schema/search.tsx+++ b/lib/schema/search.tsx@@ -30,16 +30,22 @@ export const searchSchema = z.object({'The depth of the search. Allowed values are "basic" or "advanced"'),include_domains: z- .array(z.string())+ .union([z.string(), z.array(z.string())]).nullish()- .transform(val => val ?? [])+ .transform(val => {+ if (val == null) return []+ return typeof val === 'string' ? [val] : val+ }).describe('A list of domains to specifically include in the search results. Default is None, which includes all domains.'),exclude_domains: z- .array(z.string())+ .union([z.string(), z.array(z.string())]).nullish()- .transform(val => val ?? [])+ .transform(val => {+ if (val == null) return []+ return typeof val === 'string' ? [val] : val+ }).describe("A list of domains to specifically exclude from the search results. Default is None, which doesn't exclude any domains.")@@ -59,16 +65,22 @@ export const strictSearchSchema = z.object({.enum(['basic', 'advanced']).describe('The depth of the search'),include_domains: z- .array(z.string())+ .union([z.string(), z.array(z.string())]).nullish()- .transform(val => val ?? [])+ .transform(val => {+ if (val == null) return []+ return typeof val === 'string' ? [val] : val+ }).describe('A list of domains to specifically include in the search results. Default is None, which includes all domains.'),exclude_domains: z- .array(z.string())+ .union([z.string(), z.array(z.string())]).nullish()- .transform(val => val ?? [])+ .transform(val => {+ if (val == null) return []+ return typeof val === 'string' ? [val] : val+ }).describe("A list of domains to specifically exclude from the search results. Default is None, which doesn't exclude any domains.")