mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 18:50:33 +00:00
core[patch]: update structured output tracing (#30123)
- Trace JSON schema in `options` - Rename to `ls_structured_output_format`
This commit is contained in:
@@ -1014,7 +1014,10 @@ class ChatAnthropic(BaseChatModel):
|
||||
warnings.warn(thinking_admonition)
|
||||
llm = self.bind_tools(
|
||||
[schema],
|
||||
structured_output_format={"kwargs": {}, "schema": formatted_tool},
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "function_calling"},
|
||||
"schema": formatted_tool,
|
||||
},
|
||||
)
|
||||
|
||||
def _raise_if_no_tool_calls(message: AIMessage) -> AIMessage:
|
||||
@@ -1329,7 +1332,10 @@ class ChatAnthropic(BaseChatModel):
|
||||
llm = self.bind_tools(
|
||||
[schema],
|
||||
tool_choice=tool_name,
|
||||
structured_output_format={"kwargs": {}, "schema": formatted_tool},
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "function_calling"},
|
||||
"schema": formatted_tool,
|
||||
},
|
||||
)
|
||||
|
||||
if isinstance(schema, type) and is_basemodel_subclass(schema):
|
||||
|
||||
@@ -970,7 +970,7 @@ class ChatFireworks(BaseChatModel):
|
||||
llm = self.bind_tools(
|
||||
[schema],
|
||||
tool_choice=tool_name,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "function_calling"},
|
||||
"schema": formatted_tool,
|
||||
},
|
||||
@@ -987,7 +987,7 @@ class ChatFireworks(BaseChatModel):
|
||||
elif method == "json_mode":
|
||||
llm = self.bind(
|
||||
response_format={"type": "json_object"},
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "json_mode"},
|
||||
"schema": schema,
|
||||
},
|
||||
|
||||
@@ -1001,7 +1001,7 @@ class ChatGroq(BaseChatModel):
|
||||
llm = self.bind_tools(
|
||||
[schema],
|
||||
tool_choice=tool_name,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "function_calling"},
|
||||
"schema": formatted_tool,
|
||||
},
|
||||
@@ -1018,7 +1018,7 @@ class ChatGroq(BaseChatModel):
|
||||
elif method == "json_mode":
|
||||
llm = self.bind(
|
||||
response_format={"type": "json_object"},
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "json_mode"},
|
||||
"schema": schema,
|
||||
},
|
||||
|
||||
@@ -950,7 +950,7 @@ class ChatMistralAI(BaseChatModel):
|
||||
llm = self.bind_tools(
|
||||
[schema],
|
||||
tool_choice="any",
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "function_calling"},
|
||||
"schema": schema,
|
||||
},
|
||||
@@ -968,7 +968,7 @@ class ChatMistralAI(BaseChatModel):
|
||||
elif method == "json_mode":
|
||||
llm = self.bind(
|
||||
response_format={"type": "json_object"},
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {
|
||||
# this is correct - name difference with mistral api
|
||||
"method": "json_mode"
|
||||
@@ -990,7 +990,7 @@ class ChatMistralAI(BaseChatModel):
|
||||
response_format = _convert_to_openai_response_format(schema, strict=True)
|
||||
llm = self.bind(
|
||||
response_format=response_format,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": "json_schema"},
|
||||
"schema": schema,
|
||||
},
|
||||
|
||||
@@ -1090,7 +1090,7 @@ class ChatOllama(BaseChatModel):
|
||||
llm = self.bind_tools(
|
||||
[schema],
|
||||
tool_choice=tool_name,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": formatted_tool,
|
||||
},
|
||||
@@ -1107,7 +1107,7 @@ class ChatOllama(BaseChatModel):
|
||||
elif method == "json_mode":
|
||||
llm = self.bind(
|
||||
format="json",
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": schema,
|
||||
},
|
||||
@@ -1127,7 +1127,7 @@ class ChatOllama(BaseChatModel):
|
||||
schema = cast(TypeBaseModel, schema)
|
||||
llm = self.bind(
|
||||
format=schema.model_json_schema(),
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": schema,
|
||||
},
|
||||
@@ -1148,7 +1148,7 @@ class ChatOllama(BaseChatModel):
|
||||
response_format = schema
|
||||
llm = self.bind(
|
||||
format=response_format,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": response_format,
|
||||
},
|
||||
|
||||
@@ -1431,7 +1431,7 @@ class BaseChatOpenAI(BaseChatModel):
|
||||
tool_choice=tool_name,
|
||||
parallel_tool_calls=False,
|
||||
strict=strict,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": schema,
|
||||
},
|
||||
@@ -1450,7 +1450,7 @@ class BaseChatOpenAI(BaseChatModel):
|
||||
elif method == "json_mode":
|
||||
llm = self.bind(
|
||||
response_format={"type": "json_object"},
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": schema,
|
||||
},
|
||||
@@ -1469,7 +1469,7 @@ class BaseChatOpenAI(BaseChatModel):
|
||||
response_format = _convert_to_openai_response_format(schema, strict=strict)
|
||||
llm = self.bind(
|
||||
response_format=response_format,
|
||||
structured_output_format={
|
||||
ls_structured_output_format={
|
||||
"kwargs": {"method": method},
|
||||
"schema": convert_to_openai_tool(schema),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user