-
Notifications
You must be signed in to change notification settings - Fork 195
Add LLMResponse object and RequestId to LLMRequest #799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ import ( | |
|
|
||
| // LLMRequest is a structured representation of the fields we parse out of the LLMRequest body. | ||
| type LLMRequest struct { | ||
| // RequestId is the Envoy generated Id for the request being processed | ||
| RequestId string | ||
| // Model is the name of the model that the user specified in the request body. | ||
| Model string | ||
| // ResolvedTargetModel is the final target model after traffic split. | ||
|
|
@@ -45,6 +47,20 @@ func (r *LLMRequest) String() string { | |
| r.Model, r.ResolvedTargetModel, r.Critical, len(r.Prompt), r.Headers) | ||
| } | ||
|
|
||
| // LLMResponse contains information from the response received to be passed to plugins | ||
| type LLMResponse struct { | ||
| // RequestId is the Envoy generated Id for the request being processed | ||
| RequestId string | ||
| // Headers is a map of the response headers. Nil during body processing | ||
| Headers map[string]string | ||
| // Body Is the body of the response or nil during header processing | ||
| Body string | ||
| // IsStreaming indicates whether or not the response is being streamed by the model | ||
| IsStreaming bool | ||
| // EndOfStream when true indicates that this invocation contains the last chunk of the response | ||
| EndOfStream bool | ||
| } | ||
|
|
||
| type Pod interface { | ||
| GetPod() *backend.Pod | ||
| GetMetrics() *backendmetrics.Metrics | ||
|
|
@@ -61,6 +77,7 @@ type SchedulingContext struct { | |
| context.Context | ||
| Logger logr.Logger | ||
| Req *LLMRequest | ||
| Resp *LLMResponse | ||
| PodsSnapshot []Pod | ||
| } | ||
|
|
||
|
|
@@ -84,12 +101,13 @@ type PodMetrics struct { | |
| *backendmetrics.Metrics | ||
| } | ||
|
|
||
| func NewSchedulingContext(ctx context.Context, req *LLMRequest, pods []Pod) *SchedulingContext { | ||
| func NewSchedulingContext(ctx context.Context, req *LLMRequest, resp *LLMResponse, pods []Pod) *SchedulingContext { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This param is nil in all the places it's called. It's also a exported field, perhaps the (Completely out of scope of this PR, but I would like to move away from |
||
| logger := log.FromContext(ctx).WithValues("request", req) | ||
| return &SchedulingContext{ | ||
| Context: ctx, | ||
| Logger: logger, | ||
| Req: req, | ||
| Resp: resp, | ||
| PodsSnapshot: pods, | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on the fence if there should be a dedicated field for this, we could put this in the
Headersmap, or check to see if it's already there, and then populate.