From f75310ccbee7947f23d432e724f3296a381ebd72 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 22 Oct 2025 22:13:15 -0400 Subject: [PATCH] docs(examples): tune the moon phase tool a little --- examples/moon/main.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/moon/main.go b/examples/moon/main.go index 1bc574ab9643a94b760ad5410406e4658f223a4a..5092ffea6ef7c40dc91874440e1c9b0a45cb5b1b 100644 --- a/examples/moon/main.go +++ b/examples/moon/main.go @@ -43,6 +43,7 @@ func main() { ctx := context.Background() + // Choose the model. model, err := provider.LanguageModel(ctx, "claude-haiku-4-5-20251001") if err != nil { log.Fatalf("could not get language model: %v", err) @@ -63,7 +64,10 @@ func main() { ) // Here's our prompt. - const prompt = "What is the moon phase today? And what will it be on December 31, 2025?" + prompt := fmt.Sprintf( + "What is the moon phase today? And what will it be on December 31 this year? Today's date is %s.", + time.Now().Format("January 2, 2006"), + ) fmt.Println("\n" + formatText(prompt)) // Let's go! Ask the agent to generate a response. @@ -86,12 +90,14 @@ func main() { fmt.Print(lipgloss.NewStyle().MarginLeft(3).Render(t.String()), "\n\n") } +// Input for the moon phase tool. The model will provide the date when +// necessary. type moonPhaseInput struct { Date string `json:"date,omitempty" description:"Optional date in YYYY-MM-DD; if omitted, use today"` } -// moonPhaseTool queries wttr.in for the moon phase on a given date. If no -// date is provided, it uses today's date. +// This is the moon phase tool definition. It queries wttr.in for the moon +// phase on a given date. If no date is provided, it uses today's date. // // The date format should be in YYYY-MM-DD format. func moonPhaseTool(ctx context.Context, input moonPhaseInput, _ fantasy.ToolCall) (fantasy.ToolResponse, error) {