Skip to content

An AI-powered search engine with a generative UI

Update search schema parameters to be optional for better function call compatibility

Yoshiki Miurabdb3d6d1ab86
diff --git a/lib/schema/search.tsx b/lib/schema/search.tsx
index 6e775baf..63580f65 100644
--- a/lib/schema/search.tsx
+++ b/lib/schema/search.tsx
@@ -5,19 +5,23 @@ export const searchSchema = z.object({
query: z.string().describe('The query to search for'),
max_results: z
.number()
+ .optional()
.describe('The maximum number of results to return. default is 20'),
search_depth: z
.string()
+ .optional()
.describe(
'The depth of the search. Allowed values are "basic" or "advanced"'
),
include_domains: z
.array(z.string())
+ .optional()
.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())
+ .optional()
.describe(
"A list of domains to specifically exclude from the search results. Default is None, which doesn't exclude any domains."
)
diff --git a/lib/tools/search.ts b/lib/tools/search.ts
index 1a1170ab..0291e9e6 100644
--- a/lib/tools/search.ts
+++ b/lib/tools/search.ts
@@ -15,10 +15,10 @@ export const searchTool = tool({
parameters: searchSchema,
execute: async ({
query,
- max_results,
- search_depth,
- include_domains,
- exclude_domains
+ max_results = 20,
+ search_depth = 'basic',
+ include_domains = [],
+ exclude_domains = []
}) => {
// Tavily API requires a minimum of 5 characters in the query
const filledQuery =