Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go/ai/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const (
type GenerateResponse struct {
Candidates []*Candidate `json:"candidates,omitempty"`
Custom any `json:"custom,omitempty"`
Request *GenerateRequest `json:"request,omitempty"`
Usage *GenerationUsage `json:"usage,omitempty"`
}

Expand Down
5 changes: 0 additions & 5 deletions go/genkit/dotprompt/genkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,5 @@ func (p *Prompt) Execute(ctx context.Context, input *ActionInput) (*ai.GenerateR
return nil, err
}

// TODO(ianlancetaylor): The TypeScript code stores genReq
// with each candidate in resp. The TypeScript code
// extends CandidateData with an optional request field.
// We don't have a natural way to do that in Go.

return resp, nil
}
1 change: 1 addition & 0 deletions go/genkit/dotprompt/genkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (testGenerator) Generate(ctx context.Context, req *ai.GenerateRequest, cb g
},
},
},
Request: req,
}
return r, nil
}
Expand Down
5 changes: 4 additions & 1 deletion go/plugins/googleai/googleai.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (g *generator) Generate(ctx context.Context, input *ai.GenerateRequest, cb
if err != nil {
return nil, err
}
return translateResponse(resp), nil
r := translateResponse(resp)
r.Request = input
return r, nil
}

// Streaming version.
Expand Down Expand Up @@ -134,6 +136,7 @@ func (g *generator) Generate(ctx context.Context, input *ai.GenerateRequest, cb
// to return an empty instead of nil result.
r = &ai.GenerateResponse{}
}
r.Request = input
return r, nil
}

Expand Down
4 changes: 3 additions & 1 deletion go/plugins/vertexai/vertexai.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ func (g *generator) Generate(ctx context.Context, input *ai.GenerateRequest, cb
}

// Translate from a genai.GenerateContentResponse to a ai.GenerateResponse.
r := &ai.GenerateResponse{}
r := &ai.GenerateResponse{
Request: input,
}
for _, cand := range resp.Candidates {
c := &ai.Candidate{}
c.Index = int(cand.Index)
Expand Down