From 85f578b865a6ea12ab24307f3bc68c97f85b6580 Mon Sep 17 00:00:00 2001 From: Liu Shuang Date: Mon, 17 Feb 2025 19:29:18 +0800 Subject: [PATCH] fix: remove validateO1Specific (#939) * fix: remove validateO1Specific * update golangci-lint-action version * fix actions * fix actions * fix actions * fix actions * remove some o1 test --- .github/workflows/pr.yml | 4 ++-- chat_test.go | 34 ---------------------------------- reasoning_validator.go | 32 -------------------------------- 3 files changed, 2 insertions(+), 68 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a41fff9..ea0c327 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -18,9 +18,9 @@ jobs: run: | go vet . - name: Run golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v6 with: - version: latest + version: v1.63.4 - name: Run tests run: go test -race -covermode=atomic -coverprofile=coverage.out -v . - name: Upload coverage reports to Codecov diff --git a/chat_test.go b/chat_test.go index fc6c4a9..e90142d 100644 --- a/chat_test.go +++ b/chat_test.go @@ -106,40 +106,6 @@ func TestO1ModelsChatCompletionsBetaLimitations(t *testing.T) { }, expectedError: openai.ErrReasoningModelLimitationsLogprobs, }, - { - name: "message_type_unsupported", - in: openai.ChatCompletionRequest{ - MaxCompletionTokens: 1000, - Model: openai.O1Mini, - Messages: []openai.ChatCompletionMessage{ - { - Role: openai.ChatMessageRoleSystem, - }, - }, - }, - expectedError: openai.ErrO1BetaLimitationsMessageTypes, - }, - { - name: "tool_unsupported", - in: openai.ChatCompletionRequest{ - MaxCompletionTokens: 1000, - Model: openai.O1Mini, - Messages: []openai.ChatCompletionMessage{ - { - Role: openai.ChatMessageRoleUser, - }, - { - Role: openai.ChatMessageRoleAssistant, - }, - }, - Tools: []openai.Tool{ - { - Type: openai.ToolTypeFunction, - }, - }, - }, - expectedError: openai.ErrO1BetaLimitationsTools, - }, { name: "set_temperature_unsupported", in: openai.ChatCompletionRequest{ diff --git a/reasoning_validator.go b/reasoning_validator.go index 4d4671b..040d6b4 100644 --- a/reasoning_validator.go +++ b/reasoning_validator.go @@ -28,16 +28,6 @@ var ( ErrReasoningModelLimitationsOther = errors.New("this model has beta-limitations, temperature, top_p and n are fixed at 1, while presence_penalty and frequency_penalty are fixed at 0") //nolint:lll ) -var unsupportedToolsForO1Models = map[ToolType]struct{}{ - ToolTypeFunction: {}, -} - -var availableMessageRoleForO1Models = map[string]struct{}{ - ChatMessageRoleUser: {}, - ChatMessageRoleAssistant: {}, - ChatMessageRoleDeveloper: {}, -} - // ReasoningValidator handles validation for o-series model requests. type ReasoningValidator struct{} @@ -59,12 +49,6 @@ func (v *ReasoningValidator) Validate(request ChatCompletionRequest) error { return err } - if o1Series { - if err := v.validateO1Specific(request); err != nil { - return err - } - } - return nil } @@ -94,19 +78,3 @@ func (v *ReasoningValidator) validateReasoningModelParams(request ChatCompletion return nil } - -// validateO1Specific checks O1-specific limitations. -func (v *ReasoningValidator) validateO1Specific(request ChatCompletionRequest) error { - for _, m := range request.Messages { - if _, found := availableMessageRoleForO1Models[m.Role]; !found { - return ErrO1BetaLimitationsMessageTypes - } - } - - for _, t := range request.Tools { - if _, found := unsupportedToolsForO1Models[t.Type]; found { - return ErrO1BetaLimitationsTools - } - } - return nil -}