From 168761616567a1cf2645c98f6f19329877f0beaa Mon Sep 17 00:00:00 2001 From: LinYushen Date: Thu, 21 Nov 2024 04:26:10 +0800 Subject: [PATCH] o1 model support stream (#904) --- chat_stream_test.go | 21 --------------------- completion.go | 7 ------- 2 files changed, 28 deletions(-) diff --git a/chat_stream_test.go b/chat_stream_test.go index 14684146..28a9acf6 100644 --- a/chat_stream_test.go +++ b/chat_stream_test.go @@ -36,27 +36,6 @@ func TestChatCompletionsStreamWrongModel(t *testing.T) { } } -func TestChatCompletionsStreamWithO1BetaLimitations(t *testing.T) { - config := openai.DefaultConfig("whatever") - config.BaseURL = "http://localhost/v1/chat/completions" - client := openai.NewClientWithConfig(config) - ctx := context.Background() - - req := openai.ChatCompletionRequest{ - Model: openai.O1Preview, - Messages: []openai.ChatCompletionMessage{ - { - Role: openai.ChatMessageRoleUser, - Content: "Hello!", - }, - }, - } - _, err := client.CreateChatCompletionStream(ctx, req) - if !errors.Is(err, openai.ErrO1BetaLimitationsStreaming) { - t.Fatalf("CreateChatCompletion should return ErrO1BetaLimitationsStreaming, but returned: %v", err) - } -} - func TestCreateChatCompletionStream(t *testing.T) { client, server, teardown := setupOpenAITestServer() defer teardown() diff --git a/completion.go b/completion.go index 77ea8c3a..9e307369 100644 --- a/completion.go +++ b/completion.go @@ -15,7 +15,6 @@ var ( var ( ErrO1BetaLimitationsMessageTypes = errors.New("this model has beta-limitations, user and assistant messages only, system messages are not supported") //nolint:lll - ErrO1BetaLimitationsStreaming = errors.New("this model has beta-limitations, streaming not supported") //nolint:lll ErrO1BetaLimitationsTools = errors.New("this model has beta-limitations, tools, function calling, and response format parameters are not supported") //nolint:lll ErrO1BetaLimitationsLogprobs = errors.New("this model has beta-limitations, logprobs not supported") //nolint:lll ErrO1BetaLimitationsOther = 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 @@ -199,12 +198,6 @@ func validateRequestForO1Models(request ChatCompletionRequest) error { return ErrO1MaxTokensDeprecated } - // Beta Limitations - // refs:https://platform.openai.com/docs/guides/reasoning/beta-limitations - // Streaming: not supported - if request.Stream { - return ErrO1BetaLimitationsStreaming - } // Logprobs: not supported. if request.LogProbs { return ErrO1BetaLimitationsLogprobs