-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Modifying schema to support multi modal inputs. #1673
Open
rohit-rptless
wants to merge
3
commits into
letta-ai:main
Choose a base branch
from
rohit-rptless:multimodaldraft
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
from memgpt.schemas.enums import MessageRole | ||
from memgpt.schemas.memgpt_base import MemGPTBase | ||
from memgpt.schemas.memgpt_message import LegacyMemGPTMessage, MemGPTMessage | ||
from memgpt.schemas.openai.chat_completions import ToolCall | ||
from memgpt.schemas.openai.chat_completions import ToolCall, MultiModalMessage | ||
from memgpt.utils import get_utc_time, is_utc_datetime | ||
|
||
|
||
|
@@ -62,6 +62,7 @@ class Message(BaseMessage): | |
id: str = BaseMessage.generate_id_field() | ||
role: MessageRole = Field(..., description="The role of the participant.") | ||
text: str = Field(..., description="The text of the message.") | ||
content: Union[str, MultiModalMessage] = Field(None, description="Content entered by the user.") | ||
user_id: str = Field(None, description="The unique identifier of the user.") | ||
agent_id: str = Field(None, description="The unique identifier of the agent.") | ||
model: Optional[str] = Field(None, description="The model used to make the function call.") | ||
|
@@ -223,8 +224,9 @@ def to_openai_dict( | |
|
||
elif self.role == "user": | ||
assert all([v is not None for v in [self.text, self.role]]), vars(self) | ||
content = self.mm_content if self.mm_content is not None else self.text | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we do the above (replace |
||
openai_message = { | ||
"content": self.text, | ||
"content": content, | ||
"role": self.role, | ||
} | ||
# Optional field, do not include if null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,15 @@ class SystemMessage(BaseModel): | |
role: str = "system" | ||
name: Optional[str] = None | ||
|
||
class MultiModalMessage(BaseModel): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
type: str | ||
image_url: str | ||
|
||
class UserMessage(BaseModel): | ||
content: Union[str, List[str]] | ||
content: Union[str, List[MultiModalMessage]] | ||
role: str = "user" | ||
name: Optional[str] = None | ||
|
||
|
||
class ToolCallFunction(BaseModel): | ||
name: str | ||
arguments: str | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, should delete/deprecate
text
and replace withcontent
which can beNone
,str
(text-only), orList[dict/MultiModalMessagePart]
(multi-modal).