From 31e6f41de9b9260c7b5668b9cadbf5a19f115774 Mon Sep 17 00:00:00 2001 From: Hayden Bleasel Date: Fri, 31 Oct 2025 21:49:43 -0700 Subject: [PATCH] Misc fixes (#1298) --- components/multimodal-input.tsx | 2 +- lib/ai/tools/get-weather.ts | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/components/multimodal-input.tsx b/components/multimodal-input.tsx index 65064d5..299f140 100644 --- a/components/multimodal-input.tsx +++ b/components/multimodal-input.tsx @@ -130,7 +130,7 @@ function PureMultimodalInput({ const [uploadQueue, setUploadQueue] = useState([]); const submitForm = useCallback(() => { - window.history.replaceState({}, "", `/chat/${chatId}`); + window.history.pushState({}, "", `/chat/${chatId}`); sendMessage({ role: "user", diff --git a/lib/ai/tools/get-weather.ts b/lib/ai/tools/get-weather.ts index c114833..d83a269 100644 --- a/lib/ai/tools/get-weather.ts +++ b/lib/ai/tools/get-weather.ts @@ -27,20 +27,16 @@ async function geocodeCity(city: string): Promise<{ latitude: number; longitude: export const getWeather = tool({ description: "Get the current weather at a location. You can provide either coordinates or a city name.", - inputSchema: z.union([ - z.object({ - latitude: z.number(), - longitude: z.number(), - }), - z.object({ - city: z.string().describe("City name (e.g., 'San Francisco', 'New York', 'London')"), - }), - ]), + inputSchema: z.object({ + latitude: z.number().optional(), + longitude: z.number().optional(), + city: z.string().describe("City name (e.g., 'San Francisco', 'New York', 'London')").optional(), + }), execute: async (input) => { let latitude: number; let longitude: number; - if ("city" in input) { + if (input.city) { const coords = await geocodeCity(input.city); if (!coords) { return { @@ -49,9 +45,13 @@ export const getWeather = tool({ } latitude = coords.latitude; longitude = coords.longitude; - } else { + } else if (input.latitude !== undefined && input.longitude !== undefined) { latitude = input.latitude; longitude = input.longitude; + } else { + return { + error: "Please provide either a city name or both latitude and longitude coordinates.", + }; } const response = await fetch(