{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Structured Responses"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.models.message_parts.text import TextPart\n",
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GenerationConfig,\n",
    "    GoogleGenerationProvider,\n",
    "    UserMessage,\n",
    ")\n",
    "from dotenv import load_dotenv\n",
    "\n",
    "from pydantic import BaseModel\n",
    "\n",
    "load_dotenv()\n",
    "\n",
    "\n",
    "class DangerousDogsResponse(BaseModel):\n",
    "    dangerous_dogs: list[str]\n",
    "\n",
    "\n",
    "provider = GoogleGenerationProvider(\n",
    "    use_vertex_ai=False,\n",
    ")\n",
    "\n",
    "generation = provider.create_generation(\n",
    "    model=\"gemini-1.5-flash\",\n",
    "    messages=[\n",
    "        UserMessage(\n",
    "            parts=[\n",
    "                TextPart(text=\"Hello, how are you?\"),\n",
    "                TextPart(text=\"What are the most dangerous dogs in the world?\"),\n",
    "            ]\n",
    "        )\n",
    "    ],\n",
    "    generation_config=GenerationConfig(timeout=10),\n",
    ")\n",
    "\n",
    "print(generation.parsed)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from agentle.generations.providers.google.google_generation_provider import (\n",
    "    GoogleGenerationProvider,\n",
    ")\n",
    "from agentle.agents.agent import Agent\n",
    "from agentle.mcp.servers.http_mcp_server import HTTPMCPServer\n",
    "\n",
    "class FakeHTTPMCPServer(HTTPMCPServer):\n",
    "    \n",
    "\n",
    "def get_weather(location: str) -> str:\n",
    "    return \"The weather in \" + location + \" is sunny.\"\n",
    "\n",
    "weather_agent = Agent(\n",
    "    generation_provider=GoogleGenerationProvider(),\n",
    "    model=\"gemini-2.0-flash\",\n",
    "    instructions=\"You are a weather agent that can answer questions about the weather.\",\n",
    "    tools=[get_weather],\n",
    ")\n",
    "\n",
    "output = weather_agent.run(\"Hello. What is the weather in Tokyo?\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
