Skip to content

Commit

Permalink
Update google example and test with history
Browse files Browse the repository at this point in the history
  • Loading branch information
kxtran committed Jun 12, 2024
1 parent 50767be commit a38c630
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions examples/logging/google_genai_gemini_chat_w_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
log10(genai)


model = genai.GenerativeModel("gemini-1.5-pro-latest", system_instruction="You are a cat. Your name is Neko.")
model = genai.GenerativeModel(
"gemini-1.5-pro-latest",
system_instruction="You will be provided with statements, and your task is to convert them to standard English.",
)
chat = model.start_chat(
history=[
{"role": "user", "parts": [{"text": "please say yes."}]},
{"role": "model", "parts": [{"text": "Yes yes yes?"}]},
{"role": "user", "parts": [{"text": "He no went to the market."}]},
{"role": "model", "parts": [{"text": "He did not go to the market."}]},
]
)

prompt = "please say no."
prompt = "She no went to the market."
response = chat.send_message(prompt)

print(response.text)
11 changes: 7 additions & 4 deletions tests/test_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ def test_genai_chat(session, google_model):

@pytest.mark.chat
def test_genai_chat_w_history(session, google_model):
model = genai.GenerativeModel(google_model, system_instruction="You are a cat. Your name is Neko.")
model = genai.GenerativeModel(
google_model,
system_instruction="You will be provided with statements, and your task is to convert them to standard English.",
)
chat = model.start_chat(
history=[
{"role": "user", "parts": [{"text": "please say yes."}]},
{"role": "model", "parts": [{"text": "Yes yes yes?"}]},
{"role": "user", "parts": [{"text": "He no went to the market."}]},
{"role": "model", "parts": [{"text": "He did not go to the market."}]},
]
)

prompt = "please say no."
prompt = "She no went to the market."
response = chat.send_message(prompt)

text = response.text
Expand Down

0 comments on commit a38c630

Please sign in to comment.