mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
chat + maps + ai + tools
This commit is contained in:
25
packages/ai/src/tools/weather.ts
Normal file
25
packages/ai/src/tools/weather.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export async function getWeather(latitude: any, longitude: any) {
|
||||
const response = await fetch(
|
||||
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,wind_speed_10m&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m`,
|
||||
);
|
||||
const data = await response.json();
|
||||
return data.current.temperature_2m;
|
||||
}
|
||||
|
||||
export const WeatherTool = {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'get_weather',
|
||||
description: 'Get current temperature for provided coordinates in celsius.',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
latitude: { type: 'number' },
|
||||
longitude: { type: 'number' },
|
||||
},
|
||||
required: ['latitude', 'longitude'],
|
||||
additionalProperties: false,
|
||||
},
|
||||
strict: true,
|
||||
},
|
||||
};
|
Reference in New Issue
Block a user