Skip to content

Commit 612ccf8

Browse files
authored
chore: [openai] bump sdk (#31958)
1 parent b5462b8 commit 612ccf8

File tree

5 files changed

+1489
-1455
lines changed

5 files changed

+1489
-1455
lines changed

libs/partners/openai/langchain_openai/chat_models/_compat.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
"summary": [{"type": "summary_text", "text": "Reasoning summary"}],
1717
},
1818
"tool_outputs": [
19-
{"type": "web_search_call", "id": "websearch_123", "status": "completed"}
19+
{
20+
"type": "web_search_call",
21+
"id": "websearch_123",
22+
"status": "completed",
23+
}
2024
],
2125
"refusal": "I cannot assist with that.",
2226
},

libs/partners/openai/langchain_openai/chat_models/azure.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ class AzureChatOpenAI(BaseChatOpenAI):
138138
139139
AIMessage(
140140
content="J'adore programmer.",
141-
usage_metadata={"input_tokens": 28, "output_tokens": 6, "total_tokens": 34},
141+
usage_metadata={
142+
"input_tokens": 28,
143+
"output_tokens": 6,
144+
"total_tokens": 34,
145+
},
142146
response_metadata={
143147
"token_usage": {
144148
"completion_tokens": 6,
@@ -184,8 +188,12 @@ class AzureChatOpenAI(BaseChatOpenAI):
184188
AIMessageChunk(content="ad", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f")
185189
AIMessageChunk(content="ore", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f")
186190
AIMessageChunk(content=" la", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f")
187-
AIMessageChunk(content=" programm", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f")
188-
AIMessageChunk(content="ation", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f")
191+
AIMessageChunk(
192+
content=" programm", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f"
193+
)
194+
AIMessageChunk(
195+
content="ation", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f"
196+
)
189197
AIMessageChunk(content=".", id="run-a6f294d3-0700-4f6a-abc2-c6ef1178c37f")
190198
AIMessageChunk(
191199
content="",
@@ -294,7 +302,9 @@ class Joke(BaseModel):
294302
295303
setup: str = Field(description="The setup of the joke")
296304
punchline: str = Field(description="The punchline to the joke")
297-
rating: Optional[int] = Field(description="How funny the joke is, from 1 to 10")
305+
rating: Optional[int] = Field(
306+
description="How funny the joke is, from 1 to 10"
307+
)
298308
299309
300310
structured_llm = llm.with_structured_output(Joke)
@@ -930,7 +940,9 @@ class AnswerWithJustification(BaseModel):
930940
)
931941
932942
933-
llm = AzureChatOpenAI(azure_deployment="...", model="gpt-4o", temperature=0)
943+
llm = AzureChatOpenAI(
944+
azure_deployment="...", model="gpt-4o", temperature=0
945+
)
934946
structured_llm = llm.with_structured_output(AnswerWithJustification)
935947
936948
structured_llm.invoke(
@@ -961,7 +973,9 @@ class AnswerWithJustification(BaseModel):
961973
)
962974
963975
964-
llm = AzureChatOpenAI(azure_deployment="...", model="gpt-4o", temperature=0)
976+
llm = AzureChatOpenAI(
977+
azure_deployment="...", model="gpt-4o", temperature=0
978+
)
965979
structured_llm = llm.with_structured_output(
966980
AnswerWithJustification, method="function_calling"
967981
)
@@ -990,7 +1004,9 @@ class AnswerWithJustification(BaseModel):
9901004
justification: str
9911005
9921006
993-
llm = AzureChatOpenAI(azure_deployment="...", model="gpt-4o", temperature=0)
1007+
llm = AzureChatOpenAI(
1008+
azure_deployment="...", model="gpt-4o", temperature=0
1009+
)
9941010
structured_llm = llm.with_structured_output(
9951011
AnswerWithJustification, include_raw=True
9961012
)
@@ -1022,7 +1038,9 @@ class AnswerWithJustification(TypedDict):
10221038
]
10231039
10241040
1025-
llm = AzureChatOpenAI(azure_deployment="...", model="gpt-4o", temperature=0)
1041+
llm = AzureChatOpenAI(
1042+
azure_deployment="...", model="gpt-4o", temperature=0
1043+
)
10261044
structured_llm = llm.with_structured_output(AnswerWithJustification)
10271045
10281046
structured_llm.invoke(

libs/partners/openai/langchain_openai/chat_models/base.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,9 @@ class ChatOpenAI(BaseChatOpenAI): # type: ignore[override]
21262126
21272127
AIMessageChunk(content="", id="run-9e1517e3-12bf-48f2-bb1b-2e824f7cd7b0")
21282128
AIMessageChunk(content="J", id="run-9e1517e3-12bf-48f2-bb1b-2e824f7cd7b0")
2129-
AIMessageChunk(content="'adore", id="run-9e1517e3-12bf-48f2-bb1b-2e824f7cd7b0")
2129+
AIMessageChunk(
2130+
content="'adore", id="run-9e1517e3-12bf-48f2-bb1b-2e824f7cd7b0"
2131+
)
21302132
AIMessageChunk(content=" la", id="run-9e1517e3-12bf-48f2-bb1b-2e824f7cd7b0")
21312133
AIMessageChunk(
21322134
content=" programmation", id="run-9e1517e3-12bf-48f2-bb1b-2e824f7cd7b0"
@@ -2182,7 +2184,11 @@ class ChatOpenAI(BaseChatOpenAI): # type: ignore[override]
21822184
"logprobs": None,
21832185
},
21842186
id="run-012cffe2-5d3d-424d-83b5-51c6d4a593d1-0",
2185-
usage_metadata={"input_tokens": 31, "output_tokens": 5, "total_tokens": 36},
2187+
usage_metadata={
2188+
"input_tokens": 31,
2189+
"output_tokens": 5,
2190+
"total_tokens": 36,
2191+
},
21862192
)
21872193
21882194
.. dropdown:: Tool calling
@@ -2299,7 +2305,9 @@ class GetPopulation(BaseModel):
22992305
tool = {"type": "web_search_preview"}
23002306
llm_with_tools = llm.bind_tools([tool])
23012307
2302-
response = llm_with_tools.invoke("What was a positive news story from today?")
2308+
response = llm_with_tools.invoke(
2309+
"What was a positive news story from today?"
2310+
)
23032311
response.content
23042312
23052313
.. code-block:: python
@@ -2346,7 +2354,8 @@ class GetPopulation(BaseModel):
23462354
.. code-block:: python
23472355
23482356
second_response = llm.invoke(
2349-
"What is my name?", previous_response_id=response.response_metadata["id"]
2357+
"What is my name?",
2358+
previous_response_id=response.response_metadata["id"],
23502359
)
23512360
second_response.text()
23522361
@@ -2424,7 +2433,9 @@ class Joke(BaseModel):
24242433
24252434
setup: str = Field(description="The setup of the joke")
24262435
punchline: str = Field(description="The punchline to the joke")
2427-
rating: Optional[int] = Field(description="How funny the joke is, from 1 to 10")
2436+
rating: Optional[int] = Field(
2437+
description="How funny the joke is, from 1 to 10"
2438+
)
24282439
24292440
24302441
structured_llm = llm.with_structured_output(Joke)

libs/partners/openai/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ target-version = "py39"
6565

6666
[tool.ruff.lint]
6767
select = ["E", "F", "I", "T201", "UP", "S"]
68-
ignore = [ "UP007", ]
68+
ignore = [ "UP007", "UP045" ]
6969

7070
[tool.ruff.format]
7171
docstring-code-format = true

0 commit comments

Comments
 (0)