aboutsummaryrefslogtreecommitdiffstats
path: root/.agents/tests/test_basic.py
blob: 39fba1d76b6154b21db7d714684aae7fedf5ba9d (plain) (blame)
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
41
42
43
44
45
import asyncio
import sys
sys.path.insert(0, "/home/claude/host/gemini-py/src")

from gemini import GeminiClient, GeminiOptions, query

CREDS = "/home/claude/host/config/.gemini/oauth_creds.json"

async def test_non_streaming():
    print("=== Non-streaming test ===")
    opts = GeminiOptions(model="gemini-2.5-flash-lite")
    async with GeminiClient(options=opts, credentials_path=CREDS) as client:
        response = await client.send_message("Say hello in exactly 3 words.")
        print("Response:", response.text)
        print("Thinking:", response.thinking[:100] if response.thinking else "(none)")
        print("Usage:", response.usage_metadata)
    print()

async def test_streaming():
    print("=== Streaming test ===")
    opts = GeminiOptions(model="gemini-2.5-flash-lite")
    async with GeminiClient(options=opts, credentials_path=CREDS) as client:
        print("Response: ", end="")
        async for chunk in client.send_message_stream("Count from 1 to 5."):
            print(chunk.text_delta, end="", flush=True)
        print()
    print()

async def test_multi_turn():
    print("=== Multi-turn test ===")
    opts = GeminiOptions(model="gemini-2.5-flash-lite")
    async with GeminiClient(options=opts, credentials_path=CREDS) as client:
        r1 = await client.send_message("My name is Alice.")
        print("Turn 1:", r1.text)
        r2 = await client.send_message("What is my name?")
        print("Turn 2:", r2.text)
    print()

async def main():
    await test_non_streaming()
    await test_streaming()
    await test_multi_turn()

if __name__ == "__main__":
    asyncio.run(main())