feat: refactor the POST agent/messages API to take multiple messages (#1882)

This commit is contained in:
Charles Packer
2024-10-14 13:29:07 -07:00
committed by GitHub
parent 93aacc087e
commit f408436669
4 changed files with 87 additions and 22 deletions

View File

@@ -2,7 +2,7 @@ import copy
import json
import warnings
from datetime import datetime, timezone
from typing import List, Optional
from typing import List, Literal, Optional
from pydantic import Field, field_validator
@@ -57,7 +57,11 @@ class BaseMessage(LettaBase):
class MessageCreate(BaseMessage):
"""Request to create a message"""
role: MessageRole = Field(..., description="The role of the participant.")
# In the simplified format, only allow simple roles
role: Literal[
MessageRole.user,
MessageRole.system,
] = Field(..., description="The role of the participant.")
text: str = Field(..., description="The text of the message.")
name: Optional[str] = Field(None, description="The name of the participant.")