mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-04 22:49:23 +00:00
fix: wrap sync instructor.to_json() in asyncio.to_thread for ato_json
Addresses Cursor Bugbot feedback: the function-calling path in ato_json was still calling _create_instructor().to_json() synchronously, blocking the event loop. Now wrapped in asyncio.to_thread() to offload the blocking call to a separate thread. Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import re
|
||||
from typing import TYPE_CHECKING, Any, Final, TypedDict
|
||||
@@ -225,7 +226,7 @@ class Converter(OutputConverter):
|
||||
"""
|
||||
try:
|
||||
if self.llm.supports_function_calling():
|
||||
return self._create_instructor().to_json()
|
||||
return await asyncio.to_thread(self._create_instructor().to_json)
|
||||
return json.dumps(
|
||||
await self.llm.acall(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user