{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "# Setup" ] }, { "cell_type": "code", "execution_count": null, "id": "1", "metadata": {}, "outputs": [], "source": [ "# If not already in your PYTHONPATH, add the project root so we can import agent-2\n", "import sys, os, pathlib, importlib\n", "\n", "project_root = pathlib.Path.cwd() # adjust if the notebook sits elsewhere\n", "sys.path.append(str(project_root))\n", "\n", "# Optional: load .env for API keys\n", "from dotenv import load_dotenv\n", "load_dotenv() # expects OPENAI_API_KEY and NEBIUS_API_KEY\n", "\n", "\n", "import os\n", "os.environ[\"LANGSMITH_TRACING\"] = \"true\"" ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "# Import Agent" ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "# import agent\n", "agent_module = importlib.import_module(\"agent\") # agent.py ➜ agent\n", "Agent = agent_module.Agent # grab the class" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "# Initiate\n", "agent = Agent()" ] }, { "cell_type": "code", "execution_count": null, "id": "5", "metadata": {}, "outputs": [], "source": [ "# visualise\n", "from IPython.display import Image, display\n", "\n", "try:\n", " display(Image(agent.graph.get_graph().draw_mermaid_png()))\n", "except Exception:\n", " # This requires some extra dependencies and is optional\n", " pass" ] }, { "cell_type": "markdown", "id": "6", "metadata": {}, "source": [ "# Question" ] }, { "cell_type": "code", "execution_count": null, "id": "7", "metadata": {}, "outputs": [], "source": [ "# Question\n", "question_text = \"How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?\"\n", "\n", "\n", "answer = agent(question=question_text)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8", "metadata": {}, "outputs": [], "source": [ "print(answer)" ] }, { "cell_type": "code", "execution_count": null, "id": "9", "metadata": {}, "outputs": [], "source": [ "\n", "print(\"Answer:\", answer)" ] }, { "cell_type": "code", "execution_count": null, "id": "10", "metadata": {}, "outputs": [], "source": [ "# Show the messages\n", "for m in answer['Answer']:\n", " m.pretty_print()" ] } ], "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.12.8" } }, "nbformat": 4, "nbformat_minor": 5 }