-
Notifications
You must be signed in to change notification settings - Fork 530
Description
Describe the bug
When creating a prompt with a ModelName
Config, the provided model name is not considered and it will panic. This is due to a bug when looking up the model in:
genkit/go/plugins/dotprompt/genkit.go
Lines 207 to 225 in 2940fd5
model := p.Model | |
if model == nil { | |
modelName := p.ModelName | |
if pr.Model != "" { | |
modelName = pr.Model | |
} | |
if modelName == "" { | |
return nil, errors.New("dotprompt execution: model not specified") | |
} | |
provider, name, found := strings.Cut(modelName, "/") | |
if !found { | |
return nil, errors.New("dotprompt model not in provider/name format") | |
} | |
model := ai.LookupModel(provider, name) | |
if model == nil { | |
return nil, fmt.Errorf("no model named %q for provider %q", name, provider) | |
} | |
} |
The model
is shadowed inside the if statement and result to the lookedup model going out of context after the if statement.
To Reproduce
prompt, _ := dotprompt.Define("menu", `Suggest an item for the menu of a {{ type }} themed restaurant`, dotprompt.Config{ModelName: "googleai/gemini-1.5-flash", InputSchema: r.Reflect(Input{}), OutputSchema: os, OutputFormat: ai.OutputFormatJSON})
resp, _ := prompt.Generate(ctx,
&dotprompt.PromptRequest{
Variables: input,
Config: &ai.GenerationCommonConfig{Temperature: 1},
},
nil,
)
Expected behavior
When a model name is provided, either use the provided model name or return an error if the model lookup fails.
Runtime (please complete the following information):
Not relevant
** Go version
Not relevant
Additional context
The panic will happen in line:
genkit/go/plugins/dotprompt/genkit.go
Line 227 in 2940fd5
resp, err := model.Generate(ctx, genReq, cb) |
This is similar to #847 but not quite the same issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status