22 lines
663 B
Python
22 lines
663 B
Python
from dataclasses import dataclass
|
|
from content_builder import Content, InputText, InputImage
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Message:
|
|
role: str
|
|
content: list[Content]
|
|
|
|
def to_dict(self):
|
|
return {
|
|
"role": self.role,
|
|
"content": [i_content.to_dict() for i_content in self.content]
|
|
}
|
|
|
|
|
|
if __name__ == '__main__':
|
|
test_input_text = InputText(text='What\'s on this image?')
|
|
test_input_image = InputImage(image_url='https://upload.wikimedia.org/wikipedia/commons/7/72/Skansen_Bobrka_2.jpg')
|
|
test_message = Message(role='user', content=[test_input_text, test_input_image])
|
|
print(test_message.to_dict())
|