This example demostrates how to implement OpenAI Function Calling in Strong-typed language, easy to write and maintain. follow the instructions below, you will extend OpenAI gpt-4o with openweathermap.org API.
curl -fsSL "https://get.yomo.run" | sh
vim yomo.yml
Tip
If you do not have an OpenAI API Key, you can try vivgrid.com, it's free for developers with generous OpenAI Token every month.
yomo serve -c yomo.yml
grab your api-key from openweathermap.org free, and add it to your .env
file:
YOMO_SFN_NAME=llm_fn_get_weather
YOMO_SFN_ZIPPER=localhost:9000
YOMO_SFN_CREDENTIAL=SECRET
OPENWEATHERMAP_API_KEY=<ADD_HERE>
yomo run app.go
curl -X POST -H "Content-Type: application/json" -d '{"prompt":"Hows the weather like in Paris today?"}' http://127.0.0.1:9000/invoke |jq
{
"Content": "The weather in Paris today is clear with a clear sky. Here are the detailed conditions:\n\n- **Temperature:** 9.89°C (feels like 9.02°C)\n- **Humidity:** 91%\n- **Pressure:** 1020 hPa\n- **Wind:** 2.06 m/s coming from the southwest (210°)\n- **Visibility:** 10 km\n- **Cloudiness:** 0% (clear sky)\n- **Sunrise:** 05:27 AM\n- **Sunset:** 08:41 PM\n\nOverall, it's a cool and clear day in Paris.",
"ToolCalls": null,
"ToolMessages": null,
"FinishReason": "stop",
"TokenUsage": {
"prompt_tokens": 274,
"completion_tokens": 125
},
"AssistantMessage": null
}