Misc fixes (#1298)
This commit is contained in:
parent
e4142a976e
commit
31e6f41de9
2 changed files with 12 additions and 12 deletions
|
|
@ -130,7 +130,7 @@ function PureMultimodalInput({
|
||||||
const [uploadQueue, setUploadQueue] = useState<string[]>([]);
|
const [uploadQueue, setUploadQueue] = useState<string[]>([]);
|
||||||
|
|
||||||
const submitForm = useCallback(() => {
|
const submitForm = useCallback(() => {
|
||||||
window.history.replaceState({}, "", `/chat/${chatId}`);
|
window.history.pushState({}, "", `/chat/${chatId}`);
|
||||||
|
|
||||||
sendMessage({
|
sendMessage({
|
||||||
role: "user",
|
role: "user",
|
||||||
|
|
|
||||||
|
|
@ -27,20 +27,16 @@ async function geocodeCity(city: string): Promise<{ latitude: number; longitude:
|
||||||
|
|
||||||
export const getWeather = tool({
|
export const getWeather = tool({
|
||||||
description: "Get the current weather at a location. You can provide either coordinates or a city name.",
|
description: "Get the current weather at a location. You can provide either coordinates or a city name.",
|
||||||
inputSchema: z.union([
|
inputSchema: z.object({
|
||||||
z.object({
|
latitude: z.number().optional(),
|
||||||
latitude: z.number(),
|
longitude: z.number().optional(),
|
||||||
longitude: z.number(),
|
city: z.string().describe("City name (e.g., 'San Francisco', 'New York', 'London')").optional(),
|
||||||
}),
|
}),
|
||||||
z.object({
|
|
||||||
city: z.string().describe("City name (e.g., 'San Francisco', 'New York', 'London')"),
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
execute: async (input) => {
|
execute: async (input) => {
|
||||||
let latitude: number;
|
let latitude: number;
|
||||||
let longitude: number;
|
let longitude: number;
|
||||||
|
|
||||||
if ("city" in input) {
|
if (input.city) {
|
||||||
const coords = await geocodeCity(input.city);
|
const coords = await geocodeCity(input.city);
|
||||||
if (!coords) {
|
if (!coords) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -49,9 +45,13 @@ export const getWeather = tool({
|
||||||
}
|
}
|
||||||
latitude = coords.latitude;
|
latitude = coords.latitude;
|
||||||
longitude = coords.longitude;
|
longitude = coords.longitude;
|
||||||
} else {
|
} else if (input.latitude !== undefined && input.longitude !== undefined) {
|
||||||
latitude = input.latitude;
|
latitude = input.latitude;
|
||||||
longitude = input.longitude;
|
longitude = input.longitude;
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
error: "Please provide either a city name or both latitude and longitude coordinates.",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue