From 8da0247d1e095bfbd60e00ee0387d74a86fc17f8 Mon Sep 17 00:00:00 2001 From: irar2 Date: Wed, 22 Oct 2025 08:47:08 +0300 Subject: [PATCH 1/3] Add the latest version of openai-go in the tests Signed-off-by: irar2 --- go.mod | 2 +- go.sum | 4 +- pkg/llm-d-inference-sim/failures_test.go | 2 +- pkg/llm-d-inference-sim/lora_test.go | 4 +- pkg/llm-d-inference-sim/metrics_test.go | 4 +- pkg/llm-d-inference-sim/seed_test.go | 2 +- pkg/llm-d-inference-sim/simulator_test.go | 6 +- pkg/llm-d-inference-sim/tools_test.go | 406 ++++++++++++---------- 8 files changed, 228 insertions(+), 202 deletions(-) diff --git a/go.mod b/go.mod index 32fe86a8..51bc363f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/llm-d/llm-d-kv-cache-manager v0.3.0-rc1 github.com/onsi/ginkgo/v2 v2.23.4 github.com/onsi/gomega v1.37.0 - github.com/openai/openai-go v0.1.0-beta.10 + github.com/openai/openai-go/v3 v3.6.1 github.com/pebbe/zmq4 v1.4.0 github.com/prometheus/client_golang v1.22.0 github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 diff --git a/go.sum b/go.sum index dd46dc12..0e726bbb 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y= github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0= -github.com/openai/openai-go v0.1.0-beta.10 h1:CknhGXe8aXQMRuqg255PFnWzgRY9nEryMxoNIBBM9tU= -github.com/openai/openai-go v0.1.0-beta.10/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y= +github.com/openai/openai-go/v3 v3.6.1 h1:f8J6jhT9wkYnNvHTKR7bxHXSZrSvvcfpHGkmBra04tI= +github.com/openai/openai-go/v3 v3.6.1/go.mod h1:UOpNxkqC9OdNXNUfpNByKOtB4jAL0EssQXq5p8gO0Xs= github.com/pebbe/zmq4 v1.4.0 h1:gO5P92Ayl8GXpPZdYcD62Cwbq0slSBVVQRIXwGSJ6eQ= github.com/pebbe/zmq4 v1.4.0/go.mod h1:nqnPueOapVhE2wItZ0uOErngczsJdLOGkebMxaO8r48= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= diff --git a/pkg/llm-d-inference-sim/failures_test.go b/pkg/llm-d-inference-sim/failures_test.go index 36d324a0..56c4d6ac 100644 --- a/pkg/llm-d-inference-sim/failures_test.go +++ b/pkg/llm-d-inference-sim/failures_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/openai/openai-go" + "github.com/openai/openai-go/v3" "github.com/llm-d/llm-d-inference-sim/pkg/common" openaiserverapi "github.com/llm-d/llm-d-inference-sim/pkg/openai-server-api" diff --git a/pkg/llm-d-inference-sim/lora_test.go b/pkg/llm-d-inference-sim/lora_test.go index 624684f2..d2cfb6ce 100644 --- a/pkg/llm-d-inference-sim/lora_test.go +++ b/pkg/llm-d-inference-sim/lora_test.go @@ -23,8 +23,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" + "github.com/openai/openai-go/v3" + "github.com/openai/openai-go/v3/option" "github.com/llm-d/llm-d-inference-sim/pkg/common" vllmapi "github.com/llm-d/llm-d-inference-sim/pkg/vllm-api" diff --git a/pkg/llm-d-inference-sim/metrics_test.go b/pkg/llm-d-inference-sim/metrics_test.go index f0f8bb58..43b8c3af 100644 --- a/pkg/llm-d-inference-sim/metrics_test.go +++ b/pkg/llm-d-inference-sim/metrics_test.go @@ -32,8 +32,8 @@ import ( "github.com/llm-d/llm-d-inference-sim/pkg/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" + "github.com/openai/openai-go/v3" + "github.com/openai/openai-go/v3/option" ) const ( diff --git a/pkg/llm-d-inference-sim/seed_test.go b/pkg/llm-d-inference-sim/seed_test.go index 1f48deae..4e10f1f8 100644 --- a/pkg/llm-d-inference-sim/seed_test.go +++ b/pkg/llm-d-inference-sim/seed_test.go @@ -22,7 +22,7 @@ import ( "github.com/llm-d/llm-d-inference-sim/pkg/common" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/openai/openai-go" + "github.com/openai/openai-go/v3" ) var _ = Describe("Simulator with seed", func() { diff --git a/pkg/llm-d-inference-sim/simulator_test.go b/pkg/llm-d-inference-sim/simulator_test.go index e8e57e41..9f0a2182 100644 --- a/pkg/llm-d-inference-sim/simulator_test.go +++ b/pkg/llm-d-inference-sim/simulator_test.go @@ -33,9 +33,9 @@ import ( "github.com/llm-d/llm-d-kv-cache-manager/pkg/tokenization" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" - "github.com/openai/openai-go/packages/param" + "github.com/openai/openai-go/v3" + "github.com/openai/openai-go/v3/option" + "github.com/openai/openai-go/v3/packages/param" "github.com/valyala/fasthttp/fasthttputil" "k8s.io/klog/v2" ) diff --git a/pkg/llm-d-inference-sim/tools_test.go b/pkg/llm-d-inference-sim/tools_test.go index bffb7eea..f30b5883 100644 --- a/pkg/llm-d-inference-sim/tools_test.go +++ b/pkg/llm-d-inference-sim/tools_test.go @@ -27,51 +27,14 @@ import ( "github.com/llm-d/llm-d-inference-sim/pkg/dataset" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/openai/openai-go" - "github.com/openai/openai-go/option" - "github.com/openai/openai-go/packages/param" + "github.com/openai/openai-go/v3" + "github.com/openai/openai-go/v3/option" + "github.com/openai/openai-go/v3/packages/param" ) -var tools = []openai.ChatCompletionToolParam{ +var tools = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "get_weather", - Description: openai.String("Get weather at the given location"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "location": map[string]string{ - "type": "string", - }, - }, - "required": []string{"location"}, - }, - }, - }, - { - Function: openai.FunctionDefinitionParam{ - Name: "get_temperature", - Description: openai.String("Get temperature at the given location"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "city": map[string]string{ - "type": "string", - }, - "unit": map[string]interface{}{ - "type": "string", - "enum": []string{"C", "F"}, - }, - }, - "required": []string{"city", "unit"}, - }, - }, - }, -} - -var invalidTools = [][]openai.ChatCompletionToolParam{ - { - { + OfFunction: &openai.ChatCompletionFunctionToolParam{ Function: openai.FunctionDefinitionParam{ Name: "get_weather", Description: openai.String("Get weather at the given location"), @@ -86,7 +49,9 @@ var invalidTools = [][]openai.ChatCompletionToolParam{ }, }, }, - { + }, + { + OfFunction: &openai.ChatCompletionFunctionToolParam{ Function: openai.FunctionDefinitionParam{ Name: "get_temperature", Description: openai.String("Get temperature at the given location"), @@ -98,7 +63,7 @@ var invalidTools = [][]openai.ChatCompletionToolParam{ }, "unit": map[string]interface{}{ "type": "string", - "enum": []int{5, 6}, + "enum": []string{"C", "F"}, }, }, "required": []string{"city", "unit"}, @@ -106,20 +71,45 @@ var invalidTools = [][]openai.ChatCompletionToolParam{ }, }, }, +} +var invalidTools = [][]openai.ChatCompletionToolUnionParam{ { { - Function: openai.FunctionDefinitionParam{ - Name: "get_weather", - Description: openai.String("Get weather at the given location"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "location": map[string]string{ - "type": "stringstring", + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "get_weather", + Description: openai.String("Get weather at the given location"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "location": map[string]string{ + "type": "string", + }, }, + "required": []string{"location"}, + }, + }, + }, + }, + { + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "get_temperature", + Description: openai.String("Get temperature at the given location"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "city": map[string]string{ + "type": "string", + }, + "unit": map[string]interface{}{ + "type": "string", + "enum": []int{5, 6}, + }, + }, + "required": []string{"city", "unit"}, }, - "required": []string{"location"}, }, }, }, @@ -127,182 +117,216 @@ var invalidTools = [][]openai.ChatCompletionToolParam{ { { - Function: openai.FunctionDefinitionParam{ - Name: "get_weather", - Description: openai.String("Get weather at the given location"), + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "get_weather", + Description: openai.String("Get weather at the given location"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "location": map[string]string{ + "type": "stringstring", + }, + }, + "required": []string{"location"}, + }, + }, + }, + }, + }, + + { + { + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "get_weather", + Description: openai.String("Get weather at the given location"), + }, }, }, }, } -var toolWithArray = []openai.ChatCompletionToolParam{ +var toolWithArray = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "multiply_numbers", - Description: openai.String("Multiply an array of numbers"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "numbers": map[string]interface{}{ - "type": "array", - "items": map[string]string{"type": "number"}, - "description": "List of numbers to multiply", + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "multiply_numbers", + Description: openai.String("Multiply an array of numbers"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "numbers": map[string]interface{}{ + "type": "array", + "items": map[string]string{"type": "number"}, + "description": "List of numbers to multiply", + }, }, + "required": []string{"numbers"}, }, - "required": []string{"numbers"}, }, }, }, } -var toolWith3DArray = []openai.ChatCompletionToolParam{ +var toolWith3DArray = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "process_tensor", - Description: openai.String("Process a 3D tensor of strings"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "tensor": map[string]interface{}{ - "type": "array", - "minItems": 2, - "items": map[string]any{ + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "process_tensor", + Description: openai.String("Process a 3D tensor of strings"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "tensor": map[string]interface{}{ "type": "array", - "minItems": 0, - "maxItems": 1, + "minItems": 2, "items": map[string]any{ "type": "array", - "items": map[string]string{"type": "string"}, - "maxItems": 3, + "minItems": 0, + "maxItems": 1, + "items": map[string]any{ + "type": "array", + "items": map[string]string{"type": "string"}, + "maxItems": 3, + }, }, + "description": "List of strings", }, - "description": "List of strings", }, + "required": []string{"tensor"}, }, - "required": []string{"tensor"}, }, }, }, } -var toolWithWrongMinMax = []openai.ChatCompletionToolParam{ +var toolWithWrongMinMax = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "multiply_numbers", - Description: openai.String("Multiply an array of numbers"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "numbers": map[string]interface{}{ - "type": "array", - "items": map[string]string{"type": "number"}, - "description": "List of numbers to multiply", - "minItems": 3, - "maxItems": 1, + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "multiply_numbers", + Description: openai.String("Multiply an array of numbers"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "numbers": map[string]interface{}{ + "type": "array", + "items": map[string]string{"type": "number"}, + "description": "List of numbers to multiply", + "minItems": 3, + "maxItems": 1, + }, }, + "required": []string{"numbers"}, }, - "required": []string{"numbers"}, }, }, }, } -var toolWithObjects = []openai.ChatCompletionToolParam{ +var toolWithObjects = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "process_order", - Description: openai.String("Process a customer order"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "order_info": map[string]interface{}{ - "type": "object", - "properties": map[string]interface{}{ - "item": map[string]interface{}{ - "type": "string", - }, - "quantity": map[string]string{ - "type": "integer", - }, - "address": map[string]interface{}{ - "type": "object", - "properties": map[string]interface{}{ - "street": map[string]interface{}{ - "type": "string", - }, - "number": map[string]interface{}{ - "type": "integer", - }, - "home": map[string]interface{}{ - "type": "boolean", + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "process_order", + Description: openai.String("Process a customer order"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "order_info": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "item": map[string]interface{}{ + "type": "string", + }, + "quantity": map[string]string{ + "type": "integer", + }, + "address": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "street": map[string]interface{}{ + "type": "string", + }, + "number": map[string]interface{}{ + "type": "integer", + }, + "home": map[string]interface{}{ + "type": "boolean", + }, }, + "required": []string{"street", "number", "home"}, }, - "required": []string{"street", "number", "home"}, }, + "required": []string{"item", "quantity", "address"}, + }, + "name": map[string]interface{}{ + "type": "string", }, - "required": []string{"item", "quantity", "address"}, - }, - "name": map[string]interface{}{ - "type": "string", }, + "required": []string{"order_info", "name"}, }, - "required": []string{"order_info", "name"}, }, }, }, } -var toolWithObjectAndArray = []openai.ChatCompletionToolParam{ +var toolWithObjectAndArray = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "submit_survey", - Description: openai.String("Submit a survey with user information."), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "user_info": map[string]interface{}{ - "type": "object", - "properties": map[string]interface{}{ - "name": map[string]interface{}{ - "type": "string", - "description": "The user's name", - }, - "age": map[string]string{ - "type": "integer", - "description": "The user's age", - }, - "hobbies": map[string]interface{}{ - "type": "array", - "items": map[string]string{"type": "string"}, - "description": "A list of the user's hobbies", + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "submit_survey", + Description: openai.String("Submit a survey with user information."), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "user_info": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "name": map[string]interface{}{ + "type": "string", + "description": "The user's name", + }, + "age": map[string]string{ + "type": "integer", + "description": "The user's age", + }, + "hobbies": map[string]interface{}{ + "type": "array", + "items": map[string]string{"type": "string"}, + "description": "A list of the user's hobbies", + }, }, + "required": []string{"name", "age", "hobbies"}, }, - "required": []string{"name", "age", "hobbies"}, }, + "required": []string{"user_info"}, }, - "required": []string{"user_info"}, }, }, }, } -var toolWithoutRequiredParams = []openai.ChatCompletionToolParam{ +var toolWithoutRequiredParams = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "get_temperature", - Description: openai.String("Get temperature at the given location"), - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "city": map[string]string{ - "type": "string", - }, - "country": map[string]string{ - "type": "string", - }, - "unit": map[string]interface{}{ - "type": "string", - "enum": []string{"C", "F"}, + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "get_temperature", + Description: openai.String("Get temperature at the given location"), + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "city": map[string]string{ + "type": "string", + }, + "country": map[string]string{ + "type": "string", + }, + "unit": map[string]interface{}{ + "type": "string", + "enum": []string{"C", "F"}, + }, }, }, }, @@ -310,29 +334,31 @@ var toolWithoutRequiredParams = []openai.ChatCompletionToolParam{ }, } -var toolWithObjectWithoutRequiredParams = []openai.ChatCompletionToolParam{ +var toolWithObjectWithoutRequiredParams = []openai.ChatCompletionToolUnionParam{ { - Function: openai.FunctionDefinitionParam{ - Name: "process_order", - Parameters: openai.FunctionParameters{ - "type": "object", - "properties": map[string]interface{}{ - "order_info": map[string]interface{}{ - "type": "object", - "properties": map[string]interface{}{ - "item": map[string]interface{}{ - "type": "string", - }, - "quantity": map[string]string{ - "type": "integer", - }, - "address": map[string]interface{}{ - "type": "string", + OfFunction: &openai.ChatCompletionFunctionToolParam{ + Function: openai.FunctionDefinitionParam{ + Name: "process_order", + Parameters: openai.FunctionParameters{ + "type": "object", + "properties": map[string]interface{}{ + "order_info": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "item": map[string]interface{}{ + "type": "string", + }, + "quantity": map[string]string{ + "type": "integer", + }, + "address": map[string]interface{}{ + "type": "string", + }, }, }, }, + "required": []string{"order_info"}, }, - "required": []string{"order_info"}, }, }, }, From cdaa18760f286f467c94e062b690b5333014661b Mon Sep 17 00:00:00 2001 From: irar2 Date: Wed, 22 Oct 2025 08:52:52 +0300 Subject: [PATCH 2/3] Typo in function name Signed-off-by: irar2 --- pkg/llm-d-inference-sim/failures_test.go | 12 ++++++------ pkg/llm-d-inference-sim/lora_test.go | 2 +- pkg/llm-d-inference-sim/metrics_test.go | 4 ++-- pkg/llm-d-inference-sim/simulator_test.go | 12 ++++++------ pkg/llm-d-inference-sim/tools_test.go | 18 +++++++++--------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg/llm-d-inference-sim/failures_test.go b/pkg/llm-d-inference-sim/failures_test.go index 56c4d6ac..da8f8576 100644 --- a/pkg/llm-d-inference-sim/failures_test.go +++ b/pkg/llm-d-inference-sim/failures_test.go @@ -134,7 +134,7 @@ var _ = Describe("Failures", func() { }) It("should always return an error response for chat completions", func() { - openaiClient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiClient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) _, err := openaiClient.Chat.Completions.New(ctx, params) Expect(err).To(HaveOccurred()) @@ -147,7 +147,7 @@ var _ = Describe("Failures", func() { }) It("should always return an error response for text completions", func() { - openaiClient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiClient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) _, err := openaiClient.Chat.Completions.New(ctx, params) Expect(err).To(HaveOccurred()) @@ -173,7 +173,7 @@ var _ = Describe("Failures", func() { }) It("should return only rate limit errors", func() { - openaiClient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiClient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) _, err := openaiClient.Chat.Completions.New(ctx, params) Expect(err).To(HaveOccurred()) @@ -199,7 +199,7 @@ var _ = Describe("Failures", func() { }) It("should return only specified error types", func() { - openaiClient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiClient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) // Make multiple requests to verify we get the expected error types for i := 0; i < 10; i++ { @@ -230,7 +230,7 @@ var _ = Describe("Failures", func() { }) It("should never return errors and behave like random mode", func() { - openaiClient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiClient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) resp, err := openaiClient.Chat.Completions.New(ctx, params) Expect(err).ToNot(HaveOccurred()) Expect(resp.Choices).To(HaveLen(1)) @@ -250,7 +250,7 @@ var _ = Describe("Failures", func() { }, nil) Expect(err).ToNot(HaveOccurred()) - openaiClient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiClient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) _, err = openaiClient.Chat.Completions.New(ctx, params) Expect(err).To(HaveOccurred()) diff --git a/pkg/llm-d-inference-sim/lora_test.go b/pkg/llm-d-inference-sim/lora_test.go index d2cfb6ce..837a36fc 100644 --- a/pkg/llm-d-inference-sim/lora_test.go +++ b/pkg/llm-d-inference-sim/lora_test.go @@ -41,7 +41,7 @@ var _ = Describe("LoRAs", func() { Expect(err).NotTo(HaveOccurred()) // Request to lora3 - openaiclient, params := getOpenAIClentAndChatParams(client, "lora3", userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, "lora3", userMessage, false) resp, err := openaiclient.Chat.Completions.New(ctx, params) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/llm-d-inference-sim/metrics_test.go b/pkg/llm-d-inference-sim/metrics_test.go index 43b8c3af..215d6339 100644 --- a/pkg/llm-d-inference-sim/metrics_test.go +++ b/pkg/llm-d-inference-sim/metrics_test.go @@ -73,7 +73,7 @@ var _ = Describe("Simulator metrics", Ordered, func() { client, err := startServerWithArgs(ctx, common.ModeRandom, args, nil) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, modelName, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, modelName, userMessage, false) var wg sync.WaitGroup wg.Add(1) @@ -316,7 +316,7 @@ var _ = Describe("Simulator metrics", Ordered, func() { client, err := startServerWithArgs(ctx, common.ModeRandom, args, nil) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, modelName, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, modelName, userMessage, false) params.MaxTokens = openai.Int(5) var reqWg, metricsWg sync.WaitGroup diff --git a/pkg/llm-d-inference-sim/simulator_test.go b/pkg/llm-d-inference-sim/simulator_test.go index 9f0a2182..b9b276e6 100644 --- a/pkg/llm-d-inference-sim/simulator_test.go +++ b/pkg/llm-d-inference-sim/simulator_test.go @@ -163,7 +163,7 @@ var _ = Describe("Simulator", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, true) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, true) stream := openaiclient.Chat.Completions.NewStreaming(ctx, params) defer func() { err := stream.Close() @@ -264,7 +264,7 @@ var _ = Describe("Simulator", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) numTokens := 0 // if maxTokens and maxCompletionTokens are passsed // maxCompletionTokens is used @@ -539,7 +539,7 @@ var _ = Describe("Simulator", func() { Expect(string(body)).To(ContainSubstring("BadRequestError")) // Also test with OpenAI client to ensure it gets an error - openaiclient, params := getOpenAIClentAndChatParams(client, model, "This is a test message", false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, "This is a test message", false) params.MaxTokens = openai.Int(8) _, err = openaiclient.Chat.Completions.New(ctx, params) @@ -556,7 +556,7 @@ var _ = Describe("Simulator", func() { client, err := startServerWithArgs(ctx, common.ModeEcho, args, nil) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, "Hello", false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, "Hello", false) params.MaxTokens = openai.Int(5) // Send a request within the context window @@ -604,7 +604,7 @@ func sendSimpleChatRequest(envs map[string]string, streaming bool) *http.Respons client, err := startServerWithArgs(ctx, common.ModeRandom, nil, envs) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, streaming) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, streaming) var httpResp *http.Response resp, err := openaiclient.Chat.Completions.New(ctx, params, option.WithResponseInto(&httpResp)) Expect(err).NotTo(HaveOccurred()) @@ -616,7 +616,7 @@ func sendSimpleChatRequest(envs map[string]string, streaming bool) *http.Respons return httpResp } -func getOpenAIClentAndChatParams(client option.HTTPClient, model string, message string, +func getOpenAIClientAndChatParams(client option.HTTPClient, model string, message string, streaming bool) (openai.Client, openai.ChatCompletionNewParams) { openaiclient := openai.NewClient( option.WithBaseURL(baseURL), diff --git a/pkg/llm-d-inference-sim/tools_test.go b/pkg/llm-d-inference-sim/tools_test.go index f30b5883..ce349dd9 100644 --- a/pkg/llm-d-inference-sim/tools_test.go +++ b/pkg/llm-d-inference-sim/tools_test.go @@ -372,7 +372,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, true) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, true) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = tools @@ -454,7 +454,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = tools @@ -539,7 +539,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServerWithArgs(ctx, common.ModeEcho, serverArgs, nil) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWithArray @@ -588,7 +588,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWith3DArray @@ -641,7 +641,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWithWrongMinMax @@ -660,7 +660,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWithObjects @@ -715,7 +715,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServer(ctx, mode) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWithObjectAndArray @@ -766,7 +766,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServerWithArgs(ctx, common.ModeEcho, serverArgs, nil) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWithoutRequiredParams @@ -804,7 +804,7 @@ var _ = Describe("Simulator for request with tools", func() { client, err := startServerWithArgs(ctx, common.ModeEcho, serverArgs, nil) Expect(err).NotTo(HaveOccurred()) - openaiclient, params := getOpenAIClentAndChatParams(client, model, userMessage, false) + openaiclient, params := getOpenAIClientAndChatParams(client, model, userMessage, false) params.ToolChoice = openai.ChatCompletionToolChoiceOptionUnionParam{OfAuto: param.NewOpt("required")} params.Tools = toolWithObjectWithoutRequiredParams From 460bddc564f00ff8b7946c94066d19c5a16b58a0 Mon Sep 17 00:00:00 2001 From: irar2 Date: Wed, 22 Oct 2025 09:07:52 +0300 Subject: [PATCH 3/3] Fixed lint errors Signed-off-by: irar2 --- pkg/llm-d-inference-sim/tools_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/llm-d-inference-sim/tools_test.go b/pkg/llm-d-inference-sim/tools_test.go index ce349dd9..e97db392 100644 --- a/pkg/llm-d-inference-sim/tools_test.go +++ b/pkg/llm-d-inference-sim/tools_test.go @@ -475,7 +475,7 @@ var _ = Describe("Simulator for request with tools", func() { for _, tc := range toolCalls { Expect(tc.Function.Name).To(Or(Equal("get_weather"), Equal("get_temperature"))) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string]string) err := json.Unmarshal([]byte(tc.Function.Arguments), &args) Expect(err).NotTo(HaveOccurred()) @@ -560,7 +560,7 @@ var _ = Describe("Simulator for request with tools", func() { tc := toolCalls[0] Expect(tc.Function.Name).To(Equal("multiply_numbers")) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string][]float64) err = json.Unmarshal([]byte(tc.Function.Arguments), &args) Expect(err).NotTo(HaveOccurred()) @@ -609,7 +609,7 @@ var _ = Describe("Simulator for request with tools", func() { tc := toolCalls[0] Expect(tc.Function.Name).To(Equal("process_tensor")) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string][][][]string) err = json.Unmarshal([]byte(tc.Function.Arguments), &args) @@ -681,7 +681,7 @@ var _ = Describe("Simulator for request with tools", func() { tc := toolCalls[0] Expect(tc.Function.Name).To(Equal("process_order")) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string]any) err = json.Unmarshal([]byte(tc.Function.Arguments), &args) @@ -736,7 +736,7 @@ var _ = Describe("Simulator for request with tools", func() { tc := toolCalls[0] Expect(tc.Function.Name).To(Equal("submit_survey")) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string]any) err = json.Unmarshal([]byte(tc.Function.Arguments), &args) @@ -780,7 +780,7 @@ var _ = Describe("Simulator for request with tools", func() { tc := toolCalls[0] Expect(tc.Function.Name).To(Equal("get_temperature")) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string]string) err = json.Unmarshal([]byte(tc.Function.Arguments), &args) Expect(err).NotTo(HaveOccurred()) @@ -818,7 +818,7 @@ var _ = Describe("Simulator for request with tools", func() { tc := toolCalls[0] Expect(tc.Function.Name).To(Equal("process_order")) Expect(tc.ID).NotTo(BeEmpty()) - Expect(string(tc.Type)).To(Equal("function")) + Expect(tc.Type).To(Equal("function")) args := make(map[string]any) err = json.Unmarshal([]byte(tc.Function.Arguments), &args)