mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 23:32:39 +00:00
fix: Resolve type checking errors in prompt caching implementation
- Add type ignore comment for intentional content field transformation - Convert ChatCompletionDeltaToolCall to ToolCall format for event emission - Fixes mypy errors on lines 416 and 789 Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -413,7 +413,7 @@ class LLM(BaseLLM):
|
|||||||
):
|
):
|
||||||
content = message.get("content", "")
|
content = message.get("content", "")
|
||||||
if isinstance(content, str):
|
if isinstance(content, str):
|
||||||
formatted_message["content"] = [
|
formatted_message["content"] = [ # type: ignore[assignment]
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"text": content,
|
"text": content,
|
||||||
@@ -783,10 +783,21 @@ class LLM(BaseLLM):
|
|||||||
tool_call.function.arguments
|
tool_call.function.arguments
|
||||||
)
|
)
|
||||||
assert hasattr(crewai_event_bus, "emit")
|
assert hasattr(crewai_event_bus, "emit")
|
||||||
|
# Convert ChatCompletionDeltaToolCall to ToolCall format
|
||||||
|
from crewai.events.types.llm_events import ToolCall, FunctionCall
|
||||||
|
converted_tool_call = ToolCall(
|
||||||
|
id=tool_call.id,
|
||||||
|
function=FunctionCall(
|
||||||
|
name=tool_call.function.name,
|
||||||
|
arguments=tool_call.function.arguments or ""
|
||||||
|
),
|
||||||
|
type=tool_call.type,
|
||||||
|
index=tool_call.index
|
||||||
|
)
|
||||||
crewai_event_bus.emit(
|
crewai_event_bus.emit(
|
||||||
self,
|
self,
|
||||||
event=LLMStreamChunkEvent(
|
event=LLMStreamChunkEvent(
|
||||||
tool_call=tool_call.to_dict(),
|
tool_call=converted_tool_call,
|
||||||
chunk=tool_call.function.arguments,
|
chunk=tool_call.function.arguments,
|
||||||
from_task=from_task,
|
from_task=from_task,
|
||||||
from_agent=from_agent,
|
from_agent=from_agent,
|
||||||
|
|||||||
Reference in New Issue
Block a user