Skip to content

Commit

Permalink
fix: resolve issue langchain-ai#29513 - cannot retrieve reasoning_con…
Browse files Browse the repository at this point in the history
…tent while streaming

Extract reasoning_content in the _convert_delta_to_message_chunk function
  • Loading branch information
codergma committed Feb 2, 2025
1 parent 0c782ee commit 9c3eb74
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libs/partners/openai/langchain_openai/chat_models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def _convert_delta_to_message_chunk(
role = cast(str, _dict.get("role"))
content = cast(str, _dict.get("content") or "")
additional_kwargs: Dict = {}

if _dict.get("reasoning_content"):
additional_kwargs["reasoning_content"] = _dict["reasoning_content"]

if _dict.get("function_call"):
function_call = dict(_dict["function_call"])
if "name" in function_call and function_call["name"] is None:
Expand Down Expand Up @@ -1356,9 +1360,9 @@ def with_structured_output(

if method == "json_schema":
# Check for Pydantic BaseModel V1
if (
is_pydantic_schema and issubclass(schema, BaseModelV1) # type: ignore[arg-type]
):
if is_pydantic_schema and issubclass(
schema, BaseModelV1
): # type: ignore[arg-type]
warnings.warn(
"Received a Pydantic BaseModel V1 schema. This is not supported by "
'method="json_schema". Please use method="function_calling" '
Expand Down

0 comments on commit 9c3eb74

Please sign in to comment.