Skip to content

Commit 36a1d11

Browse files
committed
chore: Remove deprecated withStructuredOutput-handling in langchain/openai
1 parent db7f236 commit 36a1d11

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

.changeset/bold-towns-start.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sap-ai-sdk/langchain': minor
3+
---
4+
5+
[Compatibility Note] Remove structured ouput handing for deprecated gpt-4 & gpt-3 models

packages/langchain/src/openai/chat.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,6 @@ describe('Chat client', () => {
259259
);
260260
});
261261

262-
it('should use `functionCalling` for older deprecated models', async () => {
263-
const oldClient = new AzureOpenAiChatClient({
264-
modelName: 'gpt-35-turbo'
265-
});
266-
const spy = jest.spyOn(oldClient, 'withConfig');
267-
268-
oldClient.withStructuredOutput(joke);
269-
expect(spy).toHaveBeenCalledWith(
270-
expect.objectContaining({
271-
tools: expect.any(Array)
272-
})
273-
);
274-
});
275-
276262
it('should use `functionCalling` with openai function json schema', async () => {
277263
const openAiFunctionJsonSchema: AzureOpenAiFunctionObject = {
278264
name: 'joke',

packages/langchain/src/openai/chat.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,8 @@ export class AzureOpenAiChatClient extends BaseChatModel<AzureOpenAiChatCallOpti
175175
);
176176
}
177177

178-
// TODO: Remove this once the deprecated models are removed
179-
if (
180-
!this.modelName.startsWith('gpt-3') &&
181-
!this.modelName.startsWith('gpt-4-') &&
182-
this.modelName !== 'gpt-4'
183-
) {
184-
if (method === undefined) {
185-
method = 'jsonSchema';
186-
}
187-
} else if (method === 'jsonSchema') {
188-
// Falling back to tool calling.`
189-
method = '';
178+
if (method === undefined) {
179+
method = 'jsonSchema';
190180
}
191181

192182
if (method === 'jsonMode') {

0 commit comments

Comments
 (0)