pull/701/head
Travis Fischer 2025-03-25 23:00:32 +08:00
rodzic ec2489da6a
commit 1ae522b610
2 zmienionych plików z 16 dodań i 5 usunięć

Wyświetl plik

@ -2,6 +2,7 @@ import {
aiFunction, aiFunction,
AIFunctionsProvider, AIFunctionsProvider,
getEnv, getEnv,
omit,
pick, pick,
sanitizeSearchParams sanitizeSearchParams
} from '@agentic/core' } from '@agentic/core'
@ -72,7 +73,7 @@ export class OpenMeteoClient extends AIFunctionsProvider {
const { start, end } = validateAndSetDates(params.startDate, params.endDate) const { start, end } = validateAndSetDates(params.startDate, params.endDate)
return this.ky const response = await this.ky
.get('forecast', { .get('forecast', {
searchParams: sanitizeSearchParams({ searchParams: sanitizeSearchParams({
...(await extractLocation()), ...(await extractLocation()),
@ -91,6 +92,20 @@ export class OpenMeteoClient extends AIFunctionsProvider {
}) })
}) })
.json<openmeteo.GetV1ForecastResponse>() .json<openmeteo.GetV1ForecastResponse>()
return omit(
response,
'latitude',
'longitude',
'elevation',
'generationtime_ms',
'utc_offset_seconds',
'timezone',
'timezone_abbreviation',
'elevation',
'hourly',
'hourly_units'
)
} }
protected async _geocode( protected async _geocode(

Wyświetl plik

@ -20,8 +20,6 @@ import { openmeteo } from './open-meteo'
export class OpenMeteoClient extends AIFunctionsProvider { export class OpenMeteoClient extends AIFunctionsProvider {
protected readonly ky: KyInstance protected readonly ky: KyInstance
protected readonly apiBaseUrl: string
constructor({ constructor({
apiBaseUrl, apiBaseUrl,
ky = defaultKy ky = defaultKy
@ -32,8 +30,6 @@ export class OpenMeteoClient extends AIFunctionsProvider {
} = {}) { } = {}) {
super() super()
this.apiBaseUrl = apiBaseUrl
this.ky = ky.extend({ this.ky = ky.extend({
prefixUrl: apiBaseUrl prefixUrl: apiBaseUrl
}) })