mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,8 @@ class Message(BaseModel):
|
||||
# - tool execution result (to LLM)
|
||||
tool_call_id: str | None = None
|
||||
name: str | None = None # name of the tool
|
||||
# force string serializer
|
||||
force_string_serializer: bool = False
|
||||
|
||||
@property
|
||||
def contains_image(self) -> bool:
|
||||
@@ -73,7 +75,9 @@ class Message(BaseModel):
|
||||
# - into a single string: for providers that don't support list of content items (e.g. no vision, no tool calls)
|
||||
# - into a list of content items: the new APIs of providers with vision/prompt caching/tool calls
|
||||
# NOTE: remove this when litellm or providers support the new API
|
||||
if self.cache_enabled or self.vision_enabled or self.function_calling_enabled:
|
||||
if not self.force_string_serializer and (
|
||||
self.cache_enabled or self.vision_enabled or self.function_calling_enabled
|
||||
):
|
||||
return self._list_serializer()
|
||||
# some providers, like HF and Groq/llama, don't support a list here, but a single string
|
||||
return self._string_serializer()
|
||||
|
||||
Reference in New Issue
Block a user