mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-19 21:08:13 +00:00
Address PR feedback: Enhance type safety and add tests for multimodal validation
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from enum import Enum
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
from typing import Any, Dict, List, Literal, Optional, Union
|
||||
|
||||
from crewai.utilities.events.base_events import CrewEvent
|
||||
|
||||
@@ -11,11 +11,47 @@ class LLMCallType(Enum):
|
||||
LLM_CALL = "llm_call"
|
||||
|
||||
|
||||
class ContentType(str, Enum):
|
||||
"""Types of content in multimodal messages"""
|
||||
|
||||
TEXT = "text"
|
||||
IMAGE_URL = "image_url"
|
||||
|
||||
|
||||
class LLMCallStartedEvent(CrewEvent):
|
||||
"""Event emitted when a LLM call starts"""
|
||||
|
||||
type: str = "llm_call_started"
|
||||
messages: Union[str, List[Dict[str, Any]]]
|
||||
messages: Union[
|
||||
str,
|
||||
List[Union[
|
||||
str,
|
||||
Dict[str, Union[
|
||||
str,
|
||||
List[Dict[str, Union[
|
||||
str,
|
||||
Dict[Literal["url"], str]
|
||||
]]]
|
||||
]]
|
||||
]]
|
||||
]
|
||||
"""
|
||||
Supports both string messages and structured messages including multimodal content.
|
||||
Formats supported:
|
||||
1. Simple string: "This is a message"
|
||||
2. List of message objects: [{"role": "user", "content": "Hello"}]
|
||||
3. Mixed list with strings and objects: ["Simple message", {"role": "user", "content": "Hello"}]
|
||||
4. Multimodal format:
|
||||
{
|
||||
'role': str,
|
||||
'content': List[
|
||||
Union[
|
||||
Dict[Literal["type", "text"], str],
|
||||
Dict[Literal["type", "image_url"], Dict[str, str]]
|
||||
]
|
||||
]
|
||||
}
|
||||
"""
|
||||
tools: Optional[List[dict]] = None
|
||||
callbacks: Optional[List[Any]] = None
|
||||
available_functions: Optional[Dict[str, Any]] = None
|
||||
|
||||
Reference in New Issue
Block a user