fix: remove validateO1Specific (#939)
* fix: remove validateO1Specific * update golangci-lint-action version * fix actions * fix actions * fix actions * fix actions * remove some o1 test
This commit is contained in:
4
.github/workflows/pr.yml
vendored
4
.github/workflows/pr.yml
vendored
@@ -18,9 +18,9 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
go vet .
|
go vet .
|
||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v4
|
uses: golangci/golangci-lint-action@v6
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: v1.63.4
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: go test -race -covermode=atomic -coverprofile=coverage.out -v .
|
run: go test -race -covermode=atomic -coverprofile=coverage.out -v .
|
||||||
- name: Upload coverage reports to Codecov
|
- name: Upload coverage reports to Codecov
|
||||||
|
|||||||
34
chat_test.go
34
chat_test.go
@@ -106,40 +106,6 @@ func TestO1ModelsChatCompletionsBetaLimitations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedError: openai.ErrReasoningModelLimitationsLogprobs,
|
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",
|
name: "set_temperature_unsupported",
|
||||||
in: openai.ChatCompletionRequest{
|
in: openai.ChatCompletionRequest{
|
||||||
|
|||||||
@@ -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
|
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.
|
// ReasoningValidator handles validation for o-series model requests.
|
||||||
type ReasoningValidator struct{}
|
type ReasoningValidator struct{}
|
||||||
|
|
||||||
@@ -59,12 +49,6 @@ func (v *ReasoningValidator) Validate(request ChatCompletionRequest) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if o1Series {
|
|
||||||
if err := v.validateO1Specific(request); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,19 +78,3 @@ func (v *ReasoningValidator) validateReasoningModelParams(request ChatCompletion
|
|||||||
|
|
||||||
return nil
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user