mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 00:48:45 +00:00
langchain: sync -> async methods in OpenAI assistants (#21378)
This commit is contained in:
parent
ad3fd44a7f
commit
080af0ec53
@ -434,7 +434,7 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
|
|||||||
],
|
],
|
||||||
"metadata": input.get("thread_metadata"),
|
"metadata": input.get("thread_metadata"),
|
||||||
}
|
}
|
||||||
run = await self._create_thread_and_run(input, thread)
|
run = await self._acreate_thread_and_run(input, thread)
|
||||||
# Starting a new run in an existing thread.
|
# Starting a new run in an existing thread.
|
||||||
elif "run_id" not in input:
|
elif "run_id" not in input:
|
||||||
_ = await self.async_client.beta.threads.messages.create(
|
_ = await self.async_client.beta.threads.messages.create(
|
||||||
@ -444,14 +444,14 @@ class OpenAIAssistantRunnable(RunnableSerializable[Dict, OutputType]):
|
|||||||
file_ids=input.get("file_ids", []),
|
file_ids=input.get("file_ids", []),
|
||||||
metadata=input.get("message_metadata"),
|
metadata=input.get("message_metadata"),
|
||||||
)
|
)
|
||||||
run = await self._create_run(input)
|
run = await self._acreate_run(input)
|
||||||
# Submitting tool outputs to an existing run, outside the AgentExecutor
|
# Submitting tool outputs to an existing run, outside the AgentExecutor
|
||||||
# framework.
|
# framework.
|
||||||
else:
|
else:
|
||||||
run = await self.async_client.beta.threads.runs.submit_tool_outputs(
|
run = await self.async_client.beta.threads.runs.submit_tool_outputs(
|
||||||
**input
|
**input
|
||||||
)
|
)
|
||||||
run = await self._wait_for_run(run.id, run.thread_id)
|
run = await self._await_for_run(run.id, run.thread_id)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
run_manager.on_chain_error(e)
|
run_manager.on_chain_error(e)
|
||||||
raise e
|
raise e
|
||||||
|
Loading…
Reference in New Issue
Block a user