Skip to content
Open
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
13 changes: 11 additions & 2 deletions pkg/epp/scheduling/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,16 @@ func (r *ChatCompletionsRequest) String() string {

messagesLen := 0
for _, msg := range r.Messages {
messagesLen += len(msg.Content)
switch content := msg.Content.(type) {
case string:
messagesLen += len(content)
case []interface{}:
// For content arrays, we'll count each element as contributing some length
messagesLen += len(content) * 10 // arbitrary multiplier for array elements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the arbitrary multiplier needed?

default:
// For other types, just add a small constant
messagesLen += 1
}
}

return fmt.Sprintf("{MessagesLength: %d}", messagesLen)
Expand All @@ -106,7 +115,7 @@ func (r *ChatCompletionsRequest) String() string {
// Message represents a single message in a chat-completions request.
type Message struct {
Role string
Content string // TODO: support multi-modal content
Content any // Support both string and array content (OpenAI content blocks)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is the problem, i think we can do the same thing just like llm-d-sim https://github.com/llm-d/llm-d-inference-sim/blob/main/pkg/openai-server-api/response.go#L84-L91

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirrozenbaum @danehans i think we need to support this first.

Copy link
Contributor

@danehans danehans Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhengkezhou1 +1 to follow the llm-d-sim types.

}

type Pod interface {
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/epp/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ import (
testutils "sigs.k8s.io/gateway-api-inference-extension/test/utils"
)

type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *ImageBlock `json:"image_url,omitempty"`
}

type ImageBlock struct {
Url string `json:"url"`
}

var _ = ginkgo.Describe("InferencePool", func() {
var infObjective *v1alpha2.InferenceObjective
ginkgo.BeforeEach(func() {
Expand Down Expand Up @@ -201,6 +211,24 @@ func verifyTrafficRouting() {
{"role": "user", "content": "Now summarize your thoughts."},
},
},
{
api: "/chat/completions",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have multiple test cases using the same api, can you add a description field to the []struct so it's easy to understand the difference between test cases?

promptOrMessages: []map[string]any{
{
"role": "user",
"content": []ContentBlock{
{
Type: "text",
Text: `What's in this image?`,
},
{
Type: "image_url",
ImageURL: &ImageBlock{Url: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"},
},
},
},
},
},
} {
ginkgo.By(fmt.Sprintf("Verifying connectivity through the inference extension with %s api and prompt/messages: %v", t.api, t.promptOrMessages))

Expand Down