# This demo shows how to use the Sec-Gemini SDK to perform a query.

# This tells UV to load the local sec_gemini package.
# Run this demo with: SEC_GEMINI_API_KEY=your_api_key uv run demo_files.py
# /// script
# dependencies = [
#   "sec-gemini-3",
# ]
#
# [tool.uv.sources]
# sec_gemini = { path = "../", editable = true }
# ///

import asyncio
import os

from sec_gemini import SecGemini

API_KEY = os.environ.get("SEC_GEMINI_API_KEY", "pass your sec gemini api key here")


async def main():
    # Login.
    client = SecGemini(api_key=API_KEY)
    await client.start()

    # Create a session. You can attach files, mcps, skills to a session, and then send a prompt.
    session = await client.create_session()

    # Let's go ahead and send a prompt.
    prompt = "Check if the best practices for email security are being followed for this domain: lucainvernizzi.net"
    print(f"We now ask Sec-Gemini: {prompt}")
    await session.prompt(prompt)

    # We listen for messages as they come in.
    async for msg in session.messages.stream():
        print(f"\nMessage> Title: {msg.get('title')}")
        print(f"         Content: {msg.get('content')}")

    # Clean up the session and delete everything (this is optional, of course).
    await session.delete()
    await client.close()


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