-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatHistoryWithInitialMessages.py
More file actions
40 lines (34 loc) · 994 Bytes
/
Copy pathChatHistoryWithInitialMessages.py
File metadata and controls
40 lines (34 loc) · 994 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from config.GeminiModel import model
chat = model.start_chat(history=[
{
"role": "user",
"parts": ["Hi. How are you?"]
},
{
"role": "model",
"parts": ["I am doing fine. Thanks for asking."]
},
{
"role": "user",
"parts": ["What are you doing today?"]
},
{
"role": "model",
"parts": ["Just surfing web and waiting for any task to perform"]
},
])
print("Chat History before conversation:\n" + str(chat.history))
message = "I have one for you. Should I ask?"
print("Me: " + message)
reply = chat.send_message(message)
print("Gemini: " + reply.text)
message = "What's your favorite fruit?"
print("Me: " + message)
reply = chat.send_message(message)
print("Gemini: " + reply.text)
message = "What is today's date?"
print("Me: " + message)
reply = chat.send_message(message)
print("Gemini: " + reply.text)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("\nComplete Chat History after conversation: \n" + str(chat.history))