> loading_
# To try the new AI skill generator, run the init command to start a new project:
$ agenthub init my-weather-agent
# Follow the standard prompts, and you'll encounter a new one:
# ? What is the name of your agent? my-weather-agent
# ? Select a template: Basic TypeScript Agent
# ? Describe a custom skill you want your agent to have (or press Enter to skip):
# > a skill that fetches the current weather for a given city using an external API
# The CLI will then generate the skill for you:
# ✨ Generating skill `getWeather.ts` from your description...
# ✅ Successfully created project `my-weather-agent`
# Your new project will contain `src/skills/getWeather.ts` with code like this:
/**
* Fetches the current weather for a specified city.
* @param city The name of the city to get the weather for.
* @returns A promise that resolves to a string with the weather conditions.
*/
import { Skill, Action } from '@overguild/agenthub-sdk';
@Skill({
name: 'getWeather',
description: 'Fetches the current weather for a given city using an external API.',
})
export class GetWeatherSkill {
@Action({
name: 'fetch',
description: 'Executes the weather fetch for the specified city.',
parameters: [
{ name: 'city', description: 'The city name', type: 'string', required: true }
]
})
async fetch(params: { city: string }): Promise<string> {
const { city } = params;
console.log(`Fetching weather for ${city}...`);
// Placeholder for actual API call logic
// const response = await fetch(`https://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q=${city}`);
// const data = await response.json();
// return `The weather in ${city} is currently ${data.current.condition.text}.`;
return `The weather in ${city} is sunny.`; // Simulated response
}
}