Explorar el Código

fix: o1-series model encounters an error when the generate mode is blocking (#8363)

takatost hace 7 meses
padre
commit
24af4b9313
Se han modificado 1 ficheros con 6 adiciones y 4 borrados
  1. 6 4
      api/core/model_runtime/model_providers/openai/llm/llm.py

+ 6 - 4
api/core/model_runtime/model_providers/openai/llm/llm.py

@@ -615,10 +615,12 @@ class OpenAILargeLanguageModel(_CommonOpenAI, LargeLanguageModel):
 
         block_as_stream = False
         if model.startswith("o1"):
-            block_as_stream = True
-            stream = False
-            if "stream_options" in extra_model_kwargs:
-                del extra_model_kwargs["stream_options"]
+            if stream:
+                block_as_stream = True
+                stream = False
+
+                if "stream_options" in extra_model_kwargs:
+                    del extra_model_kwargs["stream_options"]
 
             if "stop" in extra_model_kwargs:
                 del extra_model_kwargs["stop"]