Skip to content

Commit

Permalink
feat(tools): add type coercion to the schema
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
  • Loading branch information
Tomas2D committed Oct 7, 2024
1 parent 9b60f8a commit f0995ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/tools/search/duckDuckGoSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class DuckDuckGoSearchTool extends Tool<
inputSchema() {
return z.object({
query: z.string({ description: `Search query` }).min(1).max(128),
page: z
page: z.coerce
.number()
.int()
.min(1)
Expand Down
6 changes: 3 additions & 3 deletions src/tools/weather/openMeteo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export class OpenMeteoTool extends Tool<
.strip(),
z
.object({
latitude: z.number(),
longitude: z.number(),
latitude: z.coerce.number(),
longitude: z.coerce.number(),
})
.strip(),
]),
Expand All @@ -91,7 +91,7 @@ export class OpenMeteoTool extends Tool<
.union([z.string().date(), z.string().datetime()])
.describe("End date for the weather forecast in the format YYYY-MM-DD (UTC)")
.optional(),
elevation: z.number().nullish(),
elevation: z.coerce.number().nullish(),
temperature_unit: z.enum(["celsius", "fahrenheit"]).default("celsius"),
})
.strip();
Expand Down

0 comments on commit f0995ea

Please sign in to comment.