Skip to content

[Go/Docs] Incorrect error handling example for genkit.Init in tool-calling documentation #3778

@kazu-gor

Description

@kazu-gor

Description:

The tool-calling documentation shows an incorrect example for genkit.Init that includes error handling, but the actual genkit.Init function does not return an error.

Current documentation example (incorrect):

g, err := genkit.Init(ctx,
    genkit.WithPlugins(&googlegenai.GoogleAI{}),
    genkit.WithDefaultModel("googleai/gemini-1.5-flash"), // Updated model name
)
if err != nil {
    log.Fatalf("Genkit initialization failed: %v", err)
}

Issue:

This code will result in a compilation error because genkit.Init only returns a single value (*Genkit), not a tuple.

Actual function signature:

The actual signature of genkit.Init is:

func Init(ctx context.Context, opts ...GenkitOption) *Genkit

Source: go/genkit/genkit.go#L164

Correct example:

g := genkit.Init(ctx,
    genkit.WithPlugins(&googlegenai.GoogleAI{}),
    genkit.WithDefaultModel("googleai/gemini-1.5-flash"), // Updated model name
)

Suggested fix:

Update the documentation to remove the error handling pattern from the genkit.Init example, as the function does not return an error.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions