langchain[patch]: Upgrade openai's sdk and solve some interface adaptation problems. #19548 (#19785)

- #19548
- @baskaryan @eyurtsev PTAL

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
pull/19831/head
Guangdong Liu 6 months ago committed by GitHub
parent c42ec58578
commit b6ebddbacc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -515,6 +515,12 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
if run.status == "completed":
import openai
major_version = int(openai.version.VERSION.split(".")[0])
minor_version = int(openai.version.VERSION.split(".")[1])
version_gte_1_14 = (major_version > 1) or (
major_version == 1 and minor_version >= 14
)
messages = self.client.beta.threads.messages.list(
run.thread_id, order="asc"
)
@ -527,7 +533,7 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
if all(
(
isinstance(content, openai.types.beta.threads.TextContentBlock)
if openai.version.VERSION.startswith("1.14")
if version_gte_1_14
else isinstance(
content, openai.types.beta.threads.MessageContentText
)
@ -637,6 +643,12 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
if run.status == "completed":
import openai
major_version = int(openai.version.VERSION.split(".")[0])
minor_version = int(openai.version.VERSION.split(".")[1])
version_gte_1_14 = (major_version > 1) or (
major_version == 1 and minor_version >= 14
)
messages = await self.async_client.beta.threads.messages.list(
run.thread_id, order="asc"
)
@ -649,7 +661,7 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
if all(
(
isinstance(content, openai.types.beta.threads.TextContentBlock)
if openai.version.VERSION.startswith("1.14")
if version_gte_1_14
else isinstance(
content, openai.types.beta.threads.MessageContentText
)

Loading…
Cancel
Save