File size: 706 Bytes
2aa4095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from google.genai.types import Part, Content, UserContent

class ConversationBuilder:
    def build_with_user_content(self, user_text: str):
        response = [
            UserContent(parts=[Part(text=user_text)]), # will get a role='user' automatically 
        ]
        return response

    def build_with_content_only(self, model_text: str):
        response = [
            Content(parts=[Part(text=model_text)], role='model')
        ]
        return response

    def build_combined(self, user_text: str, model_text: str):
        response = [
            UserContent(parts=[Part(text=user_text)]),
            Content(parts=[Part(text=model_text)], role='model')
        ]
        return response