mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
Add Handling of Cache Prompt When Formatting Messages (#3773)
* Add Handling of Cache Prompt When Formatting Messages * Fix Value for Cache Control * Fix Value for Cache Control * Update openhands/core/message.py Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> * Fix lint error * Serialize Messages if Propt Caching Is Enabled * Remove formatting message change --------- Co-authored-by: Engel Nyst <enyst@users.noreply.github.com> Co-authored-by: tobitege <10787084+tobitege@users.noreply.github.com>
This commit is contained in:
@@ -72,12 +72,14 @@ class Message(BaseModel):
|
||||
|
||||
|
||||
def format_messages(
|
||||
messages: Union[Message, list[Message]], with_images: bool
|
||||
messages: Union[Message, list[Message]],
|
||||
with_images: bool,
|
||||
with_prompt_caching: bool,
|
||||
) -> list[dict]:
|
||||
if not isinstance(messages, list):
|
||||
messages = [messages]
|
||||
|
||||
if with_images:
|
||||
if with_images or with_prompt_caching:
|
||||
return [message.model_dump() for message in messages]
|
||||
|
||||
converted_messages = []
|
||||
@@ -113,4 +115,5 @@ def format_messages(
|
||||
'content': content_str,
|
||||
}
|
||||
)
|
||||
|
||||
return converted_messages
|
||||
|
||||
Reference in New Issue
Block a user