File size: 561 Bytes
34df346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from google.genai import types


async def json_to_google_chat(chat) : 

    contents = []

    for row in chat : 

        role = row['role']

        if role == 'user' : contents.append(
            types.Content(
                role = 'user' , 
                parts = [types.Part.from_text(text = str(row['content']))]
            )
        )

        else : contents.append(
            types.Content(
                role = 'model' , 
                parts = [types.Part.from_text(text = str(row['content']))]
            )
        )

    return contents