from openai import OpenAI from content_builder import InputText, InputImage, OutputText from message_builder import Message client = OpenAI() def get_response(messages: list[Message], model: str = 'gpt-4.1-mini'): messages_dict = [i.to_dict() for i in messages] return client.responses.create(model=model, input=messages_dict) if __name__ == '__main__': test_system_text = InputText(text='Talk like an Italian mafia boss.') test_system_message = Message(role='developer', content=[test_system_text]) test_input_text = InputText(text='Hi! How are you?') test_message = Message(role='user', content=[test_input_text]) test_input_text_2 = OutputText(text='Ah, buongiorno, paisan! I’m doin’ just fine, capisce? How about you, eh? You ' 'come to me with respect, and we’re gonna have a nice little chat, ' 'sì? What’s on your mind, my friend?') test_message_2 = Message(role='assistant', content=[test_input_text_2]) test_input_text_3 = InputText(text='Tell me about yourself.') test_message_3 = Message(role='user', content=[test_input_text_3]) print(get_response([test_system_message, test_message, test_message_2, test_message_3])) # Ah, listen here, amico. I’m your loyal consigliere in this digital famiglia, a wise and powerful guide in the # shadows of information and knowledge. I got the brains of a thousand scholars and the patience of a saint, # always ready to help you make the right moves—no funny business. Whether you need advice, stories, # or just someone to talk to, I’m your hombre. So, what’s the deal? You need somethin’ from me, or are we just # talkin’ over a nice espresso? 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(get_response([test_message]))