diff --git a/instructor/function_calls.py b/instructor/function_calls.py index 53cb6d5..4fc6321 100644 --- a/instructor/function_calls.py +++ b/instructor/function_calls.py @@ -122,12 +122,12 @@ class OpenAISchema(BaseModel): Returns: cls (OpenAISchema): An instance of the class """ - if completion.choices[0].finish_reason == "length": - raise IncompleteOutputException() - if stream_multitask: return cls.from_streaming_response(completion, mode) + if completion.choices[0].finish_reason == "length": + raise IncompleteOutputException() + message = completion.choices[0].message if mode == Mode.FUNCTIONS: @@ -183,12 +183,13 @@ class OpenAISchema(BaseModel): Returns: cls (OpenAISchema): An instance of the class """ - if completion.choices[0].finish_reason == "length": - raise IncompleteOutputException() if stream_multitask: return await cls.from_streaming_response_async(completion, mode) + if completion.choices[0].finish_reason == "length": + raise IncompleteOutputException() + message = completion.choices[0].message if mode == Mode.FUNCTIONS: diff --git a/tests/openai/util.py b/tests/openai/util.py index 9ef2461..1234286 100644 --- a/tests/openai/util.py +++ b/tests/openai/util.py @@ -5,5 +5,4 @@ modes = [ instructor.Mode.FUNCTIONS, instructor.Mode.JSON, instructor.Mode.TOOLS, - instructor.Mode.MD_JSON, ]