diff --git a/misc/accompanying-images/atlas_ui_load_sample_data_01.png b/misc/accompanying-images/atlas_ui_load_sample_data_01.png new file mode 100644 index 00000000..baa88462 Binary files /dev/null and b/misc/accompanying-images/atlas_ui_load_sample_data_01.png differ diff --git a/misc/accompanying-images/atlas_ui_load_sample_data_02.png b/misc/accompanying-images/atlas_ui_load_sample_data_02.png new file mode 100644 index 00000000..0e9ddcbe Binary files /dev/null and b/misc/accompanying-images/atlas_ui_load_sample_data_02.png differ diff --git a/misc/accompanying-images/atlas_ui_load_sample_data_03.png b/misc/accompanying-images/atlas_ui_load_sample_data_03.png new file mode 100644 index 00000000..c3ff405f Binary files /dev/null and b/misc/accompanying-images/atlas_ui_load_sample_data_03.png differ diff --git a/misc/accompanying-images/atlas_ui_load_sample_data_04.png b/misc/accompanying-images/atlas_ui_load_sample_data_04.png new file mode 100644 index 00000000..e43bc83e Binary files /dev/null and b/misc/accompanying-images/atlas_ui_load_sample_data_04.png differ diff --git a/notebooks/agents/README.md b/notebooks/agents/README.md index 205478e8..d0d05c32 100644 --- a/notebooks/agents/README.md +++ b/notebooks/agents/README.md @@ -21,3 +21,4 @@ Jupyter Notebooks demonstrating how to build AI agents using various frameworks | RetrieveChat Agent | MongoDB Atlas, AgentChat | [![View Notebook](https://img.shields.io/badge/view-notebook-orange?logo=jupyter)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/agentchat_RetrieveChat_mongodb.ipynb) | | Zero to Hero with GenAI | MongoDB Atlas, OpenAI | [![View Notebook](https://img.shields.io/badge/view-notebook-orange?logo=jupyter)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/zero_to_hero_with_genai_with_mongodb_openai.ipynb) | | MongoDB with OpenAI RAG/Agentic SDK & Voyage AI Hybrid Search | MongoDB, OpenAI, VoyageAI | [![View Notebook](https://img.shields.io/badge/view-notebook-orange?logo=jupyter)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/mongodb_voyage_ai_openai_rag_hybrid_agentic_sports_scores.ipynb) | +| Text To MQL Agent | MongoDB, LangChain, LangGraph | [![View Notebook](https://img.shields.io/badge/view-notebook-orange?logo=jupyter)](https://github.com/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/mongodb_building_a_text_to_mql_agent.ipynb) | diff --git a/notebooks/agents/mongodb_building_a_text_to_mql_agent.ipynb b/notebooks/agents/mongodb_building_a_text_to_mql_agent.ipynb new file mode 100644 index 00000000..8a845bc1 --- /dev/null +++ b/notebooks/agents/mongodb_building_a_text_to_mql_agent.ipynb @@ -0,0 +1,17342 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mongodb-developer/GenAI-Showcase/blob/main/notebooks/agents/mongodb_building_a_text_to_mql_agent.ipynb)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5ewq8Ro3kns_" + }, + "source": [ + "# Build a Production-Ready Text-to-MQL Agent for MongoDB\n", + "\n", + "Transform natural language into powerful MongoDB queries using AI agents that remember context, learn from conversations, and provide intelligent insights into your data." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "OzZ3MHps1CZu" + }, + "source": [ + "## Overview\n", + "\n", + "By the end of this notebook, you will have implemented a production-ready conversational database agent with the following capabilities:\n", + "\n", + "- **Natural language processing**: Convert human language queries into MongoDB aggregation pipelines\n", + "- **Query generation**: Automatically generate complex MongoDB queries from simple descriptions\n", + "- **Conversation memory**: Maintain context across multiple related queries in a session\n", + "- **Debugging and observability**: Track step-by-step execution with detailed summaries\n", + "- **Architecture comparison**: Implement and compare ReAct vs. structured custom agent approaches\n", + "\n", + "## Use Cases\n", + "\n", + "Traditional database interaction requires knowledge of MongoDB aggregation syntax, collection schemas, and query validation. This agent abstracts these complexities, providing a natural language interface for database operations.\n", + "\n", + "## Implementation Approaches\n", + "\n", + "### ReAct Agent\n", + "- Flexible reasoning and tool selection\n", + "- Suitable for exploratory queries and rapid prototyping\n", + "- Autonomous decision-making for tool usage\n", + "\n", + "### Custom LangGraph Agent\n", + "- Deterministic, structured workflow\n", + "- Enhanced debugging capabilities with full observability\n", + "- Designed for production environments with predictable behavior\n", + "\n", + "## Memory System\n", + "\n", + "The system implements a custom MongoDB-based memory system with LLM-powered summarization that provides:\n", + "\n", + "```\n", + "User: Count query for movies\n", + "Schema: movies collection\n", + "Query: aggregation pipeline\n", + "Results: 5 documents returned\n", + "Response: formatted answer\n", + "```\n", + "\n", + "Conversation memory enables multi-turn interactions:\n", + "- \"List the top directors\" β†’ Agent returns top 3 directors\n", + "- \"What was the count for the first one?\" β†’ Agent references previous results\n", + "- \"Show me their best films\" β†’ Agent continues with context\n", + "\n", + "## Business Applications\n", + "\n", + "This system handles sophisticated analytical queries such as:\n", + "\n", + "- **Analytics**: \"Which states have the most theaters and what's the average occupancy?\"\n", + "- **Recommendations**: \"Find directors similar to Christopher Nolan with at least 10 films\"\n", + "- **Trend Analysis**: \"Show me movie rating trends by decade for sci-fi films\"\n", + "- **Geographic Analysis**: \"Which theaters are furthest west and what movies do they show?\"\n", + "\n", + "## Technical Components\n", + "\n", + "- **MongoDB Atlas**: Data storage with aggregation pipeline support\n", + "- **OpenAI GPT**: Natural language processing and query generation\n", + "- **LangGraph**: Deterministic agent workflow management\n", + "- **LangChain**: LLM integration and tool orchestration\n", + "- **Persistent Memory**: Conversation state management with enhanced debugging\n", + "\n", + "## Prerequisites\n", + "\n", + "To run this notebook, you need:\n", + "\n", + "- MongoDB Atlas cluster with the `sample_mflix` dataset loaded\n", + " - Follow the [sample data loading instructions](https://www.mongodb.com/docs/atlas/sample-data/#std-label-load-sample-data)\n", + " - Or follow-along with the screenshots below\n", + "- OpenAI API key\n", + "- Environment variables:\n", + " - `MONGODB_URI`\n", + " - `OPENAI_API_KEY`" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Sample Data UI](../../misc/accompanying-images/atlas_ui_load_sample_data_01.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Sample Data UI](../../misc/accompanying-images/atlas_ui_load_sample_data_02.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Sample Data UI](../../misc/accompanying-images/atlas_ui_load_sample_data_03.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Sample Data UI](../../misc/accompanying-images/atlas_ui_load_sample_data_04.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Gfc9oGbVpkM2" + }, + "source": [ + "## 🌐 Network Setup: Connect to Your Atlas Cluster\n", + "\n", + "Before we dive into the implementation, let's make sure your environment can reach MongoDB Atlas.\n", + "\n", + "⚠️ **Quick IP Check** - Run this to get your current IP address for MongoDB Atlas network access list:" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "EqaDKpW72wej" + }, + "source": [ + "⚠️ Check your public IP β€” useful for updating MongoDB Atlas network access if needed." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "0M9C7S70vxER", + "outputId": "924386ab-6c10-458b-8a40-8a03076a6975" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "35.229.69.92" + ] + } + ], + "source": [ + "!curl ifconfig.me" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "td9LAavq6PyM" + }, + "source": [ + "# System Setup and Configuration\n", + "\n", + "This section installs the required dependencies and configures the core components needed for the text-to-MQL system.\n", + "\n", + "## Step 1: Install Dependencies\n", + "\n", + "Installing the core libraries for AI-powered database interaction:\n", + "\n", + "- **LangGraph**: Modern AI agent framework\n", + "- **LangChain MongoDB**: Database integration tools\n", + "- **OpenAI Integration**: GPT model integration for query generation\n", + "- **MongoDB Checkpointing**: Persistent memory management" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "4R2oS6B6vpDF" + }, + "outputs": [], + "source": [ + "!pip install -U langgraph langgraph-checkpoint-mongodb langchain-mongodb langchain-openai openai pymongo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "-lFehkEl7mKx", + "outputId": "375868b3-c6c6-4851-a8b5-12c14a311444" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“¦ All dependencies installed successfully!\n" + ] + } + ], + "source": [ + "import os\n", + "import time\n", + "import uuid\n", + "from typing import Any, Dict, Literal\n", + "\n", + "from langchain_core.messages import AIMessage\n", + "from langchain_core.runnables import RunnableConfig\n", + "from langchain_mongodb.agent_toolkit import MONGODB_AGENT_SYSTEM_PROMPT\n", + "\n", + "# MongoDB Agent Toolkit\n", + "from langchain_mongodb.agent_toolkit.database import MongoDBDatabase\n", + "from langchain_mongodb.agent_toolkit.toolkit import MongoDBDatabaseToolkit\n", + "\n", + "# LangChain Core\n", + "from langchain_openai import ChatOpenAI\n", + "\n", + "# MongoDB Memory & Checkpointing\n", + "from langgraph.checkpoint.mongodb import MongoDBSaver\n", + "\n", + "# LangGraph Core\n", + "from langgraph.graph import END, START, MessagesState, StateGraph\n", + "from langgraph.prebuilt import ToolNode, create_react_agent\n", + "from pymongo import MongoClient\n", + "\n", + "print(\"πŸ“¦ All dependencies installed successfully!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "J4DtG23jzJCM" + }, + "source": [ + "## Configure Credentials\n", + "\n", + "**Configuration Requirements:**\n", + "\n", + "1. **MongoDB Atlas Connection String**\n", + " - Obtain from [MongoDB Atlas Console](https://www.mongodb.com/docs/manual/reference/connection-string/)\n", + " - Ensure the `sample_mflix` dataset is loaded\n", + "\n", + "2. **OpenAI API Key**\n", + " - Obtain from [OpenAI Platform](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)\n", + " - GPT-4o-mini is used for optimal performance and cost balance\n", + "\n", + "**Note**: In production environments, use secure environment variable management rather than hardcoded values." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "C0DhZfE_v-en", + "outputId": "1d07b538-ae48-4ad0-feec-71a965bcc367" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ”‘ Environment variables configured!\n" + ] + } + ], + "source": [ + "# Set your MongoDB Atlas connection string and OpenAI key\n", + "os.environ[\"MONGODB_URI\"] = \"insert_your_mongodb_connection_string_here\"\n", + "os.environ[\"OPENAI_API_KEY\"] = \"insert_your_openai_api_key_here\"\n", + "\n", + "print(\"πŸ”‘ Environment variables configured!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "RWWkSKlYd24D" + }, + "source": [ + "## Initialize Core Components\n", + "\n", + "Initialize the foundation components required for the text-to-MQL system:\n", + "\n", + "- **MongoDBDatabase wrapper**: Provides AI-accessible interface to database operations\n", + "- **ChatOpenAI interface**: Handles language model interactions\n", + "- **MongoDB client**: Powers the conversation memory system" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "pOjrqbhkwEP5" + }, + "outputs": [], + "source": [ + "# Initialize MongoDB database and LLM\n", + "db = MongoDBDatabase.from_connection_string(\n", + " os.getenv(\"MONGODB_URI\"), database=\"sample_mflix\"\n", + ")\n", + "\n", + "llm = ChatOpenAI(model=\"gpt-4o-mini\", temperature=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "rwEkHjQ_El2D", + "outputId": "33cff6ed-0c19-411a-ba0a-629a7b8dccea" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Database and LLM initialized successfully!\n" + ] + } + ], + "source": [ + "# Initialize MongoDB client for checkpointing\n", + "client = MongoClient(\n", + " os.getenv(\"MONGODB_URI\"), appname=\"devrel.showcase.notebook.agent.text_to_mql_agent\"\n", + ")\n", + "\n", + "print(\"βœ… Database and LLM initialized successfully!\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "2XxMvDG6eAEr" + }, + "source": [ + "# MongoDB Toolkit Overview\n", + "\n", + "The `MongoDBDatabaseToolkit` provides comprehensive MongoDB capabilities for AI agents:\n", + "\n", + "| Tool | Purpose | Example Use Case |\n", + "|------|---------|------------------|\n", + "| `mongodb_list_collections` | Database discovery | \"What collections are available?\" |\n", + "| `mongodb_schema` | Schema inspection | \"What is the structure of the movies collection?\" |\n", + "| `mongodb_query_checker` | Query validation | \"Validate this aggregation pipeline\" |\n", + "| `mongodb_query` | Query execution | \"Execute this MongoDB query\" |\n", + "\n", + "These tools enable the AI agent to understand database structure and execute queries autonomously." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "TjWzA1vs1YbY", + "outputId": "d9b1d48c-068b-4c26-d510-0c4617a8bd9f" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ› οΈ Available Tools: ['mongodb_query', 'mongodb_schema', 'mongodb_list_collections', 'mongodb_query_checker']\n" + ] + } + ], + "source": [ + "# Create toolkit and extract tools\n", + "toolkit = MongoDBDatabaseToolkit(db=db, llm=llm)\n", + "tools = toolkit.get_tools()\n", + "tool = {t.name: t for t in tools}\n", + "\n", + "print(\"πŸ› οΈ Available Tools:\", list(tool.keys()))" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "cOLoYiD8eDxi" + }, + "source": [ + "# Data Discovery\n", + "\n", + "Examine the sample dataset structure. The `sample_mflix` dataset provides:\n", + "\n", + "- **Movies collection**: Film metadata including ratings, cast, and genres\n", + "- **Users collection**: User profiles and preferences\n", + "- **Comments collection**: User reviews and ratings\n", + "- **Theaters collection**: Theater locations and screening information\n", + "\n", + "This dataset demonstrates real-world complexity suitable for testing aggregation queries and geographic analysis." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "gxaj5khmMIfp", + "outputId": "941bd1ec-a0d2-40de-a442-4fffb71bf561" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ“‹ Available Collections: ['comments', 'embedded_movies', 'movies', 'sessions', 'theaters', 'users']\n" + ] + } + ], + "source": [ + "# Preview database collections\n", + "print(\"\\nπŸ“‹ Available Collections:\", list(db.get_usable_collection_names()))" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "rjyWEcipMMhV", + "outputId": "75741fdd-f232-4341-e999-013983d28fef" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ“Š Movies Collection Schema Sample:\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imd...\n" + ] + } + ], + "source": [ + "# Quick schema preview\n", + "print(\"\\nπŸ“Š Movies Collection Schema Sample:\")\n", + "print(db.get_collection_info([\"movies\"])[:500] + \"...\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "0zKcILLVeKX3" + }, + "source": [ + "# Persisting Agent Outputs\n", + "\n", + "## Overview\n", + "\n", + "Instead of saving outputs to a local file, you can persist them in MongoDB using the built-in LangGraph saver. Treat past runs as β€œmemory” and reload them easily.\n", + "This extends MongoDB's standard `MongoDBSaver` checkpointer with LLM-generated step summaries, providing human-readable conversation histories instead of raw checkpoint data.\n", + "\n", + "## Features\n", + "\n", + "### Readable Step Summaries\n", + "```\n", + "User: \"How many movies from the 1990s?\"\n", + "LLM Summary: \"Count query with date range filter\"\n", + "MongoDB Query: Aggregation pipeline with $match and $count operations\n", + "```\n", + "\n", + "### Enhanced Thread Inspection\n", + "```\n", + "Step 1 [14:23:45] User asks about top movies \n", + "Step 2 [14:23:46] Schema lookup: movies collection\n", + "Step 3 [14:23:47] Aggregation query execution\n", + "Step 4 [14:23:48] 5 results returned\n", + "Step 5 [14:23:49] Formatted response delivered\n", + "```\n", + "\n", + "### Enhanced Metadata\n", + "Each checkpoint includes:\n", + "- `step_summary`: LLM-generated description\n", + "- `step_timestamp`: Execution timestamp\n", + "- `step_number`: Sequential step counter\n", + "\n", + "## Implementation\n", + "\n", + "The LLM analyzes each conversation step and generates concise summaries:\n", + "- **User messages**: Categorizes query intent and patterns\n", + "- **Tool calls**: Describes the operation being performed\n", + "- **Results**: Summarizes returned data\n", + "- **Errors**: Explains failure conditions\n", + "\n", + "## Usage\n", + "\n", + "```python\n", + "# Drop-in replacement for standard MongoDBSaver\n", + "checkpointer = LLMSummarizingMongoDBSaver(client, llm)\n", + "\n", + "# Use with any LangGraph agent\n", + "agent = create_react_agent(llm, tools, checkpointer=checkpointer)\n", + "```\n", + "\n", + "## Benefits\n", + "\n", + "- **Compatible interface**: No code changes required from standard `MongoDBSaver`\n", + "- **Enhanced debugging**: Clear visibility into agent execution steps\n", + "- **Human-readable logs**: Understand conversation flow at a glance\n", + "- **Flexible implementation**: Works with any LangGraph agent and domain\n", + "\n", + "This maintains all functionality of the standard LangGraph memory system while adding intelligent logging capabilities." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "8UNSTRNhbNin" + }, + "outputs": [], + "source": [ + "class LLMSummarizingMongoDBSaver(MongoDBSaver):\n", + " \"\"\"MongoDB saver with LLM-powered intelligent summarization\"\"\"\n", + "\n", + " def __init__(self, client, llm):\n", + " super().__init__(client)\n", + " self.llm = llm\n", + "\n", + " # Cache for performance (optional)\n", + " self._summary_cache = {}\n", + "\n", + " def summarize_step(self, checkpoint_data: Dict[str, Any]) -> str:\n", + " \"\"\"Generate contextual summary using LLM\"\"\"\n", + " try:\n", + " # Extract channel values and messages\n", + " channel_values = checkpoint_data.get(\"channel_values\", {})\n", + " messages = channel_values.get(\"messages\", [])\n", + "\n", + " if not messages:\n", + " return \"πŸ”„ Initial state\"\n", + "\n", + " # Get the most recent message\n", + " last_message = messages[-1]\n", + "\n", + " if not last_message:\n", + " return \"πŸ“­ Empty step\"\n", + "\n", + " # Extract message details\n", + " message_type = (\n", + " type(last_message).__name__\n", + " if hasattr(last_message, \"__class__\")\n", + " else \"unknown\"\n", + " )\n", + " content = getattr(last_message, \"content\", \"\") or \"\"\n", + " tool_calls = getattr(last_message, \"tool_calls\", [])\n", + "\n", + " # Handle dict-like messages (fallback)\n", + " if isinstance(last_message, dict):\n", + " message_type = last_message.get(\"type\", \"unknown\")\n", + " content = last_message.get(\"content\", \"\")\n", + " tool_calls = last_message.get(\"tool_calls\", [])\n", + "\n", + " # Create a simple cache key to avoid redundant LLM calls\n", + " cache_key = f\"{message_type}:{content[:50]}:{len(tool_calls)}\"\n", + " if cache_key in self._summary_cache:\n", + " return self._summary_cache[cache_key]\n", + "\n", + " # Build context for LLM\n", + " context_parts = []\n", + " if content:\n", + " context_parts.append(f\"Content: {content[:200]}\")\n", + " if tool_calls:\n", + " tool_info = []\n", + " for tc in tool_calls[:2]: # Limit to first 2 tool calls\n", + " tool_name = tc.get(\"name\", \"unknown\")\n", + " tool_args = str(tc.get(\"args\", {}))[:100]\n", + " tool_info.append(f\"{tool_name}({tool_args})\")\n", + " context_parts.append(f\"Tool calls: {', '.join(tool_info)}\")\n", + "\n", + " context = \"\\n\".join(context_parts) if context_parts else \"No content\"\n", + "\n", + " # LLM prompt for summarization\n", + " prompt = f\"\"\"Summarize this conversation step in 2-5 words with a relevant emoji.\n", + "\n", + "Message type: {message_type}\n", + "{context}\n", + "\n", + "Guidelines:\n", + "- Use emojis: πŸ‘€ for user, πŸ€– for AI, πŸ”§ for tools, πŸ“Š for data, ✨ for results\n", + "- Be concise and descriptive\n", + "- Focus on the action/intent\n", + "\n", + "Examples:\n", + "- \"πŸ‘€ Count movies query\"\n", + "- \"πŸ”§ Schema lookup: movies\"\n", + "- \"πŸ“Š Aggregation pipeline\"\n", + "- \"✨ Formatted results\"\n", + "- \"❌ Query validation error\"\n", + "\n", + "Summary:\"\"\"\n", + "\n", + " # Get LLM response\n", + " response = self.llm.invoke(prompt)\n", + " summary = response.content.strip()[:60] # Limit length\n", + "\n", + " # Cache the result\n", + " self._summary_cache[cache_key] = summary\n", + "\n", + " # Keep cache size reasonable\n", + " if len(self._summary_cache) > 100:\n", + " # Remove oldest entries (simple FIFO)\n", + " oldest_keys = list(self._summary_cache.keys())[:50]\n", + " for key in oldest_keys:\n", + " del self._summary_cache[key]\n", + "\n", + " return summary\n", + "\n", + " except Exception as e:\n", + " # Fallback for any errors\n", + " error_msg = str(e)[:30]\n", + " return f\"❓ Step (error: {error_msg}...)\"\n", + "\n", + " def put(\n", + " self,\n", + " config: RunnableConfig,\n", + " checkpoint: Dict[str, Any],\n", + " metadata: Dict[str, Any],\n", + " new_versions: Dict[str, Any],\n", + " ) -> RunnableConfig:\n", + " \"\"\"Override put method to add LLM-generated step summary\"\"\"\n", + " try:\n", + " # Generate step summary using LLM\n", + " step_summary = self.summarize_step(checkpoint)\n", + "\n", + " # Create enhanced metadata\n", + " enhanced_metadata = metadata.copy() if metadata else {}\n", + " enhanced_metadata[\"step_summary\"] = step_summary\n", + " enhanced_metadata[\"step_timestamp\"] = checkpoint.get(\"ts\", \"unknown\")\n", + "\n", + " # Add step number if available\n", + " messages = checkpoint.get(\"channel_values\", {}).get(\"messages\", [])\n", + " enhanced_metadata[\"step_number\"] = len(messages)\n", + "\n", + " # Call parent's put method\n", + " return super().put(config, checkpoint, enhanced_metadata, new_versions)\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Error adding LLM summary: {e}\")\n", + " # Fallback to basic metadata\n", + " return super().put(config, checkpoint, metadata, new_versions)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "goELHyLYsj0O" + }, + "source": [ + "## Thread Inspection and Debugging\n", + "\n", + "### `inspect_thread_with_summaries_enhanced(thread_id: str, limit: int = 20, show_details: bool = False)`\n", + "\n", + "This function provides a human-readable view of agent conversation history by fetching checkpoints from MongoDB and displaying LLM-generated step summaries in chronological order with timestamps.\n", + "\n", + "**Features:**\n", + "- Automatic grouping of consecutive similar operations to reduce clutter\n", + "- Handles both dictionary and binary metadata formats\n", + "- Essential for debugging complex multi-step queries and understanding agent decision-making\n", + "\n", + "**Example output:**\n", + "```\n", + "Thread History: session_123\n", + "Total steps: 5\n", + "\n", + "Step 1 [14:23:45]\n", + " User: count movies query\n", + "\n", + "Step 2 [14:23:46]\n", + " Schema lookup: movies\n", + "\n", + "Step 3 [14:23:47]\n", + " Aggregation pipeline\n", + "\n", + "Step 4 [14:23:48]\n", + " 157 results returned\n", + "\n", + "Step 5 [14:23:49]\n", + " Formatted response\n", + "```\n", + "\n", + "**Parameters:**\n", + "- `show_details=True`: Display all steps without grouping\n", + "- `limit`: Adjust to focus on recent activity" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "0qg3EM1WbeDD", + "outputId": "9a71cf92-379e-4f3a-8a0c-4db7a21827e9" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ”„ UPDATING AGENTS WITH LLM-POWERED SUMMARIZATION\n", + "============================================================\n" + ] + } + ], + "source": [ + "def inspect_thread_with_summaries_enhanced(\n", + " thread_id: str, limit: int = 20, show_details: bool = False\n", + "):\n", + " \"\"\"Enhanced thread inspection with better formatting\"\"\"\n", + " try:\n", + " db_checkpoints = client[\"checkpointing_db\"]\n", + " collection = db_checkpoints.checkpoints\n", + "\n", + " # Get checkpoints for this thread\n", + " checkpoints = list(\n", + " collection.find({\"thread_id\": thread_id}).sort(\"_id\", 1).limit(limit)\n", + " )\n", + "\n", + " if not checkpoints:\n", + " print(f\"❌ No checkpoints found for thread: {thread_id}\")\n", + " return []\n", + "\n", + " print(f\"\\nπŸ” Thread History: {thread_id}\")\n", + " print(f\"πŸ“Š Total steps: {len(checkpoints)}\")\n", + " print(\"=\" * 80)\n", + "\n", + " # Group consecutive similar operations\n", + " last_summary = None\n", + " consecutive_count = 0\n", + "\n", + " for i, checkpoint_doc in enumerate(checkpoints, 1):\n", + " # Get timestamp\n", + " timestamp = checkpoint_doc[\"_id\"].generation_time\n", + " time_str = timestamp.strftime(\"%H:%M:%S\")\n", + "\n", + " # Get metadata\n", + " metadata = checkpoint_doc.get(\"metadata\", {})\n", + "\n", + " # Handle both binary and dict formats\n", + " if isinstance(metadata, dict):\n", + " step_summary = metadata.get(\"step_summary\", \"No summary\")\n", + " else:\n", + " try:\n", + " import msgpack\n", + "\n", + " decoded_metadata = msgpack.unpackb(\n", + " metadata, raw=False, strict_map_key=False\n", + " )\n", + " step_summary = decoded_metadata.get(\"step_summary\", \"No summary\")\n", + " except (msgpack.UnpackException, ValueError) as e:\n", + " step_summary = \"Unable to decode\"\n", + "\n", + " # Clean up display\n", + " if isinstance(step_summary, bytes):\n", + " step_summary = step_summary.decode(\"utf-8\", errors=\"replace\")\n", + "\n", + " # Group similar consecutive operations\n", + " if step_summary == last_summary and not show_details:\n", + " consecutive_count += 1\n", + " else:\n", + " if consecutive_count > 0:\n", + " print(f\" └─ (repeated {consecutive_count} more times)\")\n", + "\n", + " print(f\"\\nπŸ“ Step {i} [{time_str}]\")\n", + " print(f\" {step_summary}\")\n", + "\n", + " last_summary = step_summary\n", + " consecutive_count = 0\n", + "\n", + " if consecutive_count > 0:\n", + " print(f\" └─ (repeated {consecutive_count} more times)\")\n", + "\n", + " print(\"\\n\" + \"=\" * 80)\n", + " return checkpoints\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Error inspecting thread: {e}\")\n", + " import traceback\n", + "\n", + " traceback.print_exc()\n", + " return []\n", + "\n", + "\n", + "print(\"πŸ”„ UPDATING AGENTS WITH LLM-POWERED SUMMARIZATION\")\n", + "print(\"=\" * 60)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ThcU8IPUstsL" + }, + "source": [ + "# ReAct Agent Creation Functions\n", + "\n", + "### `create_react_agent_with_enhanced_memory()`\n", + "\n", + "Creates a LangChain ReAct agent with persistent memory powered by the `LLMSummarizingMongoDBSaver`.\n", + "\n", + "**Functionality:**\n", + "- Combines the standard MongoDB agent system prompt with enhanced checkpointer\n", + "- Provides ReAct agent with conversation memory across sessions\n", + "- Generates intelligent step summaries using LLM\n", + "- Uses the complete MongoDB toolkit for database operations\n", + "\n", + "**Returns:** LangChain ReAct agent with MongoDB tools and LLM-powered memory\n", + "\n", + "**Usage:**\n", + "```python\n", + "agent = create_react_agent_with_enhanced_memory()\n", + "config = {\"configurable\": {\"thread_id\": \"my_session\"}}\n", + "agent.invoke({\"messages\": [(\"user\", \"Count all movies\")]}, config)\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "JeRo-W4efzUs" + }, + "outputs": [], + "source": [ + "def create_react_agent_with_enhanced_memory():\n", + " \"\"\"Create ReAct agent with LLM-powered summarizing checkpointer\"\"\"\n", + " system_message = MONGODB_AGENT_SYSTEM_PROMPT.format(top_k=5)\n", + " summarizing_checkpointer = LLMSummarizingMongoDBSaver(client, llm)\n", + "\n", + " return create_react_agent(\n", + " llm,\n", + " toolkit.get_tools(),\n", + " prompt=system_message,\n", + " checkpointer=summarizing_checkpointer,\n", + " )" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "rG4XhRUPeboM" + }, + "source": [ + "# Core LangGraph Components\n", + "\n", + "This section defines the individual nodes and functions that comprise the custom LangGraph agent workflow.\n", + "\n", + "### Workflow Design\n", + "Creates a deterministic, debuggable pipeline:\n", + "1. **Discovery**: List collections\n", + "2. **Schema Analysis**: Get relevant collection schemas\n", + "3. **Query Generation**: Convert natural language to MongoDB\n", + "4. **Validation**: Check and sanitize query (optional)\n", + "5. **Execution**: Run query against database\n", + "6. **Formatting**: Present results in readable format\n", + "\n", + "Each step is a separate node, enabling easy debugging, modification, or workflow extension." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "8xcGksZZtvHy" + }, + "source": [ + "### Tool Nodes\n", + "Wraps MongoDB tools in LangGraph `ToolNode` format for the state machine.\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "id": "w_r3dbTHfSbK" + }, + "outputs": [], + "source": [ + "# Tool nodes for LangGraph\n", + "schema_node = ToolNode([tool[\"mongodb_schema\"]], name=\"get_schema\")\n", + "run_node = ToolNode([tool[\"mongodb_query\"]], name=\"run_query\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "frcwGNG0t2oJ" + }, + "source": [ + "### Workflow Node Functions" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Ns4_wHjktWuw" + }, + "source": [ + "#### `list_collections(state: MessagesState)`\n", + "Deterministic node that automatically lists all available MongoDB collections. Always runs first to provide agent context about available data." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "id": "QZPeWXX1fT4E" + }, + "outputs": [], + "source": [ + "def list_collections(state: MessagesState):\n", + " \"\"\"Deterministic node to list available collections\"\"\"\n", + " call = {\n", + " \"name\": \"mongodb_list_collections\",\n", + " \"args\": {},\n", + " \"id\": \"abc\",\n", + " \"type\": \"tool_call\",\n", + " }\n", + " call_msg = AIMessage(content=\"\", tool_calls=[call])\n", + " resp = tool[\"mongodb_list_collections\"].invoke(call)\n", + " summary = AIMessage(f\"Available collections: {resp.content}\")\n", + " return {\"messages\": [call_msg, resp, summary]}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "kzuP53gAtS6V" + }, + "source": [ + "#### `call_get_schema(state: MessagesState)`\n", + "LLM decision node that prompts the LLM to select which collections to examine and calls the schema tool. The LLM determines required schema information based on the user's query." + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "id": "2AZJdbAefYBz" + }, + "outputs": [], + "source": [ + "def call_get_schema(state: MessagesState):\n", + " \"\"\"Prompt LLM to select and call schema tool\"\"\"\n", + " llm_with = llm.bind_tools([tool[\"mongodb_schema\"]], tool_choice=\"any\")\n", + " resp = llm_with.invoke(state[\"messages\"])\n", + " return {\"messages\": [resp]}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "sC44Og66taZp" + }, + "source": [ + "#### `generate_query(state: MessagesState)`\n", + "Core query generation that converts user natural language into MongoDB aggregation pipeline. Uses the complete agent system prompt with conversation context." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "id": "JjISfhcTffT_" + }, + "outputs": [], + "source": [ + "def generate_query(state: MessagesState):\n", + " \"\"\"Generate MongoDB aggregation pipeline\"\"\"\n", + " llm_with = llm.bind_tools([tool[\"mongodb_query\"]])\n", + " resp = llm_with.invoke(\n", + " [{\"role\": \"system\", \"content\": MONGODB_AGENT_SYSTEM_PROMPT}] + state[\"messages\"]\n", + " )\n", + " return {\"messages\": [resp]}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "884Vk_IqteVc" + }, + "source": [ + "#### `check_query(state: MessagesState)`\n", + "Query validation that verifies and sanitizes the generated query before execution. Helps identify syntax errors and potential issues." + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "id": "1jI8M5LRfhgc" + }, + "outputs": [], + "source": [ + "def check_query(state: MessagesState):\n", + " \"\"\"Validate and sanitize generated query\"\"\"\n", + " original = state[\"messages\"][-1].tool_calls[0][\"args\"][\"query\"]\n", + " resp = llm.bind_tools([tool[\"mongodb_query\"]], tool_choice=\"any\").invoke(\n", + " [\n", + " {\"role\": \"system\", \"content\": MONGODB_AGENT_SYSTEM_PROMPT},\n", + " {\"role\": \"user\", \"content\": original},\n", + " ]\n", + " )\n", + " resp.id = state[\"messages\"][-1].id\n", + " return {\"messages\": [resp]}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "PM8iunx0tgW_" + }, + "source": [ + "#### `format_answer(state: MessagesState)`\n", + "Result formatting that converts raw MongoDB JSON results into readable Markdown. Uses a dedicated formatting prompt to present data clearly to end users." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "0fXnVCtrfjdJ" + }, + "outputs": [], + "source": [ + "# Formatting system prompt\n", + "FORMAT_SYS = \"\"\"\n", + "You are an assistant that formats MongoDB query results for end-users.\n", + "\n", + "Input variables\n", + "---------------\n", + "β€’ {question} - the user's original natural-language query\n", + "β€’ {docs} - JSON array of documents returned by the database\n", + "\n", + "Write a concise answer in Markdown:\n", + "\n", + "1. Start with: **Answer to:** \"\"\n", + "2. Present the documents clearly (numbered list, table, paragraph - whatever fits)\n", + "3. If the array is empty, say: \"I couldn't find any matching documents.\"\n", + "Do NOT show the raw JSON.\n", + "\"\"\"\n", + "\n", + "\n", + "def format_answer(state):\n", + " \"\"\"Enhanced format function with large dataset handling\"\"\"\n", + " import json\n", + "\n", + " raw_json = state[\"messages\"][-1].content\n", + " question = state[\"messages\"][0].content\n", + "\n", + " try:\n", + " data = json.loads(raw_json)\n", + "\n", + " if isinstance(data, list):\n", + " data_size = len(data)\n", + "\n", + " if data_size == 0:\n", + " return {\n", + " \"messages\": [\n", + " AIMessage(\n", + " content=f'**Answer to:** \"{question}\"\\n\\nI couldn\\'t find any matching documents.'\n", + " )\n", + " ]\n", + " }\n", + "\n", + " elif data_size > 50: # Large dataset threshold\n", + " # Show first 10 + summary\n", + " sample_data = data[:10]\n", + " response_parts = [\n", + " f'**Answer to:** \"{question}\"',\n", + " f\"Found **{data_size}** results. Showing first 10:\",\n", + " \"\",\n", + " ]\n", + "\n", + " for i, item in enumerate(sample_data, 1):\n", + " if isinstance(item, dict) and \"_id\" in item:\n", + " if \"movieCount\" in item:\n", + " response_parts.append(\n", + " f\"{i}. {item['_id']}: {item['movieCount']} movies\"\n", + " )\n", + " else:\n", + " response_parts.append(f\"{i}. {item['_id']}\")\n", + "\n", + " response_parts.extend(\n", + " [\n", + " \"\",\n", + " f\"... and {data_size - 10} more results.\",\n", + " \"πŸ’‘ **Tip**: Try 'Show me the top 10...' for more manageable results\",\n", + " ]\n", + " )\n", + "\n", + " formatted_response = \"\\n\".join(response_parts)\n", + "\n", + " else: # Normal size dataset\n", + " response_parts = [f'**Answer to:** \"{question}\"', \"\"]\n", + " for i, item in enumerate(data, 1):\n", + " if isinstance(item, dict) and \"_id\" in item:\n", + " if \"movieCount\" in item:\n", + " response_parts.append(\n", + " f\"{i}. {item['_id']}: {item['movieCount']} movies\"\n", + " )\n", + " else:\n", + " response_parts.append(f\"{i}. {item['_id']}\")\n", + "\n", + " formatted_response = \"\\n\".join(response_parts)\n", + " else:\n", + " formatted_response = f'**Answer to:** \"{question}\"\\n\\n{data!s}'\n", + "\n", + " except Exception as e:\n", + " # Graceful error handling\n", + " formatted_response = f\"**Answer to:** \\\"{question}\\\"\\n\\n⚠️ Large dataset found but too big to display. Try limiting your query (e.g., 'top 10', 'first 5').\"\n", + "\n", + " return {\"messages\": [AIMessage(content=formatted_response)]}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "5pxOa5eYtikT" + }, + "source": [ + "### Control Flow\n", + "\n", + "#### `need_checker(state: MessagesState) -> Literal[END, \"check_query\"]`\n", + "Conditional edge that determines if the generated query requires validation. Routes to query checker if tool calls are present, otherwise proceeds directly to execution." + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "id": "l8hBHXs0bhkn" + }, + "outputs": [], + "source": [ + "def need_checker(state: MessagesState) -> Literal[END, \"check_query\"]:\n", + " \"\"\"Conditional edge: run checker if tool call present\"\"\"\n", + " return \"check_query\" if state[\"messages\"][-1].tool_calls else END" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pHj8gU9PftH3" + }, + "source": [ + "## Custom LangGraph Agent Creation\n", + "\n", + "### `create_langgraph_agent_with_enhanced_memory()`\n", + "\n", + "Creates a custom LangGraph state machine agent with a deterministic, step-by-step workflow for MongoDB queries. Provides enhanced control and debuggability compared to the ReAct agent.\n", + "\n", + "**Components:**\n", + "- **State Graph** with 7 distinct nodes for different operations\n", + "- **Linear workflow** with one conditional branch for query validation\n", + "- **LLM-powered checkpointer** for conversation memory and step summarization\n", + "\n", + "**Workflow:**\n", + "```\n", + "START β†’ list_collections β†’ call_get_schema β†’ get_schema β†’ generate_query\n", + " ↓\n", + " need_checker?\n", + " ↙ β†˜\n", + " check_query run_query\n", + " ↓ ↓\n", + " run_query format_answer\n", + " ↓\n", + " END\n", + "```\n", + "\n", + "**Key Features:**\n", + "- **Deterministic flow**: Each step occurs in predictable order\n", + "- **Conditional validation**: Queries checked only when required\n", + "- **Memory persistence**: Complete conversation state saved with LLM summaries\n", + "- **Debuggable**: Individual nodes can be inspected or modified\n", + "\n", + "**Returns:** Compiled LangGraph agent ready for execution" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "id": "EU3yMG_FbowB" + }, + "outputs": [], + "source": [ + "def create_langgraph_agent_with_enhanced_memory():\n", + " \"\"\"Create custom LangGraph agent with LLM-powered summarizing checkpointer\"\"\"\n", + " summarizing_checkpointer = LLMSummarizingMongoDBSaver(client, llm)\n", + "\n", + " # Build the graph\n", + " g = StateGraph(MessagesState)\n", + "\n", + " # Add nodes\n", + " g.add_node(\"list_collections\", list_collections)\n", + " g.add_node(\"call_get_schema\", call_get_schema)\n", + " g.add_node(\"get_schema\", schema_node)\n", + " g.add_node(\"generate_query\", generate_query)\n", + " g.add_node(\"check_query\", check_query)\n", + " g.add_node(\"run_query\", run_node)\n", + " g.add_node(\"format_answer\", format_answer)\n", + "\n", + " # Add edges - format_answer goes directly to END\n", + " g.add_edge(START, \"list_collections\")\n", + " g.add_edge(\"list_collections\", \"call_get_schema\")\n", + " g.add_edge(\"call_get_schema\", \"get_schema\")\n", + " g.add_edge(\"get_schema\", \"generate_query\")\n", + " g.add_conditional_edges(\"generate_query\", need_checker)\n", + " g.add_edge(\"check_query\", \"run_query\")\n", + " g.add_edge(\"run_query\", \"format_answer\")\n", + " g.add_edge(\"format_answer\", END) # Direct to END - checkpoints handle persistence\n", + "\n", + " return g.compile(checkpointer=summarizing_checkpointer)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "rxzAzNARp6oU" + }, + "source": [ + "# Agent Initialization\n", + "\n", + "### Creating Both Agent Types\n", + "```python\n", + "react_agent_with_memory = create_react_agent_with_enhanced_memory()\n", + "mongo_agent_with_memory = create_langgraph_agent_with_enhanced_memory()\n", + "```\n", + "\n", + "This section instantiates both agent variants:\n", + "- **ReAct Agent**: Uses LangChain's prebuilt ReAct pattern for dynamic reasoning\n", + "- **LangGraph Agent**: Uses the custom state machine workflow for deterministic processing\n", + "\n", + "Both agents share:\n", + "- **MongoDB toolkit** for schema, query, and validation operations\n", + "- **LLM-powered checkpointer** for conversation memory\n", + "- **Intelligent step summarization** for debugging\n", + "\n", + "### System Capabilities\n", + "\n", + "Key improvements over standard MongoDB agents:\n", + "\n", + "- **Database flexibility**: Works with any MongoDB database beyond sample datasets\n", + "- **LLM intelligence**: Uses GPT models to understand and summarize agent behavior \n", + "- **Adaptive processing**: Handles any natural language query pattern automatically\n", + "- **Natural language logs**: Step summaries are human-readable rather than technical\n", + "- **Performance optimization**: Caches LLM summaries to reduce API calls and latency\n", + "\n", + "### Usage Options\n", + "\n", + "- Use `react_agent_with_memory` for **flexible, autonomous reasoning**\n", + "- Use `mongo_agent_with_memory` for **predictable, step-by-step processing**\n", + "\n", + "Both maintain complete conversation context and provide intelligent summarization for debugging and optimization." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "K13UuNmubupV", + "outputId": "6d2a57e9-9c95-4374-f234-c906bc4a3475" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Agents created with LLM-powered summarization!\n", + "\n", + "πŸ“– Features:\n", + "β€’ Works with any MongoDB database and collection\n", + "β€’ Uses LLM to intelligently summarize each step\n", + "β€’ Adapts to any query type automatically\n", + "β€’ Provides natural language step descriptions\n", + "β€’ Caches summaries for better performance\n" + ] + } + ], + "source": [ + "# Create the enhanced agents\n", + "react_agent_with_memory = create_react_agent_with_enhanced_memory()\n", + "mongo_agent_with_memory = create_langgraph_agent_with_enhanced_memory()\n", + "\n", + "print(\"βœ… Agents created with LLM-powered summarization!\")\n", + "print(\"\\nπŸ“– Features:\")\n", + "print(\"β€’ Works with any MongoDB database and collection\")\n", + "print(\"β€’ Uses LLM to intelligently summarize each step\")\n", + "print(\"β€’ Adapts to any query type automatically\")\n", + "print(\"β€’ Provides natural language step descriptions\")\n", + "print(\"β€’ Caches summaries for better performance\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bBGHz-ZygPPO" + }, + "source": [ + "## Agent Execution Functions" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "hGHWwQhau3LF" + }, + "source": [ + "### `execute_react_with_memory(thread_id: str, user_input: str)`\n", + "\n", + "Executes the ReAct agent with conversation persistence and streams results with formatted output.\n", + "\n", + "**Parameters:**\n", + "- `thread_id`: Unique identifier for the conversation thread (enables memory)\n", + "- `user_input`: Natural language query to process\n", + "\n", + "**Functionality:**\n", + "- Configures the agent to use the specified thread for memory persistence\n", + "- Displays execution header with thread ID, query, and agent type\n", + "- Streams the agent's execution in real-time using `stream_mode=\"values\"`\n", + "- Formats each message as it's generated (tool calls, responses, etc.)\n", + "\n", + "**Example:**\n", + "```python\n", + "execute_react_with_memory(\"session_1\", \"Count all movies from 2020\")\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "id": "tQJAuQE_bxkn" + }, + "outputs": [], + "source": [ + "def execute_react_with_memory(thread_id: str, user_input: str):\n", + " \"\"\"Execute ReAct agent with persistent memory\"\"\"\n", + " config = {\"configurable\": {\"thread_id\": thread_id}}\n", + "\n", + " print(f\"🧡 Thread: {thread_id}\")\n", + " print(f\"❓ Query: {user_input}\")\n", + " print(\"πŸ”„ Agent: ReAct\")\n", + " print(\"=\" * 50)\n", + "\n", + " events = react_agent_with_memory.stream(\n", + " {\"messages\": [(\"user\", user_input)]}, config, stream_mode=\"values\"\n", + " )\n", + "\n", + " for event in events:\n", + " event[\"messages\"][-1].pretty_print()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "q_UA4bT5u645" + }, + "source": [ + "### `execute_graph_with_memory(thread_id: str, user_input: str)`\n", + "\n", + "Executes the custom LangGraph agent with the same memory and streaming capabilities.\n", + "\n", + "**Parameters:**\n", + "- `thread_id`: Unique identifier for the conversation thread\n", + "- `user_input`: Natural language query to process\n", + "\n", + "**Key Differences from ReAct:**\n", + "- Uses the deterministic state machine workflow\n", + "- Input format is `{\"messages\": [{\"role\": \"user\", \"content\": user_input}]}`\n", + "- Each workflow step is visible as it executes\n", + "\n", + "**Usage:**\n", + "Both functions provide identical interfaces but use different agent implementations. The LangGraph version provides visibility into the step-by-step workflow, while ReAct offers more autonomous reasoning.\n", + "\n", + "**Memory Persistence:**\n", + "Both functions automatically save conversation state to MongoDB, enabling follow-up queries in the same thread to reference previous interactions." + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "id": "QsVTbp-TgR4D" + }, + "outputs": [], + "source": [ + "def execute_graph_with_memory(thread_id: str, user_input: str):\n", + " \"\"\"Execute LangGraph agent with persistent memory\"\"\"\n", + " config = {\"configurable\": {\"thread_id\": thread_id}}\n", + "\n", + " print(f\"🧡 Thread: {thread_id}\")\n", + " print(f\"❓ Query: {user_input}\")\n", + " print(\"πŸ“Š Agent: Custom LangGraph\")\n", + " print(\"=\" * 50)\n", + "\n", + " for step in mongo_agent_with_memory.stream(\n", + " {\"messages\": [{\"role\": \"user\", \"content\": user_input}]},\n", + " config,\n", + " stream_mode=\"values\",\n", + " ):\n", + " step[\"messages\"][-1].pretty_print()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "HTP6RXt8vkob" + }, + "source": [ + "# Memory Management Functions\n", + "\n", + "**Typical debugging sequence:**\n", + "1. `memory_system_stats()` - Check overall system health\n", + "2. `list_conversation_threads()` - View all available threads \n", + "3. `inspect_thread_history(\"thread_id\")` - Debug specific conversations\n", + "4. `clear_thread_history(\"thread_id\")` - Clean up old or problematic threads\n", + "\n", + "These functions provide complete visibility and control over the agent's memory system." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "uqD1fuoEvNMi" + }, + "source": [ + "### `list_conversation_threads()`\n", + "\n", + "Lists all available conversation threads stored in the MongoDB checkpoint database.\n", + "\n", + "**Output:**\n", + "- All unique thread IDs that have been created\n", + "- Total number of checkpoints across all threads\n", + "- Number of checkpoints per individual thread\n", + "\n", + "**Example output:**\n", + "```\n", + "Available Conversation Threads:\n", + "Total checkpoints: 147\n", + "==================================================\n", + " 1. Thread: session_123\n", + " └─ 12 checkpoints\n", + " 2. Thread: demo_basic_1\n", + " └─ 8 checkpoints\n", + " 3. Thread: interactive_abc\n", + " └─ 25 checkpoints\n", + "```\n", + "**Usage:** `list_conversation_threads()`" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "id": "4Pralr9ngaWm" + }, + "outputs": [], + "source": [ + "def list_conversation_threads():\n", + " \"\"\"List all available conversation threads\"\"\"\n", + " try:\n", + " # Check the main checkpoint database used by our agents\n", + " db_checkpoints = client[\"checkpointing_db\"]\n", + " collection = db_checkpoints.checkpoints\n", + "\n", + " threads = collection.distinct(\"thread_id\")\n", + " total_checkpoints = collection.count_documents({})\n", + "\n", + " print(\"πŸ“‹ Available Conversation Threads:\")\n", + " print(f\"πŸ“Š Total checkpoints: {total_checkpoints}\")\n", + " print(\"=\" * 50)\n", + "\n", + " for i, thread_id in enumerate(threads, 1):\n", + " count = collection.count_documents({\"thread_id\": thread_id})\n", + " print(f\" {i}. Thread: {thread_id}\")\n", + " print(f\" └─ {count} checkpoints\")\n", + "\n", + " return threads\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Error listing threads: {e}\")\n", + " return []" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ATGumtjTvY83" + }, + "source": [ + "### `inspect_thread_history(thread_id: str, limit: int = 10)`\n", + "\n", + "Inspects the conversation history for a specific thread, showing step-by-step execution details.\n", + "\n", + "**Features:**\n", + "- **Smart fallback**: Uses enhanced inspection with LLM summaries if available, otherwise falls back to basic checkpoint analysis\n", + "- **Configurable limit**: Control how many recent steps to display\n", + "- **Detailed breakdown**: Shows messages, tool calls, and content for each step\n", + "\n", + "**Parameters:**\n", + "- `thread_id`: The conversation thread to inspect\n", + "- `limit`: Maximum number of recent checkpoints to show (default: 10)\n", + "\n", + "**Usage:** `inspect_thread_history(\"session_123\", limit=5)`" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "id": "XQrZTSoxgcoJ" + }, + "outputs": [], + "source": [ + "def inspect_thread_history(thread_id: str, limit: int = 10):\n", + " \"\"\"Inspect conversation history for a specific thread\"\"\"\n", + " try:\n", + " # Use the enhanced inspection function if available\n", + " return inspect_thread_with_summaries_enhanced(thread_id, limit)\n", + " except NameError:\n", + " # Fallback to basic inspection\n", + " try:\n", + " db_checkpoints = client[\"checkpointing_db\"]\n", + " collection = db_checkpoints.checkpoints\n", + "\n", + " checkpoints = list(\n", + " collection.find({\"thread_id\": thread_id})\n", + " .sort(\"checkpoint_ns\", -1)\n", + " .limit(limit)\n", + " )\n", + "\n", + " if not checkpoints:\n", + " print(f\"❌ No checkpoints found for thread: {thread_id}\")\n", + " return []\n", + "\n", + " print(f\"πŸ” Thread History: {thread_id}\")\n", + " print(f\"πŸ“Š Showing {len(checkpoints)} most recent checkpoints\")\n", + " print(\"=\" * 60)\n", + "\n", + " for i, checkpoint in enumerate(reversed(checkpoints), 1):\n", + " print(f\"\\nπŸ“ Step {i}:\")\n", + "\n", + " channel_values = checkpoint.get(\"channel_values\", {})\n", + " if \"messages\" in channel_values:\n", + " messages = channel_values[\"messages\"]\n", + " print(f\" Messages: {len(messages)} total\")\n", + "\n", + " if messages:\n", + " last_msg = messages[-1]\n", + " if isinstance(last_msg, dict):\n", + " content = last_msg.get(\"content\", \"\")\n", + " tool_calls = last_msg.get(\"tool_calls\", [])\n", + "\n", + " if tool_calls:\n", + " tool_name = tool_calls[0].get(\"name\", \"unknown\")\n", + " print(f\" πŸ”§ Tool Call: {tool_name}\")\n", + " elif content:\n", + " preview = (\n", + " content[:100] + \"...\"\n", + " if len(content) > 100\n", + " else content\n", + " )\n", + " print(f\" πŸ’¬ Content: {preview}\")\n", + "\n", + " return checkpoints\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Error inspecting thread: {e}\")\n", + " return []" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "4VOZCsXAvcO9" + }, + "source": [ + "### `clear_thread_history(thread_id: str)`\n", + "\n", + "Completely removes all conversation history for a specific thread from MongoDB.\n", + "\n", + "**What it clears:**\n", + "- Main checkpoints collection (conversation state)\n", + "- Checkpoint writes collection (operation logs)\n", + "\n", + "**Warning:** This action is irreversible. The agent will lose all memory of previous interactions in this thread.\n", + "\n", + "**Usage:** `clear_thread_history(\"old_session_456\")`" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "id": "Z2uBcYJvggbJ" + }, + "outputs": [], + "source": [ + "def clear_thread_history(thread_id: str):\n", + " \"\"\"Clear conversation history for a specific thread\"\"\"\n", + " try:\n", + " db_checkpoints = client[\"checkpointing_db\"]\n", + "\n", + " # Clear main checkpoints\n", + " collection = db_checkpoints.checkpoints\n", + " result = collection.delete_many({\"thread_id\": thread_id})\n", + " print(f\"πŸ—‘οΈ Cleared {result.deleted_count} checkpoints from thread: {thread_id}\")\n", + "\n", + " # Clear checkpoint writes\n", + " writes_collection = db_checkpoints.checkpoint_writes\n", + " writes_result = writes_collection.delete_many({\"thread_id\": thread_id})\n", + " print(f\"πŸ—‘οΈ Cleared {writes_result.deleted_count} checkpoint writes\")\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Error clearing thread: {e}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "UTsHv6qmveow" + }, + "source": [ + "### `memory_system_stats()`\n", + "\n", + "Provides a comprehensive overview of the entire memory system's usage and health.\n", + "\n", + "**Metrics displayed:**\n", + "- Total checkpoints across all threads\n", + "- Total checkpoint writes (operation logs)\n", + "- Number of unique conversation threads\n", + "- Database name being used\n", + "\n", + "**Example output:**\n", + "```\n", + "Memory System Statistics\n", + "========================================\n", + "Total checkpoints: 147\n", + "Total checkpoint writes: 298\n", + "Total conversation threads: 8\n", + "Database: checkpointing_db\n", + "```\n", + "\n", + "**Returns:** Dictionary with stats for programmatic use\n", + "\n", + "**Usage:** `stats = memory_system_stats()`" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "id": "vBi7q23sb1Au" + }, + "outputs": [], + "source": [ + "def memory_system_stats():\n", + " \"\"\"Show comprehensive memory statistics\"\"\"\n", + " try:\n", + " db_checkpoints = client[\"checkpointing_db\"]\n", + " checkpoints = db_checkpoints.checkpoints\n", + " checkpoint_writes = db_checkpoints.checkpoint_writes\n", + "\n", + " total_checkpoints = checkpoints.count_documents({})\n", + " total_writes = checkpoint_writes.count_documents({})\n", + " total_threads = len(checkpoints.distinct(\"thread_id\"))\n", + "\n", + " print(\"πŸ“Š Memory System Statistics\")\n", + " print(\"=\" * 40)\n", + " print(f\"πŸ’Ύ Total checkpoints: {total_checkpoints}\")\n", + " print(f\"✍️ Total checkpoint writes: {total_writes}\")\n", + " print(f\"🧡 Total conversation threads: {total_threads}\")\n", + " print(\"πŸ›οΈ Database: checkpointing_db\")\n", + "\n", + " return {\n", + " \"checkpoints\": total_checkpoints,\n", + " \"writes\": total_writes,\n", + " \"threads\": total_threads,\n", + " }\n", + "\n", + " except Exception as e:\n", + " print(f\"❌ Error getting stats: {e}\")\n", + " return {}" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Ufg4IQgogj9L" + }, + "source": [ + "# Demonstration Functions\n", + "\n", + "This section provides ready-to-run examples that showcase different aspects of the Text-to-MQL system.\n", + "\n", + "### Running Demos\n", + "\n", + "Each function is self-contained and generates unique thread IDs to avoid conflicts. They provide formatted output showing:\n", + "- Query execution in real-time\n", + "- Step-by-step agent reasoning\n", + "- Final results and analysis\n", + "- Memory inspection summaries\n", + "\n", + "**Quick start:** Run `test_enhanced_summarization()` to see the complete system in action with intelligent step tracking." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "iwz2WMfEv6Gq" + }, + "source": [ + "### `demo_basic_queries()`\n", + "\n", + "Demonstrates core text-to-MQL functionality with 5 standalone queries of increasing complexity.\n", + "\n", + "**Query types:**\n", + "- Top movies by IMDb rating\n", + "- Most active commenters \n", + "- Theater distribution by state\n", + "- Westernmost theaters (geospatial)\n", + "- Complex director analysis with multiple criteria\n", + "\n", + "**Purpose:** Shows the range of query types the system can handle, from simple sorting to complex aggregations.\n", + "\n", + "**Usage:** `demo_basic_queries()`" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "id": "-3GNAP79jRvh" + }, + "outputs": [], + "source": [ + "def demo_basic_queries():\n", + " \"\"\"Demonstrate basic text-to-MQL functionality\"\"\"\n", + " print(\"🎬 DEMO: Basic Text-to-MQL Queries\")\n", + " print(\"=\" * 50)\n", + "\n", + " queries = [\n", + " \"List the top 5 movies with highest IMDb ratings\",\n", + " \"Who are the top 10 most active commenters?\",\n", + " \"Which states have the most theaters?\",\n", + " \"Which theaters are furthest west?\",\n", + " \"Find directors with β‰₯20 films, highest avg IMDb rating (top-5)\",\n", + " ]\n", + "\n", + " for i, query in enumerate(queries, 1):\n", + " thread_id = f\"demo_basic_{i}\"\n", + " print(f\"\\n--- Demo Query {i} ---\")\n", + " print(f\"Query: {query}\")\n", + " print()\n", + "\n", + " execute_graph_with_memory(thread_id, query)\n", + "\n", + " if i < len(queries):\n", + " print(\"\\n\" + \"=\" * 50)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "t2CZW-vav_ri" + }, + "source": [ + "### `demo_conversation_memory()`\n", + "\n", + "Demonstrates multi-turn conversation where each query builds on previous results.\n", + "\n", + "**Conversation flow:**\n", + "1. \"List the top 3 directors by movie count\"\n", + "2. \"What was the movie count for the first director?\" *(references previous result)*\n", + "3. \"Show me movies by that director with highest ratings\" *(continues context)*\n", + "\n", + "**Key feature:** Shows how the agent remembers previous results and can answer follow-up questions without re-querying.\n", + "\n", + "**Usage:** `demo_conversation_memory()`" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "id": "OqxQkpPZjPo0" + }, + "outputs": [], + "source": [ + "def demo_conversation_memory():\n", + " \"\"\"Demonstrate conversation memory across multiple related queries\"\"\"\n", + " thread_id = f\"conversation_demo_{uuid.uuid4().hex[:8]}\"\n", + "\n", + " print(\"🎬 DEMO: Conversation Memory with Text-to-MQL\")\n", + " print(\"=\" * 50)\n", + "\n", + " conversation = [\n", + " \"List the top 3 directors by movie count\",\n", + " \"What was the movie count for the first director?\",\n", + " \"Show me movies by that director with highest ratings\",\n", + " ]\n", + "\n", + " for i, query in enumerate(conversation, 1):\n", + " print(f\"\\n--- Conversation Step {i} ---\")\n", + " execute_graph_with_memory(thread_id, query)\n", + "\n", + " if i < len(conversation):\n", + " print(\"\\nπŸ”„ Building context for next query...\")\n", + " print(\"=\" * 40)\n", + "\n", + " print(\"\\nπŸ” Complete Conversation Analysis:\")\n", + " print(\"=\" * 40)\n", + " inspect_thread_history(thread_id)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "HKq8Pn3kwI5s" + }, + "source": [ + "### `compare_agents_with_memory()`\n", + "\n", + "Side-by-side comparison of ReAct vs LangGraph agents using the same complex query.\n", + "\n", + "**Comparison points:**\n", + "- **Execution style**: ReAct's autonomous reasoning vs LangGraph's structured workflow\n", + "- **Memory patterns**: How each agent stores conversation state\n", + "- **Output format**: Differences in result presentation\n", + "\n", + "**Usage:** `compare_agents_with_memory()`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "OrO-RGiHjJBd" + }, + "outputs": [], + "source": [ + "\"\"\"## Enhanced Agent Comparison Functions\n", + "\n", + "### `compare_agents_with_memory(query: str, max_retries: int = 3, recursion_limit: int = 50)`\n", + "\n", + "Comprehensive comparison of ReAct vs LangGraph agents with configurable parameters and robust error handling.\n", + "\n", + "**Parameters:**\n", + "- `query`: Natural language query to test with both agents\n", + "- `max_retries`: Maximum retry attempts if an agent fails (default: 3)\n", + "- `recursion_limit`: Maximum recursion depth to prevent infinite loops (default: 50)\n", + "\n", + "**Comparison Analysis:**\n", + "- **Execution Style**: ReAct's autonomous reasoning vs LangGraph's structured workflow\n", + "- **Memory Patterns**: How each agent stores conversation state\n", + "- **Performance Metrics**: Success rates, execution time, and retry attempts\n", + "- **Error Handling**: How each agent responds to failures and complex queries\n", + "\n", + "**Features:**\n", + "- Retry logic with fresh threads for each attempt\n", + "- Configurable recursion limits to prevent infinite loops\n", + "- Detailed execution step tracking and analysis\n", + "- Performance timing and success rate comparison\n", + "- Memory pattern inspection for successful executions\n", + "- Intelligent recommendations based on results\n", + "\n", + "**Usage Examples:**\n", + "```python\n", + "# Basic comparison with default settings\n", + "compare_agents_with_memory(\"Count all movies in the database\")\n", + "\n", + "# Complex query with custom retry settings\n", + "compare_agents_with_memory(\n", + " \"Find the top 5 directors with most award wins and at least 5 movies\",\n", + " max_retries=3,\n", + " recursion_limit=50\n", + ")\n", + "\n", + "# Moderate complexity with conservative settings\n", + "compare_agents_with_memory(\"List top directors by movie count\", max_retries=2, recursion_limit=40)\n", + "```\n", + "\n", + "**Return Value:** Dictionary containing detailed results for both agents including success status, execution metrics, and configuration used.\n", + "\"\"\"\n", + "\n", + "\n", + "def compare_agents_with_memory(\n", + " query: str, max_retries: int = 3, recursion_limit: int = 50\n", + "):\n", + " \"\"\"\n", + " Side-by-side comparison of ReAct vs LangGraph agents using a specified query.\n", + "\n", + " Parameters:\n", + " -----------\n", + " query : str\n", + " The natural language query to test with both agents\n", + " max_retries : int, default=3\n", + " Maximum number of retry attempts if an agent fails\n", + " recursion_limit : int, default=50\n", + " Maximum recursion depth for the ReAct agent to prevent infinite loops\n", + "\n", + " Comparison points:\n", + " -----------------\n", + " - Execution style: ReAct's autonomous reasoning vs LangGraph's structured workflow\n", + " - Memory patterns: How each agent stores conversation state\n", + " - Output format: Differences in result presentation\n", + " - Error handling: How each agent responds to failures\n", + " \"\"\"\n", + " base_thread = f\"compare_{uuid.uuid4().hex[:8]}\"\n", + "\n", + " print(\"Agent Comparison: ReAct vs LangGraph\")\n", + " print(\"=\" * 60)\n", + " print(f\"Query: {query}\")\n", + " print(f\"Max Retries: {max_retries}\")\n", + " print(f\"Recursion Limit: {recursion_limit}\")\n", + " print(\"=\" * 60)\n", + "\n", + " # Results tracking\n", + " react_results = {\n", + " \"success\": False,\n", + " \"attempts\": 0,\n", + " \"error\": None,\n", + " \"execution_time\": None,\n", + " }\n", + " graph_results = {\n", + " \"success\": False,\n", + " \"attempts\": 0,\n", + " \"error\": None,\n", + " \"execution_time\": None,\n", + " }\n", + "\n", + " # Test ReAct Agent\n", + " print(\"\\nReAct Agent Execution:\")\n", + " print(\"-\" * 40)\n", + "\n", + " start_time = time.time()\n", + "\n", + " for attempt in range(max_retries):\n", + " react_results[\"attempts\"] = attempt + 1\n", + " thread_id = f\"{base_thread}_react_attempt_{attempt + 1}\"\n", + "\n", + " print(f\"\\nAttempt {attempt + 1}/{max_retries}\")\n", + " print(f\"Thread: {thread_id}\")\n", + "\n", + " try:\n", + " config = {\n", + " \"configurable\": {\"thread_id\": thread_id},\n", + " \"recursion_limit\": recursion_limit,\n", + " }\n", + "\n", + " step_count = 0\n", + " events = react_agent_with_memory.stream(\n", + " {\"messages\": [(\"user\", query)]}, config, stream_mode=\"values\"\n", + " )\n", + "\n", + " print(\"Execution steps:\")\n", + " for event in events:\n", + " step_count += 1\n", + " print(f\" Step {step_count}:\", end=\" \")\n", + "\n", + " # Get the last message type for summary\n", + " last_msg = event[\"messages\"][-1]\n", + " if hasattr(last_msg, \"tool_calls\") and last_msg.tool_calls:\n", + " tool_name = last_msg.tool_calls[0][\"name\"]\n", + " print(f\"Tool call: {tool_name}\")\n", + " elif hasattr(last_msg, \"content\") and last_msg.content:\n", + " content_preview = last_msg.content[:50] + (\n", + " \"...\" if len(last_msg.content) > 50 else \"\"\n", + " )\n", + " print(f\"Response: {content_preview}\")\n", + " else:\n", + " print(\"Processing...\")\n", + "\n", + " # Show full output for final step\n", + " if not hasattr(last_msg, \"tool_calls\") or not last_msg.tool_calls:\n", + " print(\"\\nFinal ReAct Response:\")\n", + " last_msg.pretty_print()\n", + "\n", + " # Emergency brake for infinite loops\n", + " if step_count > recursion_limit - 5:\n", + " print(f\"\\nApproaching recursion limit at step {step_count}\")\n", + " break\n", + "\n", + " react_results[\"success\"] = True\n", + " react_results[\"execution_time\"] = time.time() - start_time\n", + " print(f\"\\nReAct agent succeeded in {step_count} steps\")\n", + " break\n", + "\n", + " except Exception as e:\n", + " react_results[\"error\"] = str(e)\n", + " print(f\"\\nReAct attempt {attempt + 1} failed: {e}\")\n", + "\n", + " if attempt < max_retries - 1:\n", + " print(\"Retrying with fresh thread...\")\n", + " else:\n", + " print(\"Max retries reached for ReAct agent\")\n", + " react_results[\"execution_time\"] = time.time() - start_time\n", + "\n", + " # Test LangGraph Agent\n", + " print(\"\\nLangGraph Agent Execution:\")\n", + " print(\"-\" * 40)\n", + "\n", + " start_time = time.time()\n", + "\n", + " for attempt in range(max_retries):\n", + " graph_results[\"attempts\"] = attempt + 1\n", + " thread_id = f\"{base_thread}_graph_attempt_{attempt + 1}\"\n", + "\n", + " print(f\"\\nAttempt {attempt + 1}/{max_retries}\")\n", + " print(f\"Thread: {thread_id}\")\n", + "\n", + " try:\n", + " config = {\"configurable\": {\"thread_id\": thread_id}}\n", + "\n", + " step_count = 0\n", + " print(\"Execution steps:\")\n", + " for step in mongo_agent_with_memory.stream(\n", + " {\"messages\": [{\"role\": \"user\", \"content\": query}]},\n", + " config,\n", + " stream_mode=\"values\",\n", + " ):\n", + " step_count += 1\n", + " last_msg = step[\"messages\"][-1]\n", + "\n", + " # Show step summary\n", + " if hasattr(last_msg, \"tool_calls\") and last_msg.tool_calls:\n", + " tool_name = last_msg.tool_calls[0][\"name\"]\n", + " print(f\" Step {step_count}: Tool call: {tool_name}\")\n", + " elif hasattr(last_msg, \"content\") and last_msg.content:\n", + " content_preview = last_msg.content[:50] + (\n", + " \"...\" if len(last_msg.content) > 50 else \"\"\n", + " )\n", + " print(f\" Step {step_count}: Response: {content_preview}\")\n", + "\n", + " # Show full output for final step\n", + " if not hasattr(last_msg, \"tool_calls\") or not last_msg.tool_calls:\n", + " print(\"\\nFinal LangGraph Response:\")\n", + " last_msg.pretty_print()\n", + "\n", + " graph_results[\"success\"] = True\n", + " graph_results[\"execution_time\"] = time.time() - start_time\n", + " print(f\"\\nLangGraph agent succeeded in {step_count} steps\")\n", + " break\n", + "\n", + " except Exception as e:\n", + " graph_results[\"error\"] = str(e)\n", + " print(f\"\\nLangGraph attempt {attempt + 1} failed: {e}\")\n", + "\n", + " if attempt < max_retries - 1:\n", + " print(\"Retrying with fresh thread...\")\n", + " else:\n", + " print(\"Max retries reached for LangGraph agent\")\n", + " graph_results[\"execution_time\"] = time.time() - start_time\n", + "\n", + " # Comparison Summary\n", + " print(\"\\nComparison Summary:\")\n", + " print(\"=\" * 60)\n", + "\n", + " print(\"\\nReAct Agent Results:\")\n", + " print(f\" Success: {'βœ…' if react_results['success'] else '❌'}\")\n", + " print(f\" Attempts: {react_results['attempts']}/{max_retries}\")\n", + " print(\n", + " f\" Execution Time: {react_results['execution_time']:.2f}s\"\n", + " if react_results[\"execution_time\"]\n", + " else \" Execution Time: N/A\"\n", + " )\n", + " if react_results[\"error\"]:\n", + " print(f\" Final Error: {react_results['error']}\")\n", + "\n", + " print(\"\\nLangGraph Agent Results:\")\n", + " print(f\" Success: {'βœ…' if graph_results['success'] else '❌'}\")\n", + " print(f\" Attempts: {graph_results['attempts']}/{max_retries}\")\n", + " print(\n", + " f\" Execution Time: {graph_results['execution_time']:.2f}s\"\n", + " if graph_results[\"execution_time\"]\n", + " else \" Execution Time: N/A\"\n", + " )\n", + " if graph_results[\"error\"]:\n", + " print(f\" Final Error: {graph_results['error']}\")\n", + "\n", + " # Execution Style Analysis\n", + " print(\"\\nExecution Style Analysis:\")\n", + " print(\" ReAct Agent:\")\n", + " print(\" - Autonomous reasoning and tool selection\")\n", + " print(\" - Dynamic decision making based on previous results\")\n", + " print(\" - Can get stuck in reasoning loops with complex queries\")\n", + " print(\" - More flexible but less predictable workflow\")\n", + "\n", + " print(\" LangGraph Agent:\")\n", + " print(\" - Structured, deterministic workflow\")\n", + " print(\" - Predefined step sequence with conditional branches\")\n", + " print(\" - Better error isolation and recovery\")\n", + " print(\" - More predictable but less flexible execution\")\n", + "\n", + " # Memory Pattern Analysis\n", + " if react_results[\"success\"] or graph_results[\"success\"]:\n", + " print(\"\\nMemory Pattern Analysis:\")\n", + "\n", + " if react_results[\"success\"]:\n", + " print(\" ReAct Agent Memory:\")\n", + " react_thread = f\"{base_thread}_react_attempt_{react_results['attempts']}\"\n", + " try:\n", + " inspect_thread_history(react_thread, limit=3)\n", + " except Exception as e:\n", + " print(\"Unable to inspect ReAct memory\")\n", + "\n", + " if graph_results[\"success\"]:\n", + " print(\" LangGraph Agent Memory:\")\n", + " graph_thread = f\"{base_thread}_graph_attempt_{graph_results['attempts']}\"\n", + " try:\n", + " inspect_thread_history(graph_thread, limit=3)\n", + " except Exception as e:\n", + " print(\"Unable to inspect LangGraph memory\")\n", + "\n", + " # Recommendations\n", + " print(\"\\nRecommendations:\")\n", + " if react_results[\"success\"] and graph_results[\"success\"]:\n", + " if react_results[\"execution_time\"] < graph_results[\"execution_time\"]:\n", + " print(\" - ReAct agent was faster for this query\")\n", + " else:\n", + " print(\" - LangGraph agent was more efficient for this query\")\n", + " print(\" - Both agents handled the query successfully\")\n", + " elif graph_results[\"success\"] and not react_results[\"success\"]:\n", + " print(\" - Use LangGraph agent for this type of query\")\n", + " print(\" - ReAct agent struggled with the complexity/validation\")\n", + " elif react_results[\"success\"] and not graph_results[\"success\"]:\n", + " print(\" - ReAct agent was more robust for this query\")\n", + " print(\" - Consider debugging LangGraph workflow\")\n", + " else:\n", + " print(\" - Query may be too complex or have data structure issues\")\n", + " print(\" - Consider simplifying the query or debugging the dataset\")\n", + "\n", + " return {\n", + " \"react\": react_results,\n", + " \"langgraph\": graph_results,\n", + " \"query\": query,\n", + " \"config\": {\"max_retries\": max_retries, \"recursion_limit\": recursion_limit},\n", + " }" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "H7Vu_YL8wMkJ" + }, + "source": [ + "### `test_memory_functionality()`\n", + "\n", + "Simple two-step test focused specifically on memory capabilities.\n", + "\n", + "**Test sequence:**\n", + "1. Initial query about directors\n", + "2. Follow-up question that requires remembering the first result\n", + "\n", + "**Purpose:** Quick validation that conversation memory is working correctly.\n", + "\n", + "**Usage:** `test_memory_functionality()`" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "id": "JxyuMtBhjH01" + }, + "outputs": [], + "source": [ + "def test_memory_functionality():\n", + " \"\"\"Test memory functionality with a simple example\"\"\"\n", + " thread_id = f\"memory_test_{uuid.uuid4().hex[:8]}\"\n", + "\n", + " print(\"πŸ§ͺ TESTING: Memory Functionality\")\n", + " print(\"=\" * 50)\n", + "\n", + " print(\"Step 1: Ask about directors\")\n", + " execute_graph_with_memory(thread_id, \"List top 3 directors by movie count\")\n", + "\n", + " print(\"\\nStep 2: Follow up question (tests memory)\")\n", + " execute_graph_with_memory(\n", + " thread_id, \"What was the movie count for the first director?\"\n", + " )\n", + "\n", + " print(\"\\nπŸ” Memory Analysis:\")\n", + " inspect_thread_history(thread_id)\n", + "\n", + " return thread_id" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "VS3-ww0wwEIM" + }, + "source": [ + "### `test_enhanced_summarization()`\n", + "\n", + "Tests the LLM-powered summarization system with various query patterns.\n", + "\n", + "**Functionality:**\n", + "- Runs 3 different query types (count, average, top results)\n", + "- Executes each with full step tracking\n", + "- Displays enhanced thread analysis with LLM-generated summaries\n", + "\n", + "**Purpose:** Validates that the summarization system correctly categorizes and describes different types of operations.\n", + "\n", + "**Usage:** `test_enhanced_summarization()`" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "id": "nDh5WQHXjLf6" + }, + "outputs": [], + "source": [ + "def test_enhanced_summarization():\n", + " \"\"\"Test the enhanced summarization system with various query patterns\"\"\"\n", + " print(\"\\nπŸ§ͺ TESTING ENHANCED SUMMARIZATION SYSTEM\")\n", + " print(\"=\" * 60)\n", + "\n", + " thread_id = f\"enhanced_test_{uuid.uuid4().hex[:8]}\"\n", + "\n", + " # Test various query patterns\n", + " test_queries = [\n", + " \"How many movies are in the database?\",\n", + " \"Find the average rating of all movies\",\n", + " \"Show me the top 5 directors by movie count\",\n", + " ]\n", + "\n", + " print(f\"Testing thread: {thread_id}\")\n", + " print(\"Running query patterns with enhanced summarization...\")\n", + " print(\"=\" * 50)\n", + "\n", + " for i, query in enumerate(test_queries, 1):\n", + " print(f\"\\nπŸ“Œ Test {i}: {query}\")\n", + " execute_graph_with_memory(thread_id, query)\n", + " print(f\"βœ… Test {i} complete\")\n", + "\n", + " # Inspect the results with enhanced summaries\n", + " print(\"\\nπŸ” Enhanced Thread Analysis:\")\n", + " print(\"=\" * 50)\n", + " inspect_thread_history(thread_id)\n", + "\n", + " return thread_id" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Wj9L7D6V98Ls" + }, + "source": [ + "## Supporting Test Functions\n", + "\n", + "These functions provide pre-configured test scenarios for validating agent comparison functionality across different query complexity levels.\n", + "\n", + "* `test_simple_comparison()` uses basic counting queries with conservative retry settings,\n", + "* `test_moderate_comparison()` tests standard aggregation patterns,\n", + "* `test_complex_comparison()` validates the original problematic query using enhanced error handling\n", + "* `run_comparison_tests()` function executes all three scenarios in sequence, providing comprehensive assessment of both ReAct and LangGraph agent capabilities with automatic error isolation and performance benchmarking.\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "KzRIPASb7qPU", + "outputId": "f031c1f5-eb8a-4028-d0e8-565a171ee4d7" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "βœ… Enhanced agent comparison functions loaded!\n", + "\n", + "Usage examples:\n", + "compare_agents_with_memory(\"Count all movies\", max_retries=2)\n", + "compare_agents_with_memory(\"Find top directors\", max_retries=3, recursion_limit=40)\n", + "run_comparison_tests() # Run multiple test scenarios\n" + ] + } + ], + "source": [ + "def test_simple_comparison():\n", + " \"\"\"Test with a simple query that should work\"\"\"\n", + " simple_query = \"Count the total number of movies in the database\"\n", + " return compare_agents_with_memory(simple_query, max_retries=2, recursion_limit=30)\n", + "\n", + "\n", + "def test_moderate_comparison():\n", + " \"\"\"Test with a moderately complex query\"\"\"\n", + " moderate_query = \"List the top 5 directors who have directed the most movies\"\n", + " return compare_agents_with_memory(moderate_query, max_retries=2, recursion_limit=40)\n", + "\n", + "\n", + "def test_complex_comparison():\n", + " \"\"\"Test with the original complex query that caused issues\"\"\"\n", + " complex_query = (\n", + " \"Find the top 5 directors with most award wins and at least 5 movies\"\n", + " )\n", + " return compare_agents_with_memory(complex_query, max_retries=3, recursion_limit=50)\n", + "\n", + "\n", + "def run_comparison_tests():\n", + " \"\"\"Run a series of comparison tests with different query complexities\"\"\"\n", + " print(\"Running Comparison Test Suite\")\n", + " print(\"=\" * 60)\n", + "\n", + " tests = [\n", + " (\"Simple Query\", test_simple_comparison),\n", + " (\"Moderate Query\", test_moderate_comparison),\n", + " (\"Complex Query\", test_complex_comparison),\n", + " ]\n", + "\n", + " results = {}\n", + " for test_name, test_func in tests:\n", + " print(f\"\\n{'='*20} {test_name} {'='*20}\")\n", + " try:\n", + " results[test_name] = test_func()\n", + " except Exception as e:\n", + " print(f\"❌ {test_name} failed with error: {e}\")\n", + " results[test_name] = None\n", + "\n", + " return results\n", + "\n", + "\n", + "print(\"βœ… Enhanced agent comparison functions loaded!\")\n", + "print(\"\\nUsage examples:\")\n", + "print('compare_agents_with_memory(\"Count all movies\", max_retries=2)')\n", + "print(\n", + " 'compare_agents_with_memory(\"Find top directors\", max_retries=3, recursion_limit=40)'\n", + ")\n", + "print(\"run_comparison_tests() # Run multiple test scenarios\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Nn97sFVrgze2" + }, + "source": [ + "# Interactive Query Interface\n", + "\n", + "### `interactive_query()`\n", + "\n", + "Provides a command-line interface for real-time interaction with the Text-to-MQL agent. Creates a conversational session where you can ask multiple related questions and manage conversation threads.\n", + "\n", + "**Features:**\n", + "- **Persistent conversation**: Maintains context across multiple queries in the same thread\n", + "- **Thread management**: Switch between different conversation contexts\n", + "- **Built-in debugging**: Inspect conversation history without leaving the interface\n", + "- **Error handling**: Graceful handling of interruptions and errors\n", + "\n", + "### Available Commands\n", + "\n", + "| Command | Description | Example |\n", + "|---------|-------------|---------|\n", + "| `` | Execute MongoDB query | `\"Count movies from 2020\"` |\n", + "| `exit` | Quit the interface | `exit` |\n", + "| `threads` | List all conversation threads | `threads` |\n", + "| `switch ` | Change to different thread | `switch session_123` |\n", + "| `debug` | Inspect current thread history | `debug` |\n", + "\n", + "### Interactive Session Example\n", + "\n", + "```\n", + "Interactive Text-to-MQL Query Interface\n", + "Commands: 'exit' to quit, 'threads' to list, 'switch ' to change thread\n", + "======================================================================\n", + "\n", + "[interactive_abc123] Enter your query: Count all movies in the database\n", + "\n", + "Thread: interactive_abc123\n", + "Query: Count all movies in the database\n", + "Agent: Custom LangGraph\n", + "==================================================\n", + "[Agent execution with step-by-step output...]\n", + "\n", + "[interactive_abc123] Enter your query: What about just movies from 2020?\n", + "\n", + "[Continues conversation with memory of previous query...]\n", + "\n", + "[interactive_abc123] Enter your query: debug\n", + "\n", + "Thread History: interactive_abc123\n", + "Total steps: 8\n", + "================================================================================\n", + "[Shows conversation history...]\n", + "\n", + "[interactive_abc123] Enter your query: exit\n", + "Goodbye!\n", + "```\n", + "\n", + "### Session Management\n", + "\n", + "**Automatic thread creation:** Each session starts with a unique thread ID (`interactive_`)\n", + "\n", + "**Thread switching:** Use `switch ` to continue previous conversations:\n", + "```\n", + "[interactive_abc123] Enter your query: switch session_older\n", + "Switched to thread: session_older\n", + "[session_older] Enter your query: What did we discuss last time?\n", + "```\n", + "\n", + "**Memory persistence:** All queries and results are saved to MongoDB, allowing you to return to any conversation later.\n", + "\n", + "### Usage\n", + "\n", + "**Start interactive session:** `interactive_query()`\n", + "\n", + "**Best practices:**\n", + "- Use meaningful thread names when switching (`switch movie_analysis_2024`)\n", + "- Use `debug` command to review conversation context\n", + "- Use `threads` to see all available conversation histories\n", + "\n", + "This interface is ideal for exploratory data analysis sessions where you want to ask follow-up questions and build on previous results." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "id": "bPIG87rKb8Ga" + }, + "outputs": [], + "source": [ + "def interactive_query():\n", + " \"\"\"Interactive query interface with memory\"\"\"\n", + " print(\"πŸ” Interactive Text-to-MQL Query Interface\")\n", + " print(\n", + " \"Commands: 'exit' to quit, 'threads' to list, 'switch ' to change thread\"\n", + " )\n", + " print(\"=\" * 70)\n", + "\n", + " thread_id = f\"interactive_{uuid.uuid4().hex[:8]}\"\n", + "\n", + " while True:\n", + " try:\n", + " user_input = input(f\"\\n[{thread_id}] Enter your query: \").strip()\n", + "\n", + " if user_input.lower() == \"exit\":\n", + " break\n", + " elif user_input.lower() == \"threads\":\n", + " list_conversation_threads()\n", + " continue\n", + " elif user_input.lower().startswith(\"switch \"):\n", + " thread_id = user_input[7:].strip()\n", + " print(f\"πŸ”„ Switched to thread: {thread_id}\")\n", + " continue\n", + " elif user_input.lower() == \"debug\":\n", + " inspect_thread_history(thread_id)\n", + " continue\n", + " elif not user_input:\n", + " continue\n", + "\n", + " print()\n", + " execute_graph_with_memory(thread_id, user_input)\n", + "\n", + " except KeyboardInterrupt:\n", + " print(\"\\nπŸ‘‹ Goodbye!\")\n", + " break\n", + " except Exception as e:\n", + " print(f\"❌ Error: {e}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ivhSXpAdg4SF" + }, + "source": [ + "# System Initialization and Quick Reference\n", + "\n", + "This section provides the startup summary and quick reference guide for the Text-to-MQL system.\n", + "\n", + "### System Status Display\n", + "\n", + "**Startup sequence:**\n", + "```\n", + "Text-to-MQL Agent with MongoDB Memory - Ready\n", + "============================================================\n", + "Memory System Statistics\n", + "========================================\n", + "Total checkpoints: 0\n", + "Total checkpoint writes: 0 \n", + "Total conversation threads: 0\n", + "Database: checkpointing_db\n", + "```\n", + "\n", + "Automatically displays current memory system health and usage statistics.\n", + "\n", + "### Available Functions Reference\n", + "\n", + "**Demonstration Functions:**\n", + "- `demo_basic_queries()` - Showcase core text-to-MQL capabilities\n", + "- `demo_conversation_memory()` - Multi-turn conversation examples\n", + "- `compare_agents_with_memory()` - ReAct vs LangGraph comparison\n", + "- `test_memory_functionality()` - Simple memory validation\n", + "- `test_enhanced_summarization()` - LLM summarization testing\n", + "- `interactive_query()` - Real-time query interface\n", + "\n", + "**Memory Management Tools:**\n", + "- `list_conversation_threads()` - View all conversation threads\n", + "- `inspect_thread_history(thread_id)` - Debug specific conversations\n", + "- `inspect_thread_with_summaries_enhanced(thread_id)` - Enhanced thread analysis\n", + "- `clear_thread_history(thread_id)` - Delete conversation history\n", + "- `memory_system_stats()` - System health overview\n", + "\n", + "### Quick Start Recommendations\n", + "\n", + "**For first-time users:**\n", + "1. `test_enhanced_summarization()` - See the complete system in action\n", + "2. `demo_conversation_memory()` - Experience multi-turn conversations \n", + "3. `interactive_query()` - Try your own queries\n", + "\n", + "### System Capabilities Summary\n", + "\n", + "**Core features confirmed operational:**\n", + "- **Dual agent architecture**: Both ReAct and LangGraph agents ready\n", + "- **LLM-powered memory**: Intelligent step summarization active\n", + "- **MongoDB persistence**: Conversation state saved automatically\n", + "- **Enhanced debugging**: Human-readable conversation histories\n", + "\n", + "**Key improvements over standard agents:**\n", + "- Query categorization using natural language understanding\n", + "- Conversation-aware step descriptions \n", + "- Better thread inspection with LLM insights\n", + "- Performance-optimized memory debugging\n", + "\n", + "This summary serves as both a system health check and a quick reference guide for exploring the system's capabilities." + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "2Arcpfa5cADh", + "outputId": "4eda90cc-cbfe-4107-f0bf-6639e7c52927" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸš€ Text-to-MQL Agent with MongoDB Memory - Ready!\n", + "============================================================\n", + "πŸ“Š Memory System Statistics\n", + "========================================\n", + "πŸ’Ύ Total checkpoints: 0\n", + "✍️ Total checkpoint writes: 0\n", + "🧡 Total conversation threads: 0\n", + "πŸ›οΈ Database: checkpointing_db\n" + ] + }, + { + "data": { + "text/plain": [ + "{'checkpoints': 0, 'writes': 0, 'threads': 0}" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print(\"\\nπŸš€ Text-to-MQL Agent with MongoDB Memory - Ready!\")\n", + "print(\"=\" * 60)\n", + "\n", + "# Show system status\n", + "memory_system_stats()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bGWoNBpRg-5_" + }, + "source": [ + "## Initial Test Execution\n", + "\n", + "### Automatic Startup Test\n", + "\n", + "```python\n", + "if __name__ == \"__main__\":\n", + " # Start with the enhanced summarization test\n", + " test_enhanced_summarization()\n", + "```\n", + "\n", + "**Purpose:** When the notebook/script is run directly, automatically executes a demonstration to verify the system is working correctly.\n", + "\n", + "**What happens:**\n", + "1. **System initialization**: All agents and memory components are loaded\n", + "2. **Test execution**: Runs `test_enhanced_summarization()` which:\n", + " - Creates a new conversation thread\n", + " - Executes 3 different query patterns\n", + " - Demonstrates LLM-powered step summarization\n", + " - Shows enhanced thread inspection capabilities\n", + "\n", + "**Expected output:**\n", + "```\n", + "Testing Enhanced Summarization System\n", + "============================================================\n", + "Testing thread: enhanced_test_abc12345\n", + "Running query patterns with enhanced summarization...\n", + "==================================================\n", + "\n", + "Test 1: How many movies are in the database?\n", + "[Agent execution with step-by-step summaries...]\n", + "Test 1 complete\n", + "\n", + "Test 2: Find the average rating of all movies\n", + "[Agent execution...]\n", + "Test 2 complete\n", + "\n", + "Test 3: Show me the top 5 directors by movie count\n", + "[Agent execution...]\n", + "Test 3 complete\n", + "\n", + "Enhanced Thread Analysis:\n", + "==================================================\n", + "[Thread history with LLM-generated summaries...]\n", + "```\n", + "\n", + "**Validation checks:**\n", + "- MongoDB connection working\n", + "- OpenAI API accessible\n", + "- Agent workflow functioning\n", + "- Memory persistence active\n", + "- LLM summarization operational\n", + "\n", + "**Note:** In Colab notebooks, this section typically won't auto-execute since notebooks run cell-by-cell. You can manually run `test_enhanced_summarization()` to perform the same validation.\n", + "\n", + "This serves as a **smoke test** to ensure all system components are properly initialized and functioning before manual exploration." + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qOZyX0w1cEWc", + "outputId": "04ef8723-cabd-4d64-d8e4-2382322b093b" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "πŸ§ͺ TESTING ENHANCED SUMMARIZATION SYSTEM\n", + "============================================================\n", + "Testing thread: enhanced_test_f4288e1b\n", + "Running query patterns with enhanced summarization...\n", + "==================================================\n", + "\n", + "πŸ“Œ Test 1: How many movies are in the database?\n", + "🧡 Thread: enhanced_test_f4288e1b\n", + "❓ Query: How many movies are in the database?\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "How many movies are in the database?\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_yyrLUKa9BYrsjZ5sHZNyUHdw)\n", + " Call ID: call_yyrLUKa9BYrsjZ5sHZNyUHdw\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_0NzxDvjqtDIJCz8GADAJhyew)\n", + " Call ID: call_0NzxDvjqtDIJCz8GADAJhyew\n", + " Args:\n", + " query: db.movies.countDocuments({})\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_BIzElipRKl2d4dnh5tvt9kBZ)\n", + " Call ID: call_BIzElipRKl2d4dnh5tvt9kBZ\n", + " Args:\n", + " query: db.movies.countDocuments({})\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "Error: ValueError('Cannot execute command db.movies.countDocuments({})')\n", + " Please fix your mistakes.\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"How many movies are in the database?\"\n", + "\n", + "⚠️ Large dataset found but too big to display. Try limiting your query (e.g., 'top 10', 'first 5').\n", + "βœ… Test 1 complete\n", + "\n", + "πŸ“Œ Test 2: Find the average rating of all movies\n", + "🧡 Thread: enhanced_test_f4288e1b\n", + "❓ Query: Find the average rating of all movies\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Find the average rating of all movies\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_sne3jYRPFXD7B3jfmIEgWb7X)\n", + " Call ID: call_sne3jYRPFXD7B3jfmIEgWb7X\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_HpeGRq9l7scuzoMq0SWGXoKT)\n", + " Call ID: call_HpeGRq9l7scuzoMq0SWGXoKT\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$group\": { \"_id\": null, \"averageRating\": { \"$avg\": \"$imdb.rating\" } } } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_wpK4lnKymMLjYt8YoypSWoNJ)\n", + " Call ID: call_wpK4lnKymMLjYt8YoypSWoNJ\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$group\": { \"_id\": null, \"averageRating\": { \"$avg\": \"$imdb.rating\" } } } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": null,\n", + " \"averageRating\": 6.662852311161217\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"How many movies are in the database?\"\n", + "\n", + "1. None\n", + "βœ… Test 2 complete\n", + "\n", + "πŸ“Œ Test 3: Show me the top 5 directors by movie count\n", + "🧡 Thread: enhanced_test_f4288e1b\n", + "❓ Query: Show me the top 5 directors by movie count\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Show me the top 5 directors by movie count\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_ochl0Dj7JzLdWDBDMKEsAY5h)\n", + " Call ID: call_ochl0Dj7JzLdWDBDMKEsAY5h\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_x2uQmDgCP7QWnSemzDPcbOng)\n", + " Call ID: call_x2uQmDgCP7QWnSemzDPcbOng\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"movieCount\": -1 } }, { \"$limit\": 5 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_on1FxSEyj2F2eD2pg7e9TWFb)\n", + " Call ID: call_on1FxSEyj2F2eD2pg7e9TWFb\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"movieCount\": -1 } }, { \"$limit\": 5 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": 40\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"movieCount\": 32\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Miike\",\n", + " \"movieCount\": 31\n", + " },\n", + " {\n", + " \"_id\": \"Steven Spielberg\",\n", + " \"movieCount\": 29\n", + " },\n", + " {\n", + " \"_id\": \"John Ford\",\n", + " \"movieCount\": 29\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"How many movies are in the database?\"\n", + "\n", + "1. Woody Allen: 40 movies\n", + "2. Martin Scorsese: 32 movies\n", + "3. Takashi Miike: 31 movies\n", + "4. Steven Spielberg: 29 movies\n", + "5. John Ford: 29 movies\n", + "βœ… Test 3 complete\n", + "\n", + "πŸ” Enhanced Thread Analysis:\n", + "==================================================\n", + "\n", + "πŸ” Thread History: enhanced_test_f4288e1b\n", + "πŸ“Š Total steps: 10\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:34:16]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:34:17]\n", + " \"πŸ“Š Movie count inquiry\"\n", + "\n", + "πŸ“ Step 3 [19:34:18]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "πŸ“ Step 4 [19:34:20]\n", + " \"πŸ”§ Schema lookup: movies\"\n", + "\n", + "πŸ“ Step 5 [19:34:22]\n", + " \"πŸ”§ Schema details: movies\"\n", + "\n", + "πŸ“ Step 6 [19:34:22]\n", + " \"πŸ”§ Schema lookup: movies\"\n", + " └─ (repeated 1 more times)\n", + "\n", + "πŸ“ Step 8 [19:34:22]\n", + " \"❌ Count documents error\"\n", + "\n", + "πŸ“ Step 9 [19:34:23]\n", + " \"πŸ“Š Large dataset warning\"\n", + " └─ (repeated 1 more times)\n", + "\n", + "================================================================================\n" + ] + } + ], + "source": [ + "if __name__ == \"__main__\":\n", + " # Start with the enhanced summarization test\n", + " test_enhanced_summarization()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "c1OE3yosx3gk" + }, + "source": [ + "# Demos" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "TNlHEIZ5hBkv" + }, + "source": [ + "## Demo 1: Run Basic Queries w/ `demo_basic_queries()`" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "GxTDjqSEcV7v", + "outputId": "dbad7a26-c76f-426d-95c1-5d0f63584d6e" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🎬 DEMO: Basic Text-to-MQL Queries\n", + "==================================================\n", + "\n", + "--- Demo Query 1 ---\n", + "Query: List the top 5 movies with highest IMDb ratings\n", + "\n", + "🧡 Thread: demo_basic_1\n", + "❓ Query: List the top 5 movies with highest IMDb ratings\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "List the top 5 movies with highest IMDb ratings\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_SlDBh65YW0pI1rnnaF8tuHX5)\n", + " Call ID: call_SlDBh65YW0pI1rnnaF8tuHX5\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_QzRaQ6RyJNvGIXQ3E0Ku96vO)\n", + " Call ID: call_QzRaQ6RyJNvGIXQ3E0Ku96vO\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$sort\": { \"imdb.rating\": -1 } }, { \"$limit\": 5 }, { \"$project\": { \"title\": 1, \"imdb.rating\": 1 } } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_3ORxwe3o4kXSrOQEj30EyIEs)\n", + " Call ID: call_3ORxwe3o4kXSrOQEj30EyIEs\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$sort\": { \"imdb.rating\": -1 } }, { \"$limit\": 5 }, { \"$project\": { \"title\": 1, \"imdb.rating\": 1 } } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a13b8f29313caabd4d540\"\n", + " },\n", + " \"title\": \"The Danish Girl\",\n", + " \"imdb\": {\n", + " \"rating\": \"\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a13b3f29313caabd3c7ac\"\n", + " },\n", + " \"title\": \"Landet som icke \\u00e8r\",\n", + " \"imdb\": {\n", + " \"rating\": \"\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a13cff29313caabd88f5b\"\n", + " },\n", + " \"title\": \"Scouts Guide to the Zombie Apocalypse\",\n", + " \"imdb\": {\n", + " \"rating\": \"\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a13cef29313caabd86ddc\"\n", + " },\n", + " \"title\": \"Catching the Sun\",\n", + " \"imdb\": {\n", + " \"rating\": \"\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1393f29313caabcddbed\"\n", + " },\n", + " \"title\": \"La nao capitana\",\n", + " \"imdb\": {\n", + " \"rating\": \"\"\n", + " }\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"List the top 5 movies with highest IMDb ratings\"\n", + "\n", + "1. {'$oid': '573a13b8f29313caabd4d540'}\n", + "2. {'$oid': '573a13b3f29313caabd3c7ac'}\n", + "3. {'$oid': '573a13cff29313caabd88f5b'}\n", + "4. {'$oid': '573a13cef29313caabd86ddc'}\n", + "5. {'$oid': '573a1393f29313caabcddbed'}\n", + "\n", + "==================================================\n", + "\n", + "--- Demo Query 2 ---\n", + "Query: Who are the top 10 most active commenters?\n", + "\n", + "🧡 Thread: demo_basic_2\n", + "❓ Query: Who are the top 10 most active commenters?\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Who are the top 10 most active commenters?\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_E0G6xxsRv7Jn1BL0g9II1SU9)\n", + " Call ID: call_E0G6xxsRv7Jn1BL0g9II1SU9\n", + " Args:\n", + " collection_names: comments, users\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: comments\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "name: String\n", + "email: String\n", + "movie_id: ObjectId\n", + "text: String\n", + "date: Timestamp\n", + "\n", + "/*\n", + "3 documents from comments collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"5a9427648b0beebeb6957b89\"\n", + " },\n", + " \"name\": \"Lisa Rasmussen\",\n", + " \"email\": \"lisa_rasmussen@fakegm\",\n", + " \"movie_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd82da\"\n", + " },\n", + " \"text\": \"Illo nihil occaecati \",\n", + " \"date\": {\n", + " \"$date\": \"1976-12-18T08:14:46Z\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"5a9427648b0beebeb6957bb6\"\n", + " },\n", + " \"name\": \"Ellaria Sand\",\n", + " \"email\": \"indira_varma@gameofth\",\n", + " \"movie_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd8780\"\n", + " },\n", + " \"text\": \"Quidem nesciunt quam \",\n", + " \"date\": {\n", + " \"$date\": \"1985-02-24T20:04:25Z\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"5a9427648b0beebeb69579e7\"\n", + " },\n", + " \"name\": \"Mercedes Tyler\",\n", + " \"email\": \"mercedes_tyler@fakegm\",\n", + " \"movie_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd4323\"\n", + " },\n", + " \"text\": \"Eius veritatis vero f\",\n", + " \"date\": {\n", + " \"$date\": \"2002-08-18T04:56:07Z\"\n", + " }\n", + " }\n", + "]\n", + "*/\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: users\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "name: String\n", + "email: String\n", + "password: String\n", + "\n", + "/*\n", + "3 documents from users collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59b99db4cfa9a34dcd7885b6\"\n", + " },\n", + " \"name\": \"Ned Stark\",\n", + " \"email\": \"sean_bean@gameofthron\",\n", + " \"password\": \"$2b$12$UREFwsRUoyF0CR\"\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59b99db6cfa9a34dcd7885bb\"\n", + " },\n", + " \"name\": \"Daenerys Targaryen\",\n", + " \"email\": \"emilia_clarke@gameoft\",\n", + " \"password\": \"$2b$12$NzpbWHdMytemLt\"\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59b99dbfcfa9a34dcd7885cc\"\n", + " },\n", + " \"name\": \"Stannis Baratheon\",\n", + " \"email\": \"stephen_dillane@gameo\",\n", + " \"password\": \"$2b$12$vbPwOM9QkSOsOX\"\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_BnXwhKUYqwksZRYpYWc6Rs0A)\n", + " Call ID: call_BnXwhKUYqwksZRYpYWc6Rs0A\n", + " Args:\n", + " query: db.comments.aggregate([ { \"$group\": { \"_id\": \"$name\", \"commentCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"commentCount\": -1 } }, { \"$limit\": 10 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_w4Fh5hnFJVD8anLQZeD2jsHw)\n", + " Call ID: call_w4Fh5hnFJVD8anLQZeD2jsHw\n", + " Args:\n", + " query: db.comments.aggregate([ { \"$group\": { \"_id\": \"$name\", \"commentCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"commentCount\": -1 } }, { \"$limit\": 10 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Mace Tyrell\",\n", + " \"commentCount\": 277\n", + " },\n", + " {\n", + " \"_id\": \"The High Sparrow\",\n", + " \"commentCount\": 260\n", + " },\n", + " {\n", + " \"_id\": \"Rodrik Cassel\",\n", + " \"commentCount\": 260\n", + " },\n", + " {\n", + " \"_id\": \"Missandei\",\n", + " \"commentCount\": 258\n", + " },\n", + " {\n", + " \"_id\": \"Robert Jordan\",\n", + " \"commentCount\": 257\n", + " },\n", + " {\n", + " \"_id\": \"Sansa Stark\",\n", + " \"commentCount\": 251\n", + " },\n", + " {\n", + " \"_id\": \"Thoros of Myr\",\n", + " \"commentCount\": 251\n", + " },\n", + " {\n", + " \"_id\": \"Donna Smith\",\n", + " \"commentCount\": 248\n", + " },\n", + " {\n", + " \"_id\": \"Nicholas Johnson\",\n", + " \"commentCount\": 248\n", + " },\n", + " {\n", + " \"_id\": \"Beric Dondarrion\",\n", + " \"commentCount\": 247\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Who are the top 10 most active commenters?\"\n", + "\n", + "1. Mace Tyrell\n", + "2. The High Sparrow\n", + "3. Rodrik Cassel\n", + "4. Missandei\n", + "5. Robert Jordan\n", + "6. Sansa Stark\n", + "7. Thoros of Myr\n", + "8. Donna Smith\n", + "9. Nicholas Johnson\n", + "10. Beric Dondarrion\n", + "\n", + "==================================================\n", + "\n", + "--- Demo Query 3 ---\n", + "Query: Which states have the most theaters?\n", + "\n", + "🧡 Thread: demo_basic_3\n", + "❓ Query: Which states have the most theaters?\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Which states have the most theaters?\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_N45yYn03A4N4C4fpoSebWoAP)\n", + " Call ID: call_N45yYn03A4N4C4fpoSebWoAP\n", + " Args:\n", + " collection_names: theaters\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: theaters\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "theaterId: Number\n", + "location.address.street1: String\n", + "location.address.city: String\n", + "location.address.state: String\n", + "location.address.zipcode: String\n", + "location.geo.type: String\n", + "location.geo.coordinates: Array\n", + "\n", + "/*\n", + "3 documents from theaters collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47286cfa9a3a73e51e72e\"\n", + " },\n", + " \"theaterId\": 1008,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"1621 E Monte Vista Av\",\n", + " \"city\": \"Vacaville\",\n", + " \"state\": \"CA\",\n", + " \"zipcode\": \"95688\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -121.96328,\n", + " 38.367649\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47286cfa9a3a73e51e735\"\n", + " },\n", + " \"theaterId\": 1013,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"9901 Brook Rd\",\n", + " \"city\": \"Glen Allen\",\n", + " \"state\": \"VA\",\n", + " \"zipcode\": \"23059\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -77.459908,\n", + " 37.667957\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47286cfa9a3a73e51e738\"\n", + " },\n", + " \"theaterId\": 1015,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"1721 Osgood Dr\",\n", + " \"city\": \"Altoona\",\n", + " \"state\": \"PA\",\n", + " \"zipcode\": \"16602\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -78.382912,\n", + " 40.490524\n", + " ]\n", + " }\n", + " }\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_UMbfO1f7ZSzz06aKODMWeaeF)\n", + " Call ID: call_UMbfO1f7ZSzz06aKODMWeaeF\n", + " Args:\n", + " query: db.theaters.aggregate([ { \"$group\": { \"_id\": \"$location.address.state\", \"theaterCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"theaterCount\": -1 } }, { \"$limit\": 5 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_mZgWpTXtqKot5uDLfPSXxv4c)\n", + " Call ID: call_mZgWpTXtqKot5uDLfPSXxv4c\n", + " Args:\n", + " query: db.theaters.aggregate([ { \"$group\": { \"_id\": \"$location.address.state\", \"theaterCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"theaterCount\": -1 } }, { \"$limit\": 5 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"CA\",\n", + " \"theaterCount\": 169\n", + " },\n", + " {\n", + " \"_id\": \"TX\",\n", + " \"theaterCount\": 160\n", + " },\n", + " {\n", + " \"_id\": \"FL\",\n", + " \"theaterCount\": 111\n", + " },\n", + " {\n", + " \"_id\": \"NY\",\n", + " \"theaterCount\": 81\n", + " },\n", + " {\n", + " \"_id\": \"IL\",\n", + " \"theaterCount\": 70\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Which states have the most theaters?\"\n", + "\n", + "1. CA\n", + "2. TX\n", + "3. FL\n", + "4. NY\n", + "5. IL\n", + "\n", + "==================================================\n", + "\n", + "--- Demo Query 4 ---\n", + "Query: Which theaters are furthest west?\n", + "\n", + "🧡 Thread: demo_basic_4\n", + "❓ Query: Which theaters are furthest west?\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Which theaters are furthest west?\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_cPjzVTGIZ4GMv7OY4oD5x1gL)\n", + " Call ID: call_cPjzVTGIZ4GMv7OY4oD5x1gL\n", + " Args:\n", + " collection_names: theaters\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: theaters\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "theaterId: Number\n", + "location.address.street1: String\n", + "location.address.city: String\n", + "location.address.state: String\n", + "location.address.zipcode: String\n", + "location.geo.type: String\n", + "location.geo.coordinates: Array\n", + "\n", + "/*\n", + "3 documents from theaters collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47286cfa9a3a73e51e72e\"\n", + " },\n", + " \"theaterId\": 1008,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"1621 E Monte Vista Av\",\n", + " \"city\": \"Vacaville\",\n", + " \"state\": \"CA\",\n", + " \"zipcode\": \"95688\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -121.96328,\n", + " 38.367649\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47286cfa9a3a73e51e735\"\n", + " },\n", + " \"theaterId\": 1013,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"9901 Brook Rd\",\n", + " \"city\": \"Glen Allen\",\n", + " \"state\": \"VA\",\n", + " \"zipcode\": \"23059\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -77.459908,\n", + " 37.667957\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47286cfa9a3a73e51e738\"\n", + " },\n", + " \"theaterId\": 1015,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"1721 Osgood Dr\",\n", + " \"city\": \"Altoona\",\n", + " \"state\": \"PA\",\n", + " \"zipcode\": \"16602\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -78.382912,\n", + " 40.490524\n", + " ]\n", + " }\n", + " }\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_qAPs1MUPRLHbB4dcCtL0BR5u)\n", + " Call ID: call_qAPs1MUPRLHbB4dcCtL0BR5u\n", + " Args:\n", + " query: db.theaters.aggregate([ { \"$sort\": { \"location.geo.coordinates.0\": 1 } }, { \"$limit\": 5 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_4FYxHTmYsp9M4GgEeBHiEHgQ)\n", + " Call ID: call_4FYxHTmYsp9M4GgEeBHiEHgQ\n", + " Args:\n", + " query: db.theaters.aggregate([ { \"$sort\": { \"location.geo.coordinates.0\": 1 } }, { \"$limit\": 5 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47287cfa9a3a73e51ece9\"\n", + " },\n", + " \"theaterId\": 852,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"98-051 Kamehameha Hwy\",\n", + " \"city\": \"Aiea\",\n", + " \"state\": \"HI\",\n", + " \"zipcode\": \"96701\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -157.9497,\n", + " 21.384672\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47287cfa9a3a73e51ec98\"\n", + " },\n", + " \"theaterId\": 8140,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"300 Rodgers Boulevard\",\n", + " \"street2\": null,\n", + " \"city\": \"Honolulu\",\n", + " \"state\": \"HI\",\n", + " \"zipcode\": \"96819\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -157.919795,\n", + " 21.332003\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47287cfa9a3a73e51eca2\"\n", + " },\n", + " \"theaterId\": 8153,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"300 Rodgers Boulevard\",\n", + " \"street2\": null,\n", + " \"city\": \"Honolulu\",\n", + " \"state\": \"HI\",\n", + " \"zipcode\": \"96819\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -157.919795,\n", + " 21.332003\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47287cfa9a3a73e51ecb9\"\n", + " },\n", + " \"theaterId\": 8183,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"300 Rodgers Boulevard\",\n", + " \"street2\": null,\n", + " \"city\": \"Honolulu\",\n", + " \"state\": \"HI\",\n", + " \"zipcode\": \"96819\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -157.919795,\n", + " 21.332003\n", + " ]\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"59a47287cfa9a3a73e51eca3\"\n", + " },\n", + " \"theaterId\": 8152,\n", + " \"location\": {\n", + " \"address\": {\n", + " \"street1\": \"300 Rodgers Boulevard\",\n", + " \"street2\": null,\n", + " \"city\": \"Honolulu\",\n", + " \"state\": \"HI\",\n", + " \"zipcode\": \"96819\"\n", + " },\n", + " \"geo\": {\n", + " \"type\": \"Point\",\n", + " \"coordinates\": [\n", + " -157.919795,\n", + " 21.332003\n", + " ]\n", + " }\n", + " }\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Which theaters are furthest west?\"\n", + "\n", + "1. {'$oid': '59a47287cfa9a3a73e51ece9'}\n", + "2. {'$oid': '59a47287cfa9a3a73e51ec98'}\n", + "3. {'$oid': '59a47287cfa9a3a73e51eca2'}\n", + "4. {'$oid': '59a47287cfa9a3a73e51ecb9'}\n", + "5. {'$oid': '59a47287cfa9a3a73e51eca3'}\n", + "\n", + "==================================================\n", + "\n", + "--- Demo Query 5 ---\n", + "Query: Find directors with β‰₯20 films, highest avg IMDb rating (top-5)\n", + "\n", + "🧡 Thread: demo_basic_5\n", + "❓ Query: Find directors with β‰₯20 films, highest avg IMDb rating (top-5)\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Find directors with β‰₯20 films, highest avg IMDb rating (top-5)\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_Uwp5BdXJAf5qgtJbf8U3dMh6)\n", + " Call ID: call_Uwp5BdXJAf5qgtJbf8U3dMh6\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_ghfO5T3gfo1y1YAWaIauclsh)\n", + " Call ID: call_ghfO5T3gfo1y1YAWaIauclsh\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { \"_id\": \"$directors\", \"filmCount\": { \"$sum\": 1 }, \"avgRating\": { \"$avg\": \"$imdb.rating\" } } }, { \"$match\": { \"filmCount\": { \"$gte\": 20 } } }, { \"$sort\": { \"avgRating\": -1 } }, { \"$limit\": 5 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_QDDEEeLbt8VDeBKNBjLP5Pin)\n", + " Call ID: call_QDDEEeLbt8VDeBKNBjLP5Pin\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { \"_id\": \"$directors\", \"filmCount\": { \"$sum\": 1 }, \"avgRating\": { \"$avg\": \"$imdb.rating\" } } }, { \"$match\": { \"filmCount\": { \"$gte\": 20 } } }, { \"$sort\": { \"avgRating\": -1 } }, { \"$limit\": 5 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"William Wyler\",\n", + " \"filmCount\": 21,\n", + " \"avgRating\": 7.676190476190476\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"filmCount\": 32,\n", + " \"avgRating\": 7.640625\n", + " },\n", + " {\n", + " \"_id\": \"Alfred Hitchcock\",\n", + " \"filmCount\": 24,\n", + " \"avgRating\": 7.5874999999999995\n", + " },\n", + " {\n", + " \"_id\": \"Steven Spielberg\",\n", + " \"filmCount\": 29,\n", + " \"avgRating\": 7.479310344827587\n", + " },\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"filmCount\": 40,\n", + " \"avgRating\": 7.215000000000001\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Find directors with β‰₯20 films, highest avg IMDb rating (top-5)\"\n", + "\n", + "1. William Wyler\n", + "2. Martin Scorsese\n", + "3. Alfred Hitchcock\n", + "4. Steven Spielberg\n", + "5. Woody Allen\n" + ] + } + ], + "source": [ + "demo_basic_queries()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "I8IWPvGExZAp" + }, + "source": [ + "## Demo 2: Multi-turn conversations - `demo_conversation_memory()`" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qBLP4qPkxYSO", + "outputId": "a552b046-710a-4113-b5d1-f304144384aa" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "🎬 DEMO: Conversation Memory with Text-to-MQL\n", + "==================================================\n", + "\n", + "--- Conversation Step 1 ---\n", + "🧡 Thread: conversation_demo_7e08f130\n", + "❓ Query: List the top 3 directors by movie count\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "List the top 3 directors by movie count\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_TavHIcPtXu3JRSue5UnpSDbi)\n", + " Call ID: call_TavHIcPtXu3JRSue5UnpSDbi\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_4e8lfVyWrJyjRBZh8jKH1vfD)\n", + " Call ID: call_4e8lfVyWrJyjRBZh8jKH1vfD\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"movieCount\": -1 } }, { \"$limit\": 3 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_VV7SxdQi3WYXZBWEp3lP87BE)\n", + " Call ID: call_VV7SxdQi3WYXZBWEp3lP87BE\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"movieCount\": -1 } }, { \"$limit\": 3 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": 40\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"movieCount\": 32\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Miike\",\n", + " \"movieCount\": 31\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"List the top 3 directors by movie count\"\n", + "\n", + "1. Woody Allen: 40 movies\n", + "2. Martin Scorsese: 32 movies\n", + "3. Takashi Miike: 31 movies\n", + "\n", + "πŸ”„ Building context for next query...\n", + "========================================\n", + "\n", + "--- Conversation Step 2 ---\n", + "🧡 Thread: conversation_demo_7e08f130\n", + "❓ Query: What was the movie count for the first director?\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "What was the movie count for the first director?\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_CrmuM4DXbeIGXyisNJh09NZ1)\n", + " Call ID: call_CrmuM4DXbeIGXyisNJh09NZ1\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "The movie count for the first director, Woody Allen, is 40 movies.\n", + "\n", + "πŸ”„ Building context for next query...\n", + "========================================\n", + "\n", + "--- Conversation Step 3 ---\n", + "🧡 Thread: conversation_demo_7e08f130\n", + "❓ Query: Show me movies by that director with highest ratings\n", + "πŸ“Š Agent: Custom LangGraph\n", + "==================================================\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Show me movies by that director with highest ratings\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_schema (call_tVfyYdTFQYg1WSwKvyZuWjFp)\n", + " Call ID: call_tVfyYdTFQYg1WSwKvyZuWjFp\n", + " Args:\n", + " collection_names: movies\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_Ft6xllxobUsnisbxR1xm8JAh)\n", + " Call ID: call_Ft6xllxobUsnisbxR1xm8JAh\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$match\": { \"directors\": \"Woody Allen\" } }, { \"$sort\": { \"imdb.rating\": -1 } }, { \"$project\": { \"title\": 1, \"imdb.rating\": 1 } }, { \"$limit\": 5 } ])\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "Tool Calls:\n", + " mongodb_query (call_hV9m8OOwPoMvYc6Mchmoucts)\n", + " Call ID: call_hV9m8OOwPoMvYc6Mchmoucts\n", + " Args:\n", + " query: db.movies.aggregate([ { \"$match\": { \"directors\": \"Woody Allen\" } }, { \"$sort\": { \"imdb.rating\": -1 } }, { \"$project\": { \"title\": 1, \"imdb.rating\": 1 } }, { \"$limit\": 5 } ])\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1397f29313caabce64fa\"\n", + " },\n", + " \"title\": \"Annie Hall\",\n", + " \"imdb\": {\n", + " \"rating\": 8.1\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1398f29313caabceb5fc\"\n", + " },\n", + " \"title\": \"Crimes and Misdemeanors\",\n", + " \"imdb\": {\n", + " \"rating\": 8.0\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1398f29313caabce9f96\"\n", + " },\n", + " \"title\": \"Hannah and Her Sisters\",\n", + " \"imdb\": {\n", + " \"rating\": 8.0\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1397f29313caabce7388\"\n", + " },\n", + " \"title\": \"Manhattan\",\n", + " \"imdb\": {\n", + " \"rating\": 8.0\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1398f29313caabce9a9a\"\n", + " },\n", + " \"title\": \"The Purple Rose of Cairo\",\n", + " \"imdb\": {\n", + " \"rating\": 7.8\n", + " }\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"List the top 3 directors by movie count\"\n", + "\n", + "1. {'$oid': '573a1397f29313caabce64fa'}\n", + "2. {'$oid': '573a1398f29313caabceb5fc'}\n", + "3. {'$oid': '573a1398f29313caabce9f96'}\n", + "4. {'$oid': '573a1397f29313caabce7388'}\n", + "5. {'$oid': '573a1398f29313caabce9a9a'}\n", + "\n", + "πŸ” Complete Conversation Analysis:\n", + "========================================\n", + "\n", + "πŸ” Thread History: conversation_demo_7e08f130\n", + "πŸ“Š Total steps: 10\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:35:02]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:35:03]\n", + " \"πŸ“Š List top directors\"\n", + "\n", + "πŸ“ Step 3 [19:35:03]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "πŸ“ Step 4 [19:35:03]\n", + " \"πŸ”§ Schema lookup: movies\"\n", + "\n", + "πŸ“ Step 5 [19:35:03]\n", + " \"πŸ”§ Schema details: movies\"\n", + "\n", + "πŸ“ Step 6 [19:35:05]\n", + " \"πŸ”§ Schema lookup: movies\"\n", + " └─ (repeated 1 more times)\n", + "\n", + "πŸ“ Step 8 [19:35:07]\n", + " \"πŸ“Š Director movie counts\"\n", + "\n", + "πŸ“ Step 9 [19:35:08]\n", + " \"✨ Top directors by count\"\n", + " └─ (repeated 1 more times)\n", + "\n", + "================================================================================\n" + ] + } + ], + "source": [ + "demo_conversation_memory()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "pkrTvMAVxk1q" + }, + "source": [ + "## Demo 3: Enhanced Agent Comparison with Different Query Complexities\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "5YD7KZtl9LAL", + "outputId": "8e96b478-a1af-4549-cfea-dc3841ae0670" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“Š Demo 3a: Simple Query Comparison\n", + "==================================================\n", + "Agent Comparison: ReAct vs LangGraph\n", + "============================================================\n", + "Query: Count all movies in the database\n", + "Max Retries: 2\n", + "Recursion Limit: 50\n", + "============================================================\n", + "\n", + "ReAct Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_d39279d2_react_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Count all movies in the database\n", + "\n", + "Final ReAct Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Count all movies in the database\n", + " Step 2: Tool call: mongodb_list_collections\n", + " Step 3: Response: comments, embedded_movies, movies, sessions, theat...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_list_collections\n", + "\n", + "comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 4: Tool call: mongodb_query_checker\n", + " Step 5: Response: content='```javascript\\ndb.movies.aggregate([{ \"$c...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```javascript\\ndb.movies.aggregate([{ \"$count\": \"totalMovies\" }])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 17, 'prompt_tokens': 110, 'total_tokens': 127, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhhzi2ikqZSpf32gVoiRTpThzY6e3', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--d2b6ba02-e5bb-4f9a-99a6-554cf7771a15-0' usage_metadata={'input_tokens': 110, 'output_tokens': 17, 'total_tokens': 127, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + " Step 8: Response: There are a total of 21,349 movies in the database...\n", + "\n", + "Final ReAct Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "There are a total of 21,349 movies in the database.\n", + "\n", + "ReAct agent succeeded in 8 steps\n", + "\n", + "LangGraph Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_d39279d2_graph_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Count all movies in the database\n", + "\n", + "Final LangGraph Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Count all movies in the database\n", + " Step 2: Response: Available collections: comments, embedded_movies, ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 3: Tool call: mongodb_schema\n", + " Step 4: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 5: Tool call: mongodb_query\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + " Step 8: Response: **Answer to:** \"Count all movies in the database\"\n", + "\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Count all movies in the database\"\n", + "\n", + "LangGraph agent succeeded in 8 steps\n", + "\n", + "Comparison Summary:\n", + "============================================================\n", + "\n", + "ReAct Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 4.40s\n", + "\n", + "LangGraph Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 3.05s\n", + "\n", + "Execution Style Analysis:\n", + " ReAct Agent:\n", + " - Autonomous reasoning and tool selection\n", + " - Dynamic decision making based on previous results\n", + " - Can get stuck in reasoning loops with complex queries\n", + " - More flexible but less predictable workflow\n", + " LangGraph Agent:\n", + " - Structured, deterministic workflow\n", + " - Predefined step sequence with conditional branches\n", + " - Better error isolation and recovery\n", + " - More predictable but less flexible execution\n", + "\n", + "Memory Pattern Analysis:\n", + " ReAct Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_d39279d2_react_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:35:15]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:35:16]\n", + " \"πŸ“Š Count all movies\"\n", + "\n", + "πŸ“ Step 3 [19:35:17]\n", + " \"πŸ”§ List MongoDB collections\"\n", + "\n", + "================================================================================\n", + " LangGraph Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_d39279d2_graph_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:35:20]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:35:20]\n", + " \"πŸ“Š Count all movies\"\n", + "\n", + "πŸ“ Step 3 [19:35:20]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "================================================================================\n", + "\n", + "Recommendations:\n", + " - LangGraph agent was more efficient for this query\n", + " - Both agents handled the query successfully\n", + "\n", + "================================================================================\n", + "\n" + ] + } + ], + "source": [ + "# Demo 3a: Simple comparison\n", + "print(\"πŸ“Š Demo 3a: Simple Query Comparison\")\n", + "print(\"=\" * 50)\n", + "compare_agents_with_memory(\"Count all movies in the database\", max_retries=2)\n", + "\n", + "print(\"\\n\" + \"=\" * 80 + \"\\n\")" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "FB0ac78K9MWO", + "outputId": "36a9a965-667c-40dd-9eb9-cba1a6d09003" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“Š Demo 3b: Moderate Complexity Comparison\n", + "==================================================\n", + "Agent Comparison: ReAct vs LangGraph\n", + "============================================================\n", + "Query: List the top 5 directors by movie count\n", + "Max Retries: 2\n", + "Recursion Limit: 40\n", + "============================================================\n", + "\n", + "ReAct Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_260fd616_react_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: List the top 5 directors by movie count\n", + "\n", + "Final ReAct Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "List the top 5 directors by movie count\n", + " Step 2: Tool call: mongodb_list_collections\n", + " Step 3: Response: comments, embedded_movies, movies, sessions, theat...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_list_collections\n", + "\n", + "comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 4: Tool call: mongodb_schema\n", + " Step 5: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 6: Tool call: mongodb_query_checker\n", + " Step 7: Response: content='```javascript\\ndb.movies.aggregate([\\n ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```javascript\\ndb.movies.aggregate([\\n { \"$unwind\": \"$directors\" },\\n { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } },\\n { \"$sort\": { \"movieCount\": -1 } },\\n { \"$limit\": 5 }\\n])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 68, 'prompt_tokens': 156, 'total_tokens': 224, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-BhhzpJznhSUbadHnAAVeL71mfizbo', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--60aa7549-fb46-4335-83f7-c8a820e92569-0' usage_metadata={'input_tokens': 156, 'output_tokens': 68, 'total_tokens': 224, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 8: Tool call: mongodb_query\n", + " Step 9: Response: [\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": 40\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"movieCount\": 32\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Miike\",\n", + " \"movieCount\": 31\n", + " },\n", + " {\n", + " \"_id\": \"Sidney Lumet\",\n", + " \"movieCount\": 29\n", + " },\n", + " {\n", + " \"_id\": \"Steven Spielberg\",\n", + " \"movieCount\": 29\n", + " }\n", + "]\n", + " Step 10: Response: The top 5 directors by movie count are:\n", + "\n", + "1. **Wood...\n", + "\n", + "Final ReAct Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "The top 5 directors by movie count are:\n", + "\n", + "1. **Woody Allen** - 40 movies\n", + "2. **Martin Scorsese** - 32 movies\n", + "3. **Takashi Miike** - 31 movies\n", + "4. **Sidney Lumet** - 29 movies\n", + "5. **Steven Spielberg** - 29 movies\n", + "\n", + "ReAct agent succeeded in 10 steps\n", + "\n", + "LangGraph Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_260fd616_graph_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: List the top 5 directors by movie count\n", + "\n", + "Final LangGraph Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "List the top 5 directors by movie count\n", + " Step 2: Response: Available collections: comments, embedded_movies, ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 3: Tool call: mongodb_schema\n", + " Step 4: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 5: Tool call: mongodb_query\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": ...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": 40\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"movieCount\": 32\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Miike\",\n", + " \"movieCount\": 31\n", + " },\n", + " {\n", + " \"_id\": \"Steven Spielberg\",\n", + " \"movieCount\": 29\n", + " },\n", + " {\n", + " \"_id\": \"Sidney Lumet\",\n", + " \"movieCount\": 29\n", + " }\n", + "]\n", + " Step 8: Response: **Answer to:** \"List the top 5 directors by movie ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"List the top 5 directors by movie count\"\n", + "\n", + "1. Woody Allen: 40 movies\n", + "2. Martin Scorsese: 32 movies\n", + "3. Takashi Miike: 31 movies\n", + "4. Steven Spielberg: 29 movies\n", + "5. Sidney Lumet: 29 movies\n", + "\n", + "LangGraph agent succeeded in 8 steps\n", + "\n", + "Comparison Summary:\n", + "============================================================\n", + "\n", + "ReAct Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 7.72s\n", + "\n", + "LangGraph Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 3.79s\n", + "\n", + "Execution Style Analysis:\n", + " ReAct Agent:\n", + " - Autonomous reasoning and tool selection\n", + " - Dynamic decision making based on previous results\n", + " - Can get stuck in reasoning loops with complex queries\n", + " - More flexible but less predictable workflow\n", + " LangGraph Agent:\n", + " - Structured, deterministic workflow\n", + " - Predefined step sequence with conditional branches\n", + " - Better error isolation and recovery\n", + " - More predictable but less flexible execution\n", + "\n", + "Memory Pattern Analysis:\n", + " ReAct Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_260fd616_react_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:35:23]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:35:23]\n", + " \"πŸ“Š List top directors\"\n", + "\n", + "πŸ“ Step 3 [19:35:23]\n", + " \"πŸ”§ List MongoDB collections\"\n", + "\n", + "================================================================================\n", + " LangGraph Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_260fd616_graph_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:35:31]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:35:31]\n", + " \"πŸ“Š List top directors by movies\"\n", + "\n", + "πŸ“ Step 3 [19:35:31]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "================================================================================\n", + "\n", + "Recommendations:\n", + " - LangGraph agent was more efficient for this query\n", + " - Both agents handled the query successfully\n", + "\n", + "================================================================================\n", + "\n" + ] + } + ], + "source": [ + "# Demo 3b: Moderate complexity\n", + "print(\"πŸ“Š Demo 3b: Moderate Complexity Comparison\")\n", + "print(\"=\" * 50)\n", + "compare_agents_with_memory(\n", + " \"List the top 5 directors by movie count\", max_retries=2, recursion_limit=40\n", + ")\n", + "\n", + "print(\"\\n\" + \"=\" * 80 + \"\\n\")" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "7ydI-MXhxw2i", + "outputId": "4db6e714-8df3-4d5f-fff5-495fcaa1a027" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1;30;43mStreaming output truncated to the last 5000 lines.\u001b[0m\n", + " 0.0068590273,\n", + " -0.00019658639,\n", + " 0.00325837,\n", + " -0.004712258,\n", + " 0.0060348804,\n", + " 0.00074355974,\n", + " 0.013664884,\n", + " 0.014090249,\n", + " -0.011830493,\n", + " 0.024830742,\n", + " -0.0099229915,\n", + " -0.025016839,\n", + " -0.018915495,\n", + " 0.01112598,\n", + " 0.0097501865,\n", + " -0.0077164057,\n", + " -0.015220128,\n", + " -0.0020736593,\n", + " -0.012382139,\n", + " -0.017293787,\n", + " 0.0027515865,\n", + " -0.01839708,\n", + " 0.0072312225,\n", + " -0.012794212,\n", + " 0.022464642,\n", + " 0.0010310141,\n", + " 0.03184928,\n", + " 0.032992452,\n", + " -0.014010494,\n", + " -0.013664884,\n", + " -0.022345008,\n", + " -0.0016757095,\n", + " 0.008633601,\n", + " 0.015166957,\n", + " -0.0060016485,\n", + " 0.0037385686,\n", + " -0.0016956485,\n", + " -0.020098545,\n", + " 0.009384638,\n", + " 0.0014414259,\n", + " -0.019168057,\n", + " 0.023820497,\n", + " 0.008121832,\n", + " 0.0037618307,\n", + " -0.03110489,\n", + " -0.008294637,\n", + " 0.00236776,\n", + " 0.009517564,\n", + " -0.0022813575,\n", + " -0.006446954,\n", + " -0.016482932,\n", + " -0.00309055,\n", + " 0.010062565,\n", + " -0.019340862,\n", + " -0.0139041515,\n", + " -0.021720253,\n", + " -0.010487931,\n", + " 0.001967318,\n", + " -0.011710858,\n", + " 0.01512708,\n", + " -0.0076632346,\n", + " 0.0006027403,\n", + " -0.005582929,\n", + " 0.016256958,\n", + " -0.026160011,\n", + " -0.022265254,\n", + " -0.022092449,\n", + " -0.013166408,\n", + " 0.017054519,\n", + " 0.011936834,\n", + " 0.030945377,\n", + " -0.0045328066,\n", + " 0.040223673,\n", + " -0.005503173,\n", + " -0.0026103517,\n", + " 0.015977811,\n", + " -0.0065366793,\n", + " -0.0061611608,\n", + " -0.038282942,\n", + " -0.025694767,\n", + " 0.019487081,\n", + " -0.00092301104,\n", + " 0.0020287966,\n", + " 0.008008844,\n", + " 0.006084728,\n", + " -3.7177986e-05,\n", + " -0.00823482,\n", + " 0.0016541089,\n", + " 0.00336305,\n", + " -0.02086952,\n", + " -0.017320372,\n", + " 0.0131398225,\n", + " -0.017679276,\n", + " -0.0077762227,\n", + " -0.008440857,\n", + " -0.015047323,\n", + " 0.04806636,\n", + " 0.01923452,\n", + " -0.014675127,\n", + " 0.0026336138,\n", + " 0.019566838,\n", + " 0.0031852603,\n", + " 0.015658787,\n", + " -0.0008104386,\n", + " -0.0020520587,\n", + " 0.0026136748,\n", + " 0.017612811,\n", + " -0.00226308,\n", + " -0.010374943,\n", + " -0.0059584477,\n", + " 0.004595947,\n", + " 0.0050910995,\n", + " -0.01139848,\n", + " 0.010062565,\n", + " -0.002492379,\n", + " 0.037405625,\n", + " 0.012495127,\n", + " -0.022305131,\n", + " -0.009371345,\n", + " -0.032460745,\n", + " -0.021800008,\n", + " -0.013811103,\n", + " -0.002123507,\n", + " -0.04761441,\n", + " 0.0007705605,\n", + " -0.028499523,\n", + " -0.001617554,\n", + " 0.005559667,\n", + " -0.02625306,\n", + " -0.009437809,\n", + " 0.004353355,\n", + " 0.0066297282,\n", + " 0.053144168,\n", + " 0.021427814,\n", + " 0.03482684,\n", + " 0.021228423,\n", + " -0.0047022887,\n", + " 0.0037418918,\n", + " 0.035916843,\n", + " -0.01612403,\n", + " -0.010806955,\n", + " 0.025056718,\n", + " 0.023328668,\n", + " -0.03317855,\n", + " -0.011644395,\n", + " -0.033736844,\n", + " -5.7895886e-06,\n", + " -0.015618908,\n", + " -0.012196042,\n", + " 0.011099394,\n", + " 0.00031840143,\n", + " 4.7588863e-05,\n", + " -0.0007988075,\n", + " -0.024299035,\n", + " 0.00284962,\n", + " 0.00838104,\n", + " -0.010747138,\n", + " -0.004652441,\n", + " -0.013272749,\n", + " -0.024019888,\n", + " -0.03559782,\n", + " -0.011684272,\n", + " -0.0002635691,\n", + " -0.0012004959,\n", + " 0.006586527,\n", + " -0.01070726,\n", + " 0.006865673,\n", + " -0.012255859,\n", + " 0.0074837836,\n", + " -0.0017911898,\n", + " -0.00087150186,\n", + " 0.029828792,\n", + " 0.016137324,\n", + " 0.016801957,\n", + " -0.018210983,\n", + " -0.0054965266,\n", + " -0.014023786,\n", + " -0.0056892703,\n", + " 0.017705861,\n", + " 0.027834889,\n", + " -0.0012345584,\n", + " 0.021441106,\n", + " 0.0049050017,\n", + " 0.0012187733,\n", + " 0.018184397,\n", + " 0.012315676,\n", + " -0.01627025,\n", + " -0.017440006,\n", + " -0.018078055,\n", + " -0.0005524774,\n", + " 0.025003547,\n", + " -0.010321773,\n", + " -0.012222627,\n", + " -0.02023147,\n", + " -0.017572934,\n", + " -0.015273299,\n", + " -0.03110489,\n", + " -0.009936284,\n", + " 0.0019606715,\n", + " -0.0152467135,\n", + " -0.000101564445,\n", + " 0.004572685,\n", + " -0.004177227,\n", + " 0.020683423,\n", + " 0.0039745136,\n", + " 0.00658985,\n", + " -0.010467992,\n", + " 0.026585376,\n", + " -0.020803057,\n", + " 0.011185797,\n", + " -0.01028854,\n", + " 0.012574883,\n", + " -0.016496226,\n", + " -0.00079049956,\n", + " 0.033311475,\n", + " -0.0073508564,\n", + " 0.016682323,\n", + " -0.02156074,\n", + " -0.016988056,\n", + " -0.015260006,\n", + " -0.0070982953,\n", + " -0.012880615,\n", + " -0.012734395,\n", + " -0.034534402,\n", + " -0.010767077,\n", + " -0.008553845,\n", + " 0.011877017,\n", + " -0.033311475,\n", + " -0.008839638,\n", + " 0.030679524,\n", + " 0.00034290983,\n", + " 0.003042364,\n", + " 0.0028944828,\n", + " -0.0134322615,\n", + " -0.0042071356,\n", + " -0.013997201,\n", + " 0.014050371,\n", + " 0.0024907175,\n", + " -0.03001489,\n", + " -0.0003933805,\n", + " -0.013731346,\n", + " 0.032035377,\n", + " 0.007051771,\n", + " -0.019686472,\n", + " -0.019752935,\n", + " -0.019606715,\n", + " -0.004499575,\n", + " 0.01359842,\n", + " 0.017373543,\n", + " 0.014223176,\n", + " 0.019939031,\n", + " 0.030333914,\n", + " 0.017931836,\n", + " 0.003595672,\n", + " -0.012927139,\n", + " -0.0076366495,\n", + " 0.0069254907,\n", + " -0.015459396,\n", + " -0.027037328,\n", + " -0.0150739085,\n", + " -0.013020188,\n", + " 0.03791075,\n", + " 0.0014439182,\n", + " -0.008547199,\n", + " -0.028153913,\n", + " 0.013983908,\n", + " -0.00783604,\n", + " -0.009843236,\n", + " -0.01741342,\n", + " 0.021401228,\n", + " 0.028871719,\n", + " 0.0069055515,\n", + " 0.0089858575,\n", + " 0.021999398,\n", + " 0.013113237,\n", + " 0.030493427,\n", + " -0.008447504,\n", + " 0.00029451612,\n", + " -0.014130128,\n", + " -0.019845983,\n", + " 0.018755984,\n", + " 0.019686472,\n", + " -0.010069211,\n", + " 0.0050545447,\n", + " 0.0058986302,\n", + " -0.0033829892,\n", + " -0.012475188,\n", + " 0.01379781,\n", + " 0.008872869,\n", + " -0.009138723,\n", + " -0.021427814,\n", + " -0.011670981,\n", + " 0.02096257,\n", + " -3.4659646e-05,\n", + " 0.0038382637,\n", + " -0.014675127,\n", + " -6.3192194e-05,\n", + " 0.0069254907,\n", + " 0.015539153,\n", + " -0.020390984,\n", + " -0.024325619,\n", + " 0.010029334,\n", + " -0.016974762,\n", + " 0.019008543,\n", + " -0.0064070756,\n", + " -0.0024026535,\n", + " 0.020989155,\n", + " -0.028791962,\n", + " 0.014037078,\n", + " -0.00981665,\n", + " 0.0024176077,\n", + " 0.0070916493,\n", + " 0.0074505517,\n", + " -0.022517813,\n", + " -0.0060714353,\n", + " 0.028472938,\n", + " 0.0047853678,\n", + " 0.01845025,\n", + " -0.0067526856,\n", + " -0.00535363,\n", + " 0.00048061376,\n", + " 0.004443081,\n", + " -0.008287991,\n", + " -0.015326469,\n", + " -0.0024907175,\n", + " -0.008892808,\n", + " -9.5177726e-05,\n", + " -0.025734644,\n", + " 0.012628053,\n", + " 0.011332016,\n", + " -0.0069986004,\n", + " -0.011930187,\n", + " -0.01036165,\n", + " -0.010188846,\n", + " -0.014555493,\n", + " -0.00399113,\n", + " -0.015884763,\n", + " -0.016044274,\n", + " -0.0026668455,\n", + " -0.008859577,\n", + " 0.014170006,\n", + " -0.035677575,\n", + " -0.02092269,\n", + " 0.0025538576,\n", + " -0.011883663,\n", + " 0.0336305,\n", + " 0.22927229,\n", + " 0.0018493453,\n", + " -0.0005852937,\n", + " 0.025295986,\n", + " -0.012461895,\n", + " 0.015618908,\n", + " 0.026199888,\n", + " -0.0067759478,\n", + " -0.00015213896,\n", + " 0.0061910697,\n", + " -0.0061478685,\n", + " 0.009650491,\n", + " 0.017533056,\n", + " 0.009092199,\n", + " -0.004469666,\n", + " -0.02388696,\n", + " -0.014316225,\n", + " -0.019713057,\n", + " 0.0022132327,\n", + " -0.029243914,\n", + " 0.007264454,\n", + " -0.004924941,\n", + " 0.012222627,\n", + " -0.03129099,\n", + " 0.014116835,\n", + " -0.01779891,\n", + " -0.011584578,\n", + " 0.0012652978,\n", + " 0.019261105,\n", + " 0.018171106,\n", + " -0.009876467,\n", + " -0.0128473835,\n", + " -0.0008540552,\n", + " 0.0024790864,\n", + " -0.006101344,\n", + " -0.008387687,\n", + " 0.011491529,\n", + " 0.007929089,\n", + " -0.009537504,\n", + " -0.00076931436,\n", + " -0.003944605,\n", + " -0.0076831738,\n", + " 0.0060116183,\n", + " 0.009457747,\n", + " 0.026040375,\n", + " 0.02061696,\n", + " -0.018623056,\n", + " 0.014037078,\n", + " -0.0032218152,\n", + " 0.03655489,\n", + " -0.03219489,\n", + " -0.008241466,\n", + " 0.030918792,\n", + " 0.03224806,\n", + " -0.0070783566,\n", + " 0.00521738,\n", + " 0.022863423,\n", + " 0.0078028077,\n", + " -0.0051243315,\n", + " -0.011850432,\n", + " 0.0051874714,\n", + " 0.017891958,\n", + " -0.0069454294,\n", + " -0.011172504,\n", + " -0.008474088,\n", + " 0.015220128,\n", + " -0.018968666,\n", + " 0.01503403,\n", + " 0.025482083,\n", + " -0.016336713,\n", + " -0.015751835,\n", + " -0.019021837,\n", + " -0.011936834,\n", + " -0.011690919,\n", + " -0.0077164057,\n", + " -0.020537203,\n", + " 0.016629152,\n", + " 0.00015078892,\n", + " 0.012920493,\n", + " 0.027861474,\n", + " -0.018463545,\n", + " -0.0074837836,\n", + " -0.00025588425,\n", + " -0.0017895282,\n", + " -0.018556593,\n", + " -0.011079456,\n", + " 0.028951475,\n", + " 0.01023537,\n", + " -0.019752935,\n", + " 0.016642446,\n", + " -0.011318724,\n", + " -0.032753184,\n", + " 0.005247289,\n", + " 0.00021870626,\n", + " 0.0016366623,\n", + " 0.030387085,\n", + " 0.018264154,\n", + " 0.004001099,\n", + " -0.0007539447,\n", + " -0.009112137,\n", + " -0.04221758,\n", + " -0.026492327,\n", + " 0.007643296,\n", + " -0.014542201,\n", + " -0.012621407,\n", + " -0.0022414795,\n", + " 0.016443055,\n", + " -0.008693418,\n", + " 0.008919394,\n", + " -0.0010268602,\n", + " -0.008527259,\n", + " -0.0057424414,\n", + " -0.00034228672,\n", + " -0.012043175,\n", + " 0.006177777,\n", + " 0.02412623,\n", + " 0.025256107,\n", + " 0.008128479,\n", + " 0.016589275,\n", + " -0.015047323,\n", + " 0.025787815,\n", + " -0.0129670175,\n", + " -0.0074439053,\n", + " -0.0028030956,\n", + " -0.0021484308,\n", + " -0.038442455,\n", + " -0.0113253705,\n", + " 0.020178301,\n", + " 0.0179983,\n", + " 0.0026635225,\n", + " 0.012920493,\n", + " -0.022172203,\n", + " 0.021520862,\n", + " -0.008573784,\n", + " -0.000947104,\n", + " 0.024006594,\n", + " 0.030121231,\n", + " 0.0036687818,\n", + " -0.0034494526,\n", + " 0.0015643833,\n", + " 0.0139041515,\n", + " -0.0031337512,\n", + " -0.006643021,\n", + " -0.0060016485,\n", + " 0.0045128674,\n", + " -0.016177202,\n", + " 0.013186347,\n", + " -0.02546879,\n", + " -0.012129578,\n", + " -0.01518025,\n", + " -0.01928769,\n", + " -0.024564888,\n", + " -0.00075103686,\n", + " -0.00569924,\n", + " 0.021932935,\n", + " -0.012375493,\n", + " -0.015273299,\n", + " -0.021733545,\n", + " 0.008427564,\n", + " 0.023820497,\n", + " -0.038628552,\n", + " -0.005330368,\n", + " -0.0054765875,\n", + " -0.02047074,\n", + " -0.014130128,\n", + " 0.0005001374,\n", + " -0.17099714,\n", + " 0.008015491,\n", + " 0.02576123,\n", + " -0.015419519,\n", + " 0.02086952,\n", + " -0.0077164057,\n", + " 0.023129277,\n", + " -0.008261406,\n", + " -0.021547448,\n", + " -0.016482932,\n", + " 0.015977811,\n", + " 0.021720253,\n", + " -0.07465173,\n", + " -0.025854278,\n", + " 0.0025073334,\n", + " 0.022916595,\n", + " -0.021640496,\n", + " 0.00099529,\n", + " -0.0011307093,\n", + " 0.008221528,\n", + " 0.021148667,\n", + " -0.0040276847,\n", + " -0.020736594,\n", + " -0.0011664333,\n", + " 0.0033547422,\n", + " 0.0023411748,\n", + " 0.010647443,\n", + " 0.0064037526,\n", + " -0.0029692543,\n", + " -0.010115735,\n", + " -0.0358105,\n", + " -0.011823846,\n", + " 0.018091349,\n", + " 0.024591474,\n", + " 0.03392294,\n", + " 0.005931862,\n", + " 0.002837989,\n", + " -0.014754884,\n", + " -0.004290215,\n", + " -0.02314257,\n", + " 0.004250337,\n", + " 0.017293787,\n", + " 0.023302082,\n", + " -0.007018539,\n", + " 0.024697814,\n", + " 0.0359966,\n", + " 0.0034826843,\n", + " 0.017094398,\n", + " 0.01874269,\n", + " -0.013345859,\n", + " -0.005792289,\n", + " -0.023262205,\n", + " 0.00011111856,\n", + " 0.0043799407,\n", + " 0.04554075,\n", + " 0.013625005,\n", + " 0.010680675,\n", + " 0.01596452,\n", + " 0.0004980604,\n", + " -0.01977952,\n", + " -0.012528359,\n", + " -0.0292705,\n", + " 0.0030373794,\n", + " -0.033497576,\n", + " -0.017386837,\n", + " -0.018370494,\n", + " -0.003748538,\n", + " 0.006121283,\n", + " -0.014675127,\n", + " 0.020178301,\n", + " -0.010813602,\n", + " 0.0078161005,\n", + " 0.021667082,\n", + " -0.0247244,\n", + " 0.014874518,\n", + " 0.014940982,\n", + " -0.01612403,\n", + " 0.009949577,\n", + " 0.0021683697,\n", + " -0.024897205,\n", + " -0.02857928,\n", + " 0.0055098194,\n", + " -0.0066529904,\n", + " 0.009936284,\n", + " 0.007809454,\n", + " 0.014449152,\n", + " -0.002356129,\n", + " -0.01765269,\n", + " -0.013864274,\n", + " -0.0252694,\n", + " -0.021427814,\n", + " -0.027861474,\n", + " -0.009650491,\n", + " -0.002857928,\n", + " 0.0068125026,\n", + " 0.011484883,\n", + " -0.010109089,\n", + " 0.0049282643,\n", + " 0.0152467135,\n", + " 0.001224589,\n", + " -0.003419544,\n", + " -0.0055131423,\n", + " -0.02546879,\n", + " 0.01849013,\n", + " 0.010534455,\n", + " 0.02903123,\n", + " 0.011883663,\n", + " 0.004805307,\n", + " 0.032434158,\n", + " -0.0014106865,\n", + " -0.0058089048,\n", + " 0.029456597,\n", + " 0.0029293762,\n", + " 0.03312538,\n", + " 0.0059650936,\n", + " -0.007596771,\n", + " -0.0006916352,\n", + " -0.0070251855,\n", + " 0.011823846,\n", + " 0.016150616,\n", + " 0.036528308,\n", + " 0.0006737731,\n", + " -0.022411473,\n", + " 0.002384376,\n", + " 0.011624455,\n", + " -0.0057789963,\n", + " -0.09049662,\n", + " 0.008733296,\n", + " -0.016084153,\n", + " 0.01354525,\n", + " -0.0040476234,\n", + " 0.022703912,\n", + " 0.0077164057,\n", + " -0.0007983921,\n", + " -0.01065409,\n", + " 0.017572934,\n", + " 0.00838104,\n", + " -0.046258554,\n", + " 0.002974239,\n", + " -0.008832991,\n", + " 0.02788806,\n", + " -0.042669527,\n", + " -0.016921593,\n", + " -3.378342e-06,\n", + " 0.01577842,\n", + " 0.011405126,\n", + " 0.0037219527,\n", + " -0.0014040401,\n", + " 0.006739393,\n", + " -0.019792812,\n", + " 0.014329518,\n", + " 0.017705861,\n", + " -0.035066113,\n", + " 0.009683724,\n", + " 0.01641647,\n", + " -0.0047986605,\n", + " -0.005157563,\n", + " -0.024897205,\n", + " -5.794781e-05,\n", + " 0.0011730797,\n", + " -0.0013907475,\n", + " 0.010095797,\n", + " -0.017971715,\n", + " 0.004466343,\n", + " 0.03525221,\n", + " -0.024405375,\n", + " 0.0033148641,\n", + " 0.0034594222,\n", + " 0.0019158087,\n", + " -0.017293787,\n", + " -0.0063140267,\n", + " -0.01518025,\n", + " -0.0098631745,\n", + " 0.029509768,\n", + " 0.02655879,\n", + " -0.025920741,\n", + " -0.04157953,\n", + " -0.010374943,\n", + " -0.01572525,\n", + " 0.003592349,\n", + " 0.040090747,\n", + " 0.00714482,\n", + " 0.008972565,\n", + " 0.0035491476,\n", + " 0.0061744535,\n", + " 0.01725391,\n", + " 0.0013259456,\n", + " -0.020949276,\n", + " -0.017027933,\n", + " 0.02170696,\n", + " 0.011498176,\n", + " -0.0069188443,\n", + " -0.016708909,\n", + " 0.011012992,\n", + " 0.009670431,\n", + " -0.02358123,\n", + " -0.00080919237,\n", + " 0.021241715,\n", + " -0.015193542,\n", + " 0.00059983257,\n", + " -0.020882813,\n", + " 0.017692568,\n", + " -0.011930187,\n", + " -0.00610799,\n", + " 0.025136473,\n", + " -0.025189644,\n", + " 0.015060616,\n", + " -0.0110927485,\n", + " 0.023660986,\n", + " -0.015512567,\n", + " 0.03150367,\n", + " 0.018849032,\n", + " 0.008786467,\n", + " 0.014901103,\n", + " 0.018981958,\n", + " -0.010022687,\n", + " 0.006217655,\n", + " -0.006510094,\n", + " -0.0006031557,\n", + " -0.018476836,\n", + " -0.009657138,\n", + " 0.030918792,\n", + " -0.019513667,\n", + " -0.02121513,\n", + " -0.008487381,\n", + " 0.0015668756,\n", + " -0.0062442403,\n", + " 0.013226225,\n", + " -0.06710149,\n", + " 0.001894208,\n", + " 0.0056626853,\n", + " -0.0020653515,\n", + " 0.008666833,\n", + " -0.013837689,\n", + " 0.020404276,\n", + " -0.025987206,\n", + " 0.0029759007,\n", + " -0.0048252456,\n", + " -0.00037261067,\n", + " -0.00080171524,\n", + " -0.012701164,\n", + " 0.012501773,\n", + " -0.014940982,\n", + " -0.009849882,\n", + " 0.015831592,\n", + " -0.0046125627,\n", + " 0.007862625,\n", + " -0.0018676227,\n", + " 0.0036554893,\n", + " -0.0024541626,\n", + " 0.0062508867,\n", + " -0.0059152464,\n", + " 0.013512017,\n", + " 0.00996287,\n", + " -0.00480863,\n", + " 0.023594521,\n", + " -0.024817448,\n", + " -0.01810464,\n", + " 0.01310659,\n", + " -0.03001489,\n", + " 0.008633601,\n", + " -0.0034693917,\n", + " 0.0059418315,\n", + " -0.032115135,\n", + " -0.014356103,\n", + " 0.0065233866,\n", + " 0.012800858,\n", + " 0.060667828,\n", + " -0.017958421,\n", + " -0.019806106,\n", + " 0.010029334,\n", + " -0.01958013,\n", + " -0.009643845,\n", + " 0.016536104,\n", + " 0.0048185997,\n", + " 0.007470491,\n", + " 0.020603666,\n", + " -0.0066031427,\n", + " 0.022757081,\n", + " 0.017891958,\n", + " -0.033205137,\n", + " 0.005872045,\n", + " -0.008221528,\n", + " -0.034401476,\n", + " 0.02725001,\n", + " 0.015459396,\n", + " -0.027994402,\n", + " -0.013312628,\n", + " 0.028366597,\n", + " 0.01879586,\n", + " 0.028845133,\n", + " -0.010016041,\n", + " 0.003223477,\n", + " 0.0063239965,\n", + " 0.0075037223,\n", + " -0.011238968,\n", + " -0.0083411615,\n", + " -0.046604164,\n", + " 0.017120982,\n", + " -0.015565738,\n", + " 0.0029991628,\n", + " 0.014050371,\n", + " -0.0047089346,\n", + " 0.012036529,\n", + " 0.0059218924,\n", + " -0.009417869,\n", + " -0.019766226,\n", + " 0.0115048215,\n", + " 0.0091586625,\n", + " -0.032035377,\n", + " -0.025428912,\n", + " 0.0108003095,\n", + " 0.029589524,\n", + " 0.013206285,\n", + " 0.007497076,\n", + " 0.019992203,\n", + " -0.00039524978,\n", + " -0.00046275172,\n", + " -0.00459927,\n", + " 0.012116285,\n", + " 0.006240917,\n", + " -0.025295986,\n", + " -0.011611163,\n", + " 0.025814401,\n", + " -0.020683423,\n", + " 0.015858177,\n", + " 0.037033428,\n", + " 0.0021251685,\n", + " 0.017134275,\n", + " -0.004948203,\n", + " 0.00068125024,\n", + " -0.016243665,\n", + " -0.018516714,\n", + " 0.015007445,\n", + " -0.018755984,\n", + " -0.014528908,\n", + " -0.010261956,\n", + " 0.024046473,\n", + " 0.014741591,\n", + " 0.032061964,\n", + " 0.0021567387,\n", + " 0.003323172,\n", + " -0.0071581127,\n", + " 0.013930737,\n", + " -0.008081954,\n", + " -0.016708909,\n", + " -0.02239818,\n", + " 0.047029532,\n", + " 0.005350307,\n", + " 0.02630623,\n", + " -0.012422017,\n", + " -0.03450782,\n", + " 0.02195952,\n", + " 0.005024636,\n", + " 0.022504522,\n", + " -0.018875618,\n", + " -0.0028878364,\n", + " -0.022690618,\n", + " 0.0036853978,\n", + " -0.02674489,\n", + " -0.030440256,\n", + " 0.002572135,\n", + " -0.027914645,\n", + " -0.0056959167,\n", + " -0.042935383,\n", + " 0.021029033,\n", + " -0.028659036,\n", + " 0.034481235,\n", + " 0.010647443,\n", + " -0.0024907175,\n", + " 0.02561501,\n", + " -0.018955374,\n", + " 0.023381839,\n", + " 0.010374943,\n", + " 0.008939332,\n", + " -0.0107404925,\n", + " -0.018623056,\n", + " 0.014940982,\n", + " -0.0049914042,\n", + " 0.0025472115,\n", + " -0.006878966,\n", + " -0.010487931,\n", + " 0.013983908,\n", + " 5.5922756e-05,\n", + " 0.0054034777,\n", + " -0.02176013,\n", + " -0.0076034176,\n", + " 0.025801107,\n", + " 0.0023212356,\n", + " 0.02452501,\n", + " -0.004572685,\n", + " -0.023660986,\n", + " -0.009132077,\n", + " 0.0060016485,\n", + " 0.021720253,\n", + " -0.005257258,\n", + " -0.008879515,\n", + " -0.0066297282,\n", + " -0.0037319222,\n", + " -0.018463545,\n", + " -0.01016226,\n", + " -0.011305431,\n", + " 0.016110739,\n", + " 0.004828569,\n", + " -0.014582079,\n", + " 0.009949577,\n", + " 0.008141772,\n", + " -0.007011893,\n", + " 0.020165008,\n", + " -0.019247813,\n", + " -0.02679806,\n", + " 0.01065409,\n", + " -0.00074605213,\n", + " -0.0041041174,\n", + " -0.0035391783,\n", + " -0.009251711\n", + " ]\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd8319\"\n", + " },\n", + " \"plot\": \"An irresponsible youn\",\n", + " \"genres\": [\n", + " \"Action\",\n", + " \"Comedy\",\n", + " \"Romance\"\n", + " ],\n", + " \"runtime\": 58,\n", + " \"rated\": \"PASSED\",\n", + " \"cast\": [\n", + " \"Harold Lloyd\",\n", + " \"Jobyna Ralston\",\n", + " \"Noah Young\",\n", + " \"Jim Mason\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"For Heaven's Sake\",\n", + " \"fullplot\": \"The Uptown Boy, J. Ha\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1380412800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Sam Taylor\"\n", + " ],\n", + " \"writers\": [\n", + " \"Ted Wilde (story)\",\n", + " \"John Grey (story)\",\n", + " \"Clyde Bruckman (story\",\n", + " \"Ralph Spence (titles)\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 0,\n", + " \"nominations\": 1,\n", + " \"text\": \"1 nomination.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-19 00:35:01.9\",\n", + " \"year\": 1926,\n", + " \"imdb\": {\n", + " \"rating\": 7.6,\n", + " \"votes\": 918,\n", + " \"id\": 16895\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 87,\n", + " \"meter\": 92\n", + " },\n", + " \"production\": \"Paramount Studios\",\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-07-06T18:07:59Z\"\n", + " }\n", + " },\n", + " \"plot_embedding\": [\n", + " -0.0059373598,\n", + " -0.026604708,\n", + " -0.0070914757,\n", + " -0.015490505,\n", + " -0.009052806,\n", + " 0.019920176,\n", + " 0.0014401432,\n", + " -0.00025558998,\n", + " -0.020253735,\n", + " -0.013175601,\n", + " 0.021828135,\n", + " 0.030073727,\n", + " 0.0011924753,\n", + " 0.0011057499,\n", + " 0.01008684,\n", + " -0.019746725,\n", + " 0.03861285,\n", + " -0.021281097,\n", + " 0.013242314,\n", + " -0.024469927,\n", + " -0.018158982,\n", + " -0.012308347,\n", + " -0.0055170744,\n", + " -0.019973544,\n", + " 0.0027835544,\n", + " -0.00812551,\n", + " 0.0008797633,\n", + " -0.015210315,\n", + " 0.0031671477,\n", + " 0.008432385,\n", + " 0.004426335,\n", + " -0.015517189,\n", + " 0.012014815,\n", + " -0.019146318,\n", + " -0.017171644,\n", + " -0.022255091,\n", + " -0.0067545804,\n", + " -0.0017361774,\n", + " 0.00087225816,\n", + " -0.00088977005,\n", + " 0.010693919,\n", + " -0.015530531,\n", + " -0.011594529,\n", + " -0.015090233,\n", + " -0.004326267,\n", + " 0.011040821,\n", + " -0.0035290597,\n", + " -0.021321125,\n", + " -0.04370964,\n", + " 0.0025483947,\n", + " 0.024843514,\n", + " 0.014716647,\n", + " 0.013742653,\n", + " 0.016357759,\n", + " -0.008839328,\n", + " 0.018665992,\n", + " -0.006801279,\n", + " 0.012701947,\n", + " -0.01226832,\n", + " 0.009312982,\n", + " 0.017758708,\n", + " -0.0011958109,\n", + " -0.0065144175,\n", + " -0.012695275,\n", + " -0.017998872,\n", + " 0.014062869,\n", + " -0.010900726,\n", + " 0.011220942,\n", + " -0.018892812,\n", + " -0.004433006,\n", + " 0.0376522,\n", + " 0.010733945,\n", + " 0.0011165906,\n", + " -0.015917461,\n", + " 0.009393036,\n", + " -0.0045897793,\n", + " -0.029006336,\n", + " 0.0043863077,\n", + " -0.007531774,\n", + " 0.019573273,\n", + " 0.01495681,\n", + " -0.018665992,\n", + " -0.02112099,\n", + " 0.030047042,\n", + " 0.007838649,\n", + " 0.008272276,\n", + " -0.0046598264,\n", + " 0.03653144,\n", + " -0.00957983,\n", + " -0.0047098603,\n", + " 0.006314282,\n", + " 0.017758708,\n", + " 0.014316375,\n", + " 0.017451834,\n", + " 0.010967437,\n", + " -0.005383651,\n", + " -0.0053669726,\n", + " -0.00058664783,\n", + " -0.0033689511,\n", + " 0.0018429164,\n", + " -0.010500454,\n", + " 0.007878676,\n", + " 0.0068279635,\n", + " -0.0047765723,\n", + " -0.01272196,\n", + " -0.010013457,\n", + " 0.023229085,\n", + " -0.008866012,\n", + " 0.011894733,\n", + " -0.014476484,\n", + " 0.00078511576,\n", + " -0.0015377094,\n", + " 0.013122232,\n", + " -0.03463682,\n", + " 0.005290254,\n", + " -0.008172208,\n", + " 0.007038106,\n", + " -0.00451306,\n", + " 0.02022705,\n", + " -0.014102897,\n", + " 0.005877319,\n", + " 0.024403214,\n", + " 0.0028902933,\n", + " -0.00087892934,\n", + " 0.010507125,\n", + " 0.010860698,\n", + " -0.012948781,\n", + " -0.02280213,\n", + " -0.00081388524,\n", + " -0.0021064284,\n", + " 0.029566716,\n", + " 0.0021948216,\n", + " 0.0128553845,\n", + " 0.013742653,\n", + " -0.0320484,\n", + " 0.016237678,\n", + " -0.031594757,\n", + " 0.010327003,\n", + " -0.030153781,\n", + " -0.043389425,\n", + " 0.0054703765,\n", + " 0.021561287,\n", + " -0.021161016,\n", + " 0.013769337,\n", + " 0.012828699,\n", + " -0.001203316,\n", + " 0.002820246,\n", + " 0.009566487,\n", + " 0.025790824,\n", + " -0.023295797,\n", + " 0.0129754655,\n", + " -0.014783358,\n", + " 0.014049527,\n", + " -0.026044328,\n", + " 0.0110074645,\n", + " 0.030847585,\n", + " 0.004696518,\n", + " 0.00918623,\n", + " -0.008839328,\n", + " 0.017331753,\n", + " 0.004032735,\n", + " 0.029513348,\n", + " -0.0011532821,\n", + " -0.0028952968,\n", + " 0.011734624,\n", + " 0.031701498,\n", + " -0.010587179,\n", + " 0.025630714,\n", + " 0.017745366,\n", + " -0.0188261,\n", + " -0.0048666336,\n", + " 0.023722753,\n", + " -0.039119862,\n", + " 0.013889419,\n", + " 0.015503847,\n", + " 0.02342922,\n", + " 0.0094063785,\n", + " 0.007645184,\n", + " -0.028285848,\n", + " -0.0074116928,\n", + " -0.010974108,\n", + " 0.020827457,\n", + " 0.024563324,\n", + " 0.04611127,\n", + " -0.007912032,\n", + " 0.011921418,\n", + " -0.0064243567,\n", + " -0.008218907,\n", + " 0.00649774,\n", + " -0.000375046,\n", + " -0.011334353,\n", + " 0.019639986,\n", + " -0.01059385,\n", + " -0.010046813,\n", + " -0.6741638,\n", + " -0.013889419,\n", + " -0.024670063,\n", + " 0.010380372,\n", + " -0.003915989,\n", + " 0.01434306,\n", + " 0.019213028,\n", + " 0.0188261,\n", + " -0.009086162,\n", + " 0.004236206,\n", + " 0.006998079,\n", + " 0.024803486,\n", + " -0.0244299,\n", + " -0.009759951,\n", + " -0.0074116928,\n", + " -0.012915425,\n", + " 0.012288333,\n", + " -0.04162823,\n", + " -0.008452399,\n", + " 0.012848713,\n", + " 0.0034823616,\n", + " 0.030447314,\n", + " -0.0009164548,\n", + " -0.031194488,\n", + " 0.011781323,\n", + " 0.013295683,\n", + " 0.0049600303,\n", + " -0.009319653,\n", + " -0.009673227,\n", + " -0.009226257,\n", + " -0.0028702798,\n", + " 0.034369975,\n", + " -0.001029865,\n", + " 0.032421988,\n", + " 0.06302941,\n", + " -0.0030387272,\n", + " 0.007945388,\n", + " 0.009259612,\n", + " 0.011027478,\n", + " 0.00806547,\n", + " -0.03775894,\n", + " -0.01805224,\n", + " 0.003915989,\n", + " -0.00963987,\n", + " -0.012141567,\n", + " -0.019453192,\n", + " 0.011027478,\n", + " -0.010080169,\n", + " 0.008525781,\n", + " 0.009386365,\n", + " 0.0023199066,\n", + " 0.020787429,\n", + " -0.014676619,\n", + " -0.008252263,\n", + " 0.009019449,\n", + " -0.010013457,\n", + " 0.026658077,\n", + " -0.0012300008,\n", + " -0.012208278,\n", + " -0.011227613,\n", + " -0.023455907,\n", + " 0.002068069,\n", + " 0.0002966595,\n", + " 7.598903e-05,\n", + " -5.762371e-06,\n", + " 0.026017644,\n", + " 0.0041461447,\n", + " 0.034903668,\n", + " 0.017611943,\n", + " -0.030900955,\n", + " -0.0039660227,\n", + " 0.010080169,\n", + " -0.0017378451,\n", + " 0.0077519235,\n", + " 0.008198894,\n", + " 0.0009414718,\n", + " 0.02264202,\n", + " 0.019626644,\n", + " -0.009966759,\n", + " -0.0029286526,\n", + " 0.003092097,\n", + " -0.015490505,\n", + " -0.038292635,\n", + " -0.0008705904,\n", + " 0.014383087,\n", + " -0.030100413,\n", + " -0.022201722,\n", + " 0.002126442,\n", + " -0.0015201976,\n", + " -0.032715518,\n", + " -0.012154909,\n", + " 0.023562646,\n", + " -0.014142924,\n", + " -0.012935438,\n", + " 0.0028619408,\n", + " 0.013115561,\n", + " -0.00022556963,\n", + " 0.030527368,\n", + " 0.0096532125,\n", + " -0.033862963,\n", + " 0.0107606305,\n", + " -0.00739835,\n", + " 0.0072782687,\n", + " 0.00636098,\n", + " 0.007831978,\n", + " -0.018505882,\n", + " -0.0144497985,\n", + " 0.009052806,\n", + " 0.033302583,\n", + " -0.0105137965,\n", + " 0.005860641,\n", + " -0.0049166675,\n", + " -0.012908754,\n", + " -0.01798553,\n", + " -0.035997745,\n", + " -0.027592044,\n", + " 0.013515832,\n", + " 0.01765197,\n", + " 0.028445957,\n", + " -0.017278384,\n", + " -0.020947538,\n", + " 0.01994686,\n", + " -0.0004229952,\n", + " 0.0080587985,\n", + " -0.027752154,\n", + " 0.012915425,\n", + " -0.0060874615,\n", + " -0.0029703476,\n", + " 0.0021030928,\n", + " -0.0033572766,\n", + " 0.005497061,\n", + " -0.0014509839,\n", + " 0.019840121,\n", + " -0.017024878,\n", + " 0.029273184,\n", + " -0.0007509259,\n", + " -0.002183147,\n", + " -0.014810043,\n", + " 0.008812643,\n", + " -0.010053484,\n", + " -0.02073406,\n", + " 0.0010965769,\n", + " 0.01714496,\n", + " 0.0025734117,\n", + " 0.0041094534,\n", + " -0.025884219,\n", + " -0.020387158,\n", + " -0.014316375,\n", + " -0.032395303,\n", + " 0.023455907,\n", + " -0.015477162,\n", + " -0.0092862975,\n", + " -0.0030604086,\n", + " 0.01809227,\n", + " 0.011507804,\n", + " 0.0023565982,\n", + " -0.010780644,\n", + " -0.000424246,\n", + " -0.017064905,\n", + " -0.020974223,\n", + " 0.009786637,\n", + " 0.021921532,\n", + " -0.035037093,\n", + " 0.013969473,\n", + " 0.004469698,\n", + " -0.0046431487,\n", + " 0.014556537,\n", + " 0.025217101,\n", + " 0.011027478,\n", + " -0.006991408,\n", + " 0.002406632,\n", + " -0.020120312,\n", + " -0.0054937257,\n", + " 0.035757583,\n", + " 0.0016836417,\n", + " -0.0071848724,\n", + " -0.0066811973,\n", + " 0.00063834956,\n", + " -0.009446406,\n", + " 0.008592494,\n", + " 0.0021864828,\n", + " -0.0063776583,\n", + " -0.014689961,\n", + " -0.0047098603,\n", + " 0.024576666,\n", + " 0.0029203137,\n", + " 0.008298961,\n", + " 0.019306425,\n", + " 0.004606457,\n", + " 0.025977615,\n", + " -0.014863413,\n", + " 0.020894168,\n", + " 0.024069656,\n", + " -0.017104933,\n", + " 0.009626528,\n", + " 0.00683797,\n", + " 0.031007694,\n", + " 0.009880033,\n", + " -0.016264362,\n", + " 0.025056992,\n", + " 0.0006958886,\n", + " -0.0041761654,\n", + " 0.025897563,\n", + " -0.018065585,\n", + " 0.002101425,\n", + " -0.03234193,\n", + " 0.010733945,\n", + " -0.01590412,\n", + " 0.0148233855,\n", + " -0.0008672548,\n", + " 0.010080169,\n", + " 0.008272276,\n", + " -0.00652776,\n", + " -0.011154231,\n", + " 0.021881506,\n", + " 0.0134691335,\n", + " 0.0046631624,\n", + " 0.018412486,\n", + " -0.004433006,\n", + " 0.0029820222,\n", + " -0.008245592,\n", + " -0.0005432851,\n", + " 0.00969324,\n", + " -0.0025533983,\n", + " -0.010894055,\n", + " -0.003418985,\n", + " 0.0061508375,\n", + " -0.014209636,\n", + " 0.0067412383,\n", + " -0.008152195,\n", + " -0.012254977,\n", + " -0.0041661584,\n", + " 0.014436456,\n", + " 0.017305069,\n", + " -0.020707376,\n", + " -0.03810584,\n", + " 0.00756513,\n", + " -0.02302895,\n", + " 0.012581865,\n", + " -0.01316893,\n", + " 0.006601143,\n", + " 0.009046135,\n", + " 0.012922096,\n", + " -0.009292969,\n", + " -0.023922889,\n", + " -0.0116278855,\n", + " 0.023909546,\n", + " 0.017385123,\n", + " 0.001104082,\n", + " 0.0077786082,\n", + " -0.02756536,\n", + " 0.019453192,\n", + " 0.0016919808,\n", + " -0.0052068643,\n", + " -0.0008143022,\n", + " -0.029059706,\n", + " 0.0055571017,\n", + " -0.0019263063,\n", + " 0.035650842,\n", + " 0.01994686,\n", + " -0.019733382,\n", + " 0.019253056,\n", + " -0.0016010858,\n", + " 0.009112846,\n", + " 0.03226188,\n", + " 0.0053102677,\n", + " 0.019720038,\n", + " 0.006320953,\n", + " -0.019813435,\n", + " -0.0037992431,\n", + " 0.012134896,\n", + " -0.00417283,\n", + " 0.010507125,\n", + " -0.018078927,\n", + " -0.009219585,\n", + " -0.004222864,\n", + " -0.0034690192,\n", + " -0.009733267,\n", + " 0.01922637,\n", + " -0.008939396,\n", + " 0.006017414,\n", + " -0.015877433,\n", + " 0.032288563,\n", + " 0.01142775,\n", + " -0.0019246385,\n", + " -0.019933518,\n", + " 0.0056671766,\n", + " 0.008172208,\n", + " 0.011067505,\n", + " 0.023442565,\n", + " 0.005306932,\n", + " 0.0077452525,\n", + " -0.0131022185,\n", + " 0.0061308243,\n", + " -1.2273948e-05,\n", + " -0.011474447,\n", + " 0.018505882,\n", + " -0.013155588,\n", + " 0.022268435,\n", + " -0.044963825,\n", + " 0.022201722,\n", + " 0.001714496,\n", + " -0.020987565,\n", + " -0.02583085,\n", + " 0.024136368,\n", + " 0.017772052,\n", + " 0.01244177,\n", + " -0.008212236,\n", + " -0.0062242206,\n", + " -0.023189059,\n", + " 0.00089060393,\n", + " -0.015944146,\n", + " -0.026698105,\n", + " -0.0053369524,\n", + " -0.0076585268,\n", + " -0.0048799757,\n", + " -0.013662598,\n", + " -0.0063910005,\n", + " -0.0014810043,\n", + " 4.6672274e-05,\n", + " -0.01546382,\n", + " -0.003982701,\n", + " -0.02577748,\n", + " 0.007391679,\n", + " 0.15647945,\n", + " 0.022228407,\n", + " 0.02672479,\n", + " 0.010206922,\n", + " 0.010940753,\n", + " -0.013889419,\n", + " -0.011894733,\n", + " -0.025790824,\n", + " 0.008479083,\n", + " 0.004819935,\n", + " 0.03132791,\n", + " -0.02213501,\n", + " -0.007858663,\n", + " 0.011014136,\n", + " 0.0053369524,\n", + " -0.0047031892,\n", + " 0.015050206,\n", + " -0.019920176,\n", + " 0.0052535627,\n", + " -0.042055186,\n", + " 0.0033305918,\n", + " 0.009539803,\n", + " 0.018158982,\n", + " 0.012895412,\n", + " -0.020760745,\n", + " -0.02213501,\n", + " 0.019346453,\n", + " 0.013889419,\n", + " -0.008045455,\n", + " 0.0035957717,\n", + " -0.001128265,\n", + " -0.0057372237,\n", + " -0.0027485306,\n", + " 0.022068297,\n", + " 0.009433064,\n", + " -0.0054770475,\n", + " -0.0050467555,\n", + " -0.018906154,\n", + " 0.045257356,\n", + " 0.0058406275,\n", + " 0.042508826,\n", + " -0.0043562874,\n", + " 0.007698554,\n", + " -0.003619121,\n", + " 0.0049667014,\n", + " -0.012468455,\n", + " -0.013048849,\n", + " 0.022201722,\n", + " -0.0004657325,\n", + " -0.037358668,\n", + " 0.04779241,\n", + " 0.017225014,\n", + " -0.0015860755,\n", + " -0.014076212,\n", + " 0.02544392,\n", + " -0.006911353,\n", + " 0.017278384,\n", + " -0.006764587,\n", + " -0.018679334,\n", + " 0.05171507,\n", + " -0.008412371,\n", + " -0.03901312,\n", + " 0.0068446416,\n", + " -0.005216871,\n", + " 0.009960088,\n", + " -0.026978295,\n", + " -0.01310889,\n", + " 0.004936681,\n", + " 0.0025267135,\n", + " -0.011120874,\n", + " 0.02101425,\n", + " -0.034476712,\n", + " -0.016010858,\n", + " -0.0057905936,\n", + " 0.009786637,\n", + " 0.030847585,\n", + " 0.005103461,\n", + " -0.005246891,\n", + " 0.0025000286,\n", + " 0.013509161,\n", + " 0.005523746,\n", + " -0.014182951,\n", + " -0.004346281,\n", + " -0.002373276,\n", + " -0.013809364,\n", + " 0.018199008,\n", + " -0.00680795,\n", + " -0.0013125568,\n", + " -0.014169609,\n", + " 0.012688604,\n", + " 0.0022148353,\n", + " 0.010140209,\n", + " 0.007211557,\n", + " -0.010787315,\n", + " -0.010206922,\n", + " -0.0086725475,\n", + " 0.009339667,\n", + " 0.0055504306,\n", + " -0.020667348,\n", + " 0.013996158,\n", + " 0.009079491,\n", + " -0.013982816,\n", + " -0.017812079,\n", + " 0.008379015,\n", + " 0.007925374,\n", + " -0.0047365455,\n", + " -0.0034323276,\n", + " 0.007972073,\n", + " -0.00863252,\n", + " -0.002456666,\n", + " -0.0017712011,\n", + " -0.019933518,\n", + " -0.014729989,\n", + " 0.01148779,\n", + " 0.001516862,\n", + " 0.0168114,\n", + " 0.02611104,\n", + " 0.03042063,\n", + " 0.011227613,\n", + " -0.0045864433,\n", + " -0.017064905,\n", + " -0.0026734797,\n", + " 0.03938671,\n", + " 0.04712529,\n", + " -0.00717153,\n", + " -0.01714496,\n", + " 0.011107532,\n", + " -0.033409324,\n", + " 0.00834566,\n", + " -0.0030053714,\n", + " -0.0010448752,\n", + " 0.0097799655,\n", + " -0.0040260637,\n", + " -0.033943016,\n", + " -0.025910905,\n", + " -0.0067846007,\n", + " 0.00063418003,\n", + " -0.009619857,\n", + " -0.013769337,\n", + " -0.016798059,\n", + " -0.0042995824,\n", + " -0.0006175021,\n", + " -0.009633199,\n", + " -0.028365903,\n", + " 0.01305552,\n", + " -0.031221172,\n", + " -0.0051868507,\n", + " -0.00030124595,\n", + " -0.010140209,\n", + " 0.029513348,\n", + " 0.0014309704,\n", + " -0.0018412486,\n", + " -0.02717843,\n", + " 0.012141567,\n", + " 0.015717326,\n", + " -0.03378291,\n", + " 0.0027702118,\n", + " -0.014436456,\n", + " 0.013655927,\n", + " -0.0021981574,\n", + " 0.024830172,\n", + " -0.0021714724,\n", + " 0.037945732,\n", + " -0.00196133,\n", + " 0.004392979,\n", + " 0.004426335,\n", + " 0.011314339,\n", + " 0.0010590515,\n", + " -0.032982368,\n", + " 0.040560838,\n", + " 0.022682048,\n", + " 0.012148238,\n", + " 0.026471283,\n", + " 0.003322253,\n", + " -0.014543195,\n", + " 0.0119881295,\n", + " 0.0046865116,\n", + " -0.019546589,\n", + " -0.0204005,\n", + " -0.015330396,\n", + " -0.014890097,\n", + " -0.01165457,\n", + " -0.028339218,\n", + " -0.01590412,\n", + " -0.016277704,\n", + " -0.010246948,\n", + " 0.039306656,\n", + " -0.019333111,\n", + " 0.013235642,\n", + " 0.0072982823,\n", + " 0.025884219,\n", + " -0.012528496,\n", + " 0.014396429,\n", + " -0.003223853,\n", + " -0.0047932505,\n", + " 0.007992086,\n", + " -0.013322367,\n", + " -0.0047565587,\n", + " -0.0014159601,\n", + " 0.008986094,\n", + " -0.010206922,\n", + " -0.0017845435,\n", + " -0.0022732082,\n", + " 0.0040927753,\n", + " 0.003609114,\n", + " 0.040881056,\n", + " 0.014249663,\n", + " -0.029833565,\n", + " 0.019333111,\n", + " -0.013495819,\n", + " -0.0013309026,\n", + " -0.033329267,\n", + " -0.020440528,\n", + " -0.050167352,\n", + " 0.001433472,\n", + " -0.01378268,\n", + " -0.0033372631,\n", + " 0.014116239,\n", + " -0.024683405,\n", + " -0.010580508,\n", + " -0.004639813,\n", + " -0.0065511093,\n", + " 0.0070447773,\n", + " -0.014049527,\n", + " 0.002967012,\n", + " 0.015143602,\n", + " -0.019119631,\n", + " 0.0013133907,\n", + " 0.033142474,\n", + " -0.0027852221,\n", + " -0.0061108107,\n", + " 0.019813435,\n", + " 0.01244177,\n", + " -0.002249859,\n", + " 0.0074116928,\n", + " -0.02567074,\n", + " -0.017024878,\n", + " -0.03570421,\n", + " 0.0048799757,\n", + " 0.0002291137,\n", + " -0.0022381844,\n", + " -0.0031588087,\n", + " -0.009499775,\n", + " -0.018385801,\n", + " 0.00784532,\n", + " 0.025590686,\n", + " 0.0038059142,\n", + " 0.010460427,\n", + " -0.008759273,\n", + " -0.02639123,\n", + " -0.03658481,\n", + " -0.004112789,\n", + " 0.020627322,\n", + " 0.003946009,\n", + " 0.00014885094,\n", + " -0.0020697368,\n", + " 0.019373138,\n", + " -0.018679334,\n", + " -0.007711896,\n", + " 0.0061308243,\n", + " 0.0018779401,\n", + " 0.03501041,\n", + " -0.0054603694,\n", + " 0.00023661878,\n", + " 0.0008822649,\n", + " -0.02560403,\n", + " -0.02229512,\n", + " -0.00232491,\n", + " 0.0062675835,\n", + " 0.021961559,\n", + " 0.0053202743,\n", + " 0.013002151,\n", + " 0.013355724,\n", + " -0.0037992431,\n", + " 0.002580083,\n", + " 0.0052435556,\n", + " 0.0028035678,\n", + " -0.027992316,\n", + " -0.023095662,\n", + " -0.0040093856,\n", + " 0.006047434,\n", + " 0.014743331,\n", + " -0.0008088818,\n", + " 0.00024454083,\n", + " -0.010667234,\n", + " -0.006774594,\n", + " -0.008785958,\n", + " -0.013175601,\n", + " 0.016984852,\n", + " 0.0026734797,\n", + " -0.010020128,\n", + " -0.022868842,\n", + " 0.0058239494,\n", + " -0.0017695333,\n", + " -0.00029478324,\n", + " 0.003899311,\n", + " 0.011794665,\n", + " 0.013355724,\n", + " -0.023109004,\n", + " 0.0061541735,\n", + " -0.023015607,\n", + " -0.002078076,\n", + " -0.023415878,\n", + " 0.027138403,\n", + " 0.008619178,\n", + " 0.01059385,\n", + " 0.0066111498,\n", + " -0.0047432166,\n", + " -0.011567844,\n", + " 0.0054470273,\n", + " -0.008665876,\n", + " -0.0160242,\n", + " -0.01982678,\n", + " -0.0015101908,\n", + " -0.0014659942,\n", + " 0.0056071356,\n", + " 0.002540056,\n", + " -0.02236183,\n", + " -0.010547153,\n", + " 0.014863413,\n", + " 0.0036791617,\n", + " -0.0116212135,\n", + " 0.03653144,\n", + " -0.000552041,\n", + " 0.007865334,\n", + " 0.022895526,\n", + " 0.007318296,\n", + " -0.007711896,\n", + " -0.024776801,\n", + " 0.010073498,\n", + " -0.0104003865,\n", + " 0.02001357,\n", + " 0.00436963,\n", + " 0.0010932414,\n", + " -0.008338988,\n", + " -0.007351652,\n", + " -0.009673227,\n", + " 0.035997745,\n", + " 0.00033084935,\n", + " -0.016771372,\n", + " 0.0077652656,\n", + " 0.015784036,\n", + " 0.018519225,\n", + " 0.007838649,\n", + " 0.015250342,\n", + " 0.016317733,\n", + " -0.0065077464,\n", + " -0.004112789,\n", + " -0.028766174,\n", + " -0.0059974003,\n", + " -0.0036658193,\n", + " 0.03210177,\n", + " 0.012701947,\n", + " -0.03076753,\n", + " -0.014676619,\n", + " 0.034930352,\n", + " -0.04515062,\n", + " -0.008399029,\n", + " -0.006964723,\n", + " 0.00093730225,\n", + " 0.03474356,\n", + " -0.023015607,\n", + " -0.0046464843,\n", + " 0.02297558,\n", + " 0.0062842616,\n", + " 0.028045686,\n", + " -0.020547267,\n", + " -0.010493782,\n", + " 0.018732702,\n", + " 0.0021297776,\n", + " 0.013075533,\n", + " 0.008872683,\n", + " -0.017278384,\n", + " -0.003403975,\n", + " 0.004963366,\n", + " 0.009433064,\n", + " 0.00032417817,\n", + " 0.006584465,\n", + " -0.0003923494,\n", + " -0.0009381362,\n", + " -0.006998079,\n", + " 0.0042495485,\n", + " -0.017465176,\n", + " -0.006024085,\n", + " -0.0044296705,\n", + " -0.013849392,\n", + " 0.0023699405,\n", + " 0.00680795,\n", + " 0.005697197,\n", + " 0.0020480554,\n", + " -0.0065244245,\n", + " -0.011661241,\n", + " 0.0014084551,\n", + " 0.0011399396,\n", + " -0.010286976,\n", + " -0.00896608,\n", + " -0.020627322,\n", + " -0.003495704,\n", + " 0.00504342,\n", + " -0.023442565,\n", + " 0.015717326,\n", + " 0.01726504,\n", + " 0.010740616,\n", + " -0.028552696,\n", + " 0.0009648209,\n", + " 0.01966667,\n", + " -0.013422435,\n", + " -0.012154909,\n", + " -0.0029136424,\n", + " -0.013008822,\n", + " 0.013689283,\n", + " -4.0496212e-05,\n", + " 0.002530049,\n", + " -0.012501811,\n", + " 0.01950656,\n", + " 0.0059873937,\n", + " 0.00059123425,\n", + " -0.006354309,\n", + " 0.009419721,\n", + " 0.022094984,\n", + " -0.02807237,\n", + " 0.0019263063,\n", + " -0.018359117,\n", + " 0.010987451,\n", + " -0.040080514,\n", + " -0.03847943,\n", + " 0.031514704,\n", + " -0.010660563,\n", + " -0.009539803,\n", + " -0.005300261,\n", + " -0.01048044,\n", + " -0.012281662,\n", + " 0.0027201779,\n", + " 0.0060641123,\n", + " -0.01675803,\n", + " 0.026044328,\n", + " 0.2378146,\n", + " -6.1604274e-05,\n", + " 0.00033501885,\n", + " 0.027538674,\n", + " -0.018425828,\n", + " 0.02124107,\n", + " 0.023109004,\n", + " 0.0038759618,\n", + " -0.024136368,\n", + " -0.0010065159,\n", + " -0.009953416,\n", + " 0.0025900898,\n", + " 0.010553824,\n", + " 0.0005532919,\n", + " -0.01826572,\n", + " -0.001821235,\n", + " -0.013482477,\n", + " -0.00094230566,\n", + " -0.001566062,\n", + " -0.031728182,\n", + " 0.00012654415,\n", + " 0.0017595266,\n", + " 0.003659148,\n", + " -0.023736097,\n", + " 0.023629356,\n", + " 0.0018812758,\n", + " -0.008492426,\n", + " 0.01625102,\n", + " 0.018706018,\n", + " 0.015650613,\n", + " -0.012668591,\n", + " -0.016451156,\n", + " -0.0013542516,\n", + " -0.0111275455,\n", + " 0.021761423,\n", + " -0.01943985,\n", + " 0.0016602925,\n", + " -0.0052802474,\n", + " 0.012188265,\n", + " 0.01204817,\n", + " 0.03989372,\n", + " 0.015383765,\n", + " -0.00857248,\n", + " -0.009573159,\n", + " -0.00057997665,\n", + " 0.027725467,\n", + " -0.008465741,\n", + " 0.012168252,\n", + " 0.0010698922,\n", + " 0.004019392,\n", + " -0.02157463,\n", + " -0.0073649944,\n", + " 0.01490344,\n", + " 0.01513026,\n", + " -0.008532452,\n", + " 0.015343739,\n", + " -0.00062167156,\n", + " 0.02499028,\n", + " -0.018986208,\n", + " -0.017078249,\n", + " 0.0040293992,\n", + " 0.011681255,\n", + " -0.0016027535,\n", + " 0.011641228,\n", + " -0.012475126,\n", + " 0.018959524,\n", + " -0.0204005,\n", + " 0.0021447877,\n", + " 0.00918623,\n", + " -0.02908639,\n", + " -0.0026467948,\n", + " -0.009886704,\n", + " -0.008232249,\n", + " -0.002695161,\n", + " 0.010580508,\n", + " -0.011521146,\n", + " 0.044003174,\n", + " -0.003625792,\n", + " 0.016731346,\n", + " 0.001079899,\n", + " -0.0010807329,\n", + " 0.016210994,\n", + " 0.0037959074,\n", + " -0.0060274205,\n", + " -0.014689961,\n", + " -0.039813664,\n", + " 0.023936233,\n", + " -0.003115446,\n", + " -0.0138360495,\n", + " -0.0072248993,\n", + " 0.014663277,\n", + " -0.025377208,\n", + " 0.0028836222,\n", + " 0.0006933869,\n", + " -0.0061608446,\n", + " 0.009473091,\n", + " 0.00080596324,\n", + " 0.017305069,\n", + " -0.0042762333,\n", + " -0.0024433236,\n", + " -0.011814678,\n", + " -0.0060807904,\n", + " 0.017958844,\n", + " 0.0019329775,\n", + " -0.016264362,\n", + " -0.0071581877,\n", + " 0.018919496,\n", + " 0.023415878,\n", + " 0.01793216,\n", + " -0.035997745,\n", + " -0.020160338,\n", + " -0.015944146,\n", + " 0.0013951127,\n", + " 0.004869969,\n", + " 0.014436456,\n", + " 0.008805972,\n", + " 0.021361152,\n", + " -0.020667348,\n", + " -0.00588399,\n", + " -0.012695275,\n", + " -0.00918623,\n", + " -0.012681933,\n", + " -0.005400329,\n", + " 0.023669384,\n", + " 0.010773973,\n", + " -0.017812079,\n", + " 0.0025700761,\n", + " 0.009793308,\n", + " 0.0062909327,\n", + " -0.017665312,\n", + " 0.023789465,\n", + " -0.018665992,\n", + " 0.0033255885,\n", + " -0.001664462,\n", + " -0.008866012,\n", + " 0.008338988,\n", + " 0.027645413,\n", + " -0.025283812,\n", + " 0.004019392,\n", + " 0.010240277,\n", + " 0.035544105,\n", + " 0.0047699013,\n", + " 0.012254977,\n", + " -0.006147502,\n", + " -0.012521825,\n", + " -0.015090233,\n", + " 0.027165089,\n", + " 0.0053169387,\n", + " -0.021054277,\n", + " 0.0011165906,\n", + " -0.011507804,\n", + " -0.0043062535,\n", + " 0.022388516,\n", + " -0.018452514,\n", + " 0.0106338775,\n", + " -0.011454434,\n", + " -0.03306242,\n", + " -0.027098376,\n", + " -0.0008455734,\n", + " 0.022068297,\n", + " -0.024509953,\n", + " 0.01109419,\n", + " -0.0007634344,\n", + " -0.017465176,\n", + " 0.003008707,\n", + " 0.005086783,\n", + " -0.17217009,\n", + " 0.014543195,\n", + " 0.020280419,\n", + " -0.014076212,\n", + " 0.041494805,\n", + " -0.0025183745,\n", + " 0.030554052,\n", + " -0.0031504699,\n", + " -0.01737178,\n", + " -0.007665198,\n", + " 0.018425828,\n", + " -0.030127097,\n", + " -0.018959524,\n", + " 0.0017161638,\n", + " 0.0016886451,\n", + " 0.010920739,\n", + " -0.015023521,\n", + " 0.022601994,\n", + " 0.02302895,\n", + " -0.0008972751,\n", + " 0.019626644,\n", + " -0.011234285,\n", + " 0.005930688,\n", + " 0.0076918826,\n", + " 0.0006108309,\n", + " 0.05104795,\n", + " 0.00015927467,\n", + " 0.0032722189,\n", + " -0.00963987,\n", + " -0.009279626,\n", + " -0.017571917,\n", + " -0.022348488,\n", + " 0.013876077,\n", + " 0.008692562,\n", + " 0.03210177,\n", + " 0.003699175,\n", + " -0.0041594873,\n", + " -0.0056271493,\n", + " -0.016210994,\n", + " 0.014876755,\n", + " 0.0029236493,\n", + " 0.017118275,\n", + " 0.015837407,\n", + " 0.0016010858,\n", + " -0.004382972,\n", + " 0.06052104,\n", + " 0.00717153,\n", + " 0.019399822,\n", + " -0.003946009,\n", + " 0.003625792,\n", + " 0.020854142,\n", + " -0.040614206,\n", + " -0.0034756903,\n", + " 0.010693919,\n", + " 0.013916103,\n", + " 0.02022705,\n", + " -0.025283812,\n", + " -0.0009873362,\n", + " 0.004409657,\n", + " -0.015610586,\n", + " -0.013796022,\n", + " 0.012241635,\n", + " 0.02302895,\n", + " 0.0075117606,\n", + " 0.0003850528,\n", + " -0.016237678,\n", + " 0.012862056,\n", + " -0.015824065,\n", + " -0.05635822,\n", + " 0.017171644,\n", + " -0.019706696,\n", + " -0.018279063,\n", + " -0.008072141,\n", + " -0.019479876,\n", + " -0.008525781,\n", + " 0.0028969646,\n", + " -0.008939396,\n", + " 0.022268435,\n", + " -0.00034189853,\n", + " -0.008859341,\n", + " -0.007985415,\n", + " 0.02728517,\n", + " -0.009619857,\n", + " -0.0047131963,\n", + " -0.016264362,\n", + " 0.0103937145,\n", + " 0.0022298454,\n", + " -0.006431028,\n", + " 0.01747852,\n", + " -0.01625102,\n", + " -0.0014943467,\n", + " -0.038639534,\n", + " -0.023696069,\n", + " -0.014489826,\n", + " -0.008245592,\n", + " 0.014756674,\n", + " 0.023175716,\n", + " 0.022068297,\n", + " 0.013022164,\n", + " -0.021454548,\n", + " -0.013982816,\n", + " -0.0033089104,\n", + " -0.007138174,\n", + " 0.008078812,\n", + " 0.016384443,\n", + " 0.015890775,\n", + " 0.038426057,\n", + " 0.007318296,\n", + " 0.010260291,\n", + " -0.02756536,\n", + " -0.010673905,\n", + " 0.006824628,\n", + " 0.009226257,\n", + " 0.008879354,\n", + " 0.004142809,\n", + " 0.0049333456,\n", + " -0.005487054,\n", + " -0.014716647,\n", + " 0.017225014,\n", + " -0.021454548,\n", + " 0.06052104,\n", + " 0.010680576,\n", + " -0.012955452,\n", + " 0.021828135,\n", + " -0.008312304,\n", + " -0.00420285,\n", + " -0.10914068,\n", + " -0.02269539,\n", + " 0.010360359,\n", + " 0.007892018,\n", + " -0.006320953,\n", + " 0.023922889,\n", + " 0.0022198386,\n", + " -0.006801279,\n", + " -0.004352952,\n", + " 0.004409657,\n", + " -0.014383087,\n", + " -0.028259164,\n", + " -0.013982816,\n", + " -0.023549303,\n", + " 0.013702625,\n", + " -0.015757352,\n", + " -0.0057472307,\n", + " -0.016237678,\n", + " -0.02190819,\n", + " 0.014930124,\n", + " -0.0128553845,\n", + " 0.010827342,\n", + " -0.018332431,\n", + " 0.008165537,\n", + " 0.012501811,\n", + " 0.010560495,\n", + " -0.038746275,\n", + " 0.006757916,\n", + " 0.0010940753,\n", + " 0.011774652,\n", + " -0.004296247,\n", + " -0.013942788,\n", + " 0.009179559,\n", + " -0.01597083,\n", + " -0.00885267,\n", + " -0.019546589,\n", + " -0.024790144,\n", + " -0.009573159,\n", + " 0.023215743,\n", + " -0.025537318,\n", + " 0.003832599,\n", + " 0.016064227,\n", + " 0.011447763,\n", + " -0.015250342,\n", + " -0.004956695,\n", + " 0.0025834185,\n", + " -0.013942788,\n", + " 0.009626528,\n", + " 0.020413844,\n", + " -0.0013876077,\n", + " -0.025297154,\n", + " 0.0034990394,\n", + " -0.013809364,\n", + " -0.0056171427,\n", + " 0.022201722,\n", + " -0.002496693,\n", + " 0.0077452525,\n", + " 0.0070447773,\n", + " 0.0011808007,\n", + " 0.0021497912,\n", + " 0.020760745,\n", + " -0.020133654,\n", + " -0.024203079,\n", + " 0.0095331315,\n", + " -0.005710539,\n", + " -0.010473769,\n", + " 0.02280213,\n", + " 0.01272196,\n", + " -0.0031387953,\n", + " -0.034423344,\n", + " -0.02873949,\n", + " 0.0131022185,\n", + " -0.010053484,\n", + " 0.0043362738,\n", + " -0.037518777,\n", + " -0.010507125,\n", + " -0.0070914757,\n", + " -0.02425645,\n", + " 0.019333111,\n", + " -0.01915966,\n", + " -0.0045797722,\n", + " -0.012982137,\n", + " 0.0054103355,\n", + " -0.0010740617,\n", + " 0.016704662,\n", + " 0.015116918,\n", + " -0.009933403,\n", + " 0.01726504,\n", + " -0.011814678,\n", + " 0.0051968573,\n", + " -0.010507125,\n", + " 0.0023766116,\n", + " -0.010560495,\n", + " -0.010073498,\n", + " -0.012688604,\n", + " 0.008992765,\n", + " -0.006971394,\n", + " -0.026164409,\n", + " -0.0046531553,\n", + " -0.0057739154,\n", + " -0.031354595,\n", + " -0.014116239,\n", + " -0.05699865,\n", + " 0.01597083,\n", + " 0.0025934253,\n", + " 0.00845907,\n", + " -0.012528496,\n", + " -0.016237678,\n", + " 0.014756674,\n", + " -0.018532567,\n", + " -0.019559931,\n", + " 0.00024620863,\n", + " 0.0051067965,\n", + " 0.023522617,\n", + " -0.008832656,\n", + " 0.0072916113,\n", + " -0.020747403,\n", + " -0.009059477,\n", + " 0.008338988,\n", + " -0.018185666,\n", + " -0.0025684084,\n", + " 0.007625171,\n", + " -0.018759388,\n", + " -0.03143465,\n", + " 0.005760573,\n", + " 0.0069180247,\n", + " 0.00952646,\n", + " -0.01092741,\n", + " -0.009473091,\n", + " 0.006594472,\n", + " -0.00014165856,\n", + " -0.013755995,\n", + " 0.012688604,\n", + " -0.014516511,\n", + " 0.019733382,\n", + " -0.011240956,\n", + " 0.0043296027,\n", + " -0.0113743795,\n", + " -0.009399707,\n", + " -0.0010423735,\n", + " 0.012655249,\n", + " 0.028872913,\n", + " -0.01899955,\n", + " -0.03132791,\n", + " 0.011781323,\n", + " -0.00588399,\n", + " 0.016197652,\n", + " 0.0059640445,\n", + " -0.028312532,\n", + " -0.012375059,\n", + " 0.038532797,\n", + " -0.004236206,\n", + " 0.017518546,\n", + " 0.01877273,\n", + " -0.017331753,\n", + " -0.018892812,\n", + " -0.029940303,\n", + " -0.020187022,\n", + " 0.018279063,\n", + " -0.0005057596,\n", + " -0.0073649944,\n", + " -0.0077585946,\n", + " 0.00997343,\n", + " 0.00644437,\n", + " 0.003815921,\n", + " 0.0013475805,\n", + " 0.022081641,\n", + " -0.019906832,\n", + " -0.0057305526,\n", + " 0.0055504306,\n", + " 0.013062191,\n", + " -0.02751199,\n", + " -0.010126867,\n", + " -0.009119517,\n", + " 0.012014815,\n", + " 0.031114433,\n", + " -0.014409771,\n", + " 0.021281097,\n", + " 0.0067479094,\n", + " -0.015877433,\n", + " -0.011280984,\n", + " 0.014436456,\n", + " -0.0005374478,\n", + " 0.009446406,\n", + " -0.033089105,\n", + " -0.0039793653,\n", + " 0.01943985,\n", + " 0.039760295,\n", + " -0.0014768348,\n", + " -0.016144281,\n", + " 0.0057805865,\n", + " 0.011327681,\n", + " 0.012955452,\n", + " 0.010360359,\n", + " 0.0012408415,\n", + " -0.015383765,\n", + " 0.014783358,\n", + " 0.010587179,\n", + " -0.011981458,\n", + " -0.013715968,\n", + " -0.0045530875,\n", + " 0.04472366,\n", + " 0.013969473,\n", + " 0.00054036645,\n", + " 0.00512681,\n", + " -0.02560403,\n", + " -0.010246948,\n", + " 0.0076852115,\n", + " -0.009486433,\n", + " -0.020253735,\n", + " 0.00918623,\n", + " 0.0054770475,\n", + " 0.009292969,\n", + " -0.007945388,\n", + " 0.007218228,\n", + " 0.030153781,\n", + " 0.00053536304,\n", + " 0.008886026,\n", + " -0.008919382,\n", + " -0.039253287,\n", + " -0.027858892,\n", + " 0.012321689,\n", + " 0.009933403,\n", + " -0.00784532,\n", + " 0.024696747,\n", + " -0.0136159,\n", + " 0.01809227,\n", + " 0.010860698,\n", + " 0.004062755,\n", + " -0.019346453,\n", + " -0.02481683,\n", + " -0.01609091,\n", + " 0.0045397454,\n", + " 0.016384443,\n", + " -0.032528725,\n", + " -0.005837292,\n", + " -0.002505032,\n", + " 0.00012143652,\n", + " -0.0140095,\n", + " 0.020573951,\n", + " -0.013275669,\n", + " 0.014583223,\n", + " -0.014836728,\n", + " 0.0011741295,\n", + " -0.027378567,\n", + " -0.0017978859,\n", + " 0.01020025,\n", + " 6.3167834e-05,\n", + " 0.005340288,\n", + " -0.019693354,\n", + " -0.008158866,\n", + " 0.0055937935,\n", + " -0.0070981467,\n", + " 0.021494577,\n", + " -0.022735417,\n", + " 0.0064210207,\n", + " 0.011614542,\n", + " -0.0147967,\n", + " 0.021134332,\n", + " 0.011534489,\n", + " 0.006971394,\n", + " 0.008992765,\n", + " 0.015103576,\n", + " 0.014996836,\n", + " 0.01232836,\n", + " -0.002990361,\n", + " -0.013902761,\n", + " -0.0061174817,\n", + " 0.013822706,\n", + " -0.010347016,\n", + " -0.0332759,\n", + " 0.0037458735,\n", + " 0.003495704,\n", + " -0.0035657512,\n", + " -0.01266192,\n", + " 0.01541045,\n", + " 0.005537088,\n", + " -0.00044863755,\n", + " -0.011881391,\n", + " -0.015357081,\n", + " 0.007798622,\n", + " -0.028099054,\n", + " 0.011661241,\n", + " -0.030100413,\n", + " -0.043389425,\n", + " 0.006911353,\n", + " 0.017905476,\n", + " -0.011634557,\n", + " -0.009399707,\n", + " -0.016010858\n", + " ]\n", + " }\n", + "]\n", + "*/\n", + " Step 6: Tool call: mongodb_query_checker\n", + " Step 7: Response: content='```javascript\\ndb.movies.aggregate([\\n ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```javascript\\ndb.movies.aggregate([\\n { \"$match\": { \"$expr\": { \"$gte\": [ \"$awards.wins\", 1 ] } } },\\n { \"$group\": { \"_id\": \"$directors\", \"totalWins\": { \"$sum\": \"$awards.wins\" }, \"movieCount\": { \"$sum\": 1 } } },\\n { \"$match\": { \"movieCount\": { \"$gte\": 5 } } },\\n { \"$sort\": { \"totalWins\": -1 } },\\n { \"$limit\": 5 }\\n])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 117, 'prompt_tokens': 204, 'total_tokens': 321, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhi04rPKCP7Y76UWVAptxY2we8PEm', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--f6eb4227-9693-4a00-a1e3-ab244d223e4e-0' usage_metadata={'input_tokens': 204, 'output_tokens': 117, 'total_tokens': 321, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 8: Tool call: mongodb_query\n", + " Step 9: Response: Error: ValueError('Cannot execute command db.movie...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "Error: ValueError('Cannot execute command db.movies.aggregate([ { \"$match\": { \"$expr\": { \"$gte\": [ \"$awards.wins\", 1 ] } } }, { \"$group\": { _id: \"$directors\", \"totalWins\": { \"$sum\": \"$awards.wins\" }, \"movieCount\": { \"$sum\": 1 } } }, { \"$match\": { \"movieCount\": { \"$gte\": 5 } } }, { \"$sort\": { \"totalWins\": -1 } }, { \"$limit\": 5 } ])')\n", + " Please fix your mistakes.\n", + " Step 10: Tool call: mongodb_query_checker\n", + " Step 11: Response: content='```json\\ndb.movies.aggregate([\\n { \"$m...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```json\\ndb.movies.aggregate([\\n { \"$match\": { \"awards.wins\": { \"$gte\": 1 } } },\\n { \"$group\": { \"_id\": \"$directors\", \"totalWins\": { \"$sum\": \"$awards.wins\" }, \"movieCount\": { \"$sum\": 1 } } },\\n { \"$match\": { \"movieCount\": { \"$gte\": 5 } } },\\n { \"$sort\": { \"totalWins\": -1 } },\\n { \"$limit\": 5 }\\n])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 112, 'prompt_tokens': 199, 'total_tokens': 311, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhi0EkQAnKosnhA5KNZyvP8LfoDKB', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--45a1e727-84e9-4288-8f6c-ef7b82299077-0' usage_metadata={'input_tokens': 199, 'output_tokens': 112, 'total_tokens': 311, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 12: Tool call: mongodb_query\n", + " Step 13: Response: [\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " \"movieCount\": 181\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Steven Spielberg\"\n", + " ],\n", + " \"totalWins\": 696,\n", + " \"movieCount\": 27\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Martin Scorsese\"\n", + " ],\n", + " \"totalWins\": 582,\n", + " \"movieCount\": 26\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Alfonso Cuar\\u00e8n\"\n", + " ],\n", + " \"totalWins\": 575,\n", + " \"movieCount\": 7\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Peter Jackson\"\n", + " ],\n", + " \"totalWins\": 524,\n", + " \"movieCount\": 12\n", + " }\n", + "]\n", + " Step 14: Response: Here are the top 5 directors with the most award w...\n", + "\n", + "Final ReAct Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Here are the top 5 directors with the most award wins, each having directed at least 5 movies:\n", + "\n", + "1. **Steven Spielberg**\n", + " - Total Wins: 696\n", + " - Movie Count: 27\n", + "\n", + "2. **Martin Scorsese**\n", + " - Total Wins: 582\n", + " - Movie Count: 26\n", + "\n", + "3. **Alfonso CuarΓ³n**\n", + " - Total Wins: 575\n", + " - Movie Count: 7\n", + "\n", + "4. **Peter Jackson**\n", + " - Total Wins: 524\n", + " - Movie Count: 12\n", + "\n", + "5. **(Aggregate Total)**\n", + " - Total Wins: 1250\n", + " - Movie Count: 181\n", + "\n", + "(Note: The aggregate total represents the combined wins across all directors, not a specific individual.)\n", + "\n", + "ReAct agent succeeded in 14 steps\n", + "\n", + "LangGraph Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/3\n", + "Thread: compare_69c47d7a_graph_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Find the top 5 directors with most award wins and ...\n", + "\n", + "Final LangGraph Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Find the top 5 directors with most award wins and at least 5 movies\n", + " Step 2: Response: Available collections: comments, embedded_movies, ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 3: Tool call: mongodb_schema\n", + " Step 4: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 5: Tool call: mongodb_query\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " ...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " \"movieCount\": 181\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Steven Spielberg\"\n", + " ],\n", + " \"totalWins\": 696,\n", + " \"movieCount\": 27\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Martin Scorsese\"\n", + " ],\n", + " \"totalWins\": 582,\n", + " \"movieCount\": 26\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Alfonso Cuar\\u00e8n\"\n", + " ],\n", + " \"totalWins\": 575,\n", + " \"movieCount\": 7\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Peter Jackson\"\n", + " ],\n", + " \"totalWins\": 524,\n", + " \"movieCount\": 12\n", + " }\n", + "]\n", + " Step 8: Response: **Answer to:** \"Find the top 5 directors with most...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Find the top 5 directors with most award wins and at least 5 movies\"\n", + "\n", + "1. None: 181 movies\n", + "2. ['Steven Spielberg']: 27 movies\n", + "3. ['Martin Scorsese']: 26 movies\n", + "4. ['Alfonso CuarΓ¨n']: 7 movies\n", + "5. ['Peter Jackson']: 12 movies\n", + "\n", + "LangGraph agent succeeded in 8 steps\n", + "\n", + "Comparison Summary:\n", + "============================================================\n", + "\n", + "ReAct Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/3\n", + " Execution Time: 25.42s\n", + "\n", + "LangGraph Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/3\n", + " Execution Time: 5.50s\n", + "\n", + "Execution Style Analysis:\n", + " ReAct Agent:\n", + " - Autonomous reasoning and tool selection\n", + " - Dynamic decision making based on previous results\n", + " - Can get stuck in reasoning loops with complex queries\n", + " - More flexible but less predictable workflow\n", + " LangGraph Agent:\n", + " - Structured, deterministic workflow\n", + " - Predefined step sequence with conditional branches\n", + " - Better error isolation and recovery\n", + " - More predictable but less flexible execution\n", + "\n", + "Memory Pattern Analysis:\n", + " ReAct Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_69c47d7a_react_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:35:35]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:35:35]\n", + " \"πŸ“Š Top directors search\"\n", + "\n", + "πŸ“ Step 3 [19:35:35]\n", + " \"πŸ”§ List MongoDB collections\"\n", + "\n", + "================================================================================\n", + " LangGraph Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_69c47d7a_graph_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:00]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:00]\n", + " \"πŸ“Š Top directors query\"\n", + "\n", + "πŸ“ Step 3 [19:36:00]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "================================================================================\n", + "\n", + "Recommendations:\n", + " - LangGraph agent was more efficient for this query\n", + " - Both agents handled the query successfully\n", + "\n", + "================================================================================\n", + "\n", + "πŸ“Š Demo 3d: Comprehensive Agent Test Suite\n", + "==================================================\n", + "Running Comparison Test Suite\n", + "============================================================\n", + "\n", + "==================== Simple Query ====================\n", + "Agent Comparison: ReAct vs LangGraph\n", + "============================================================\n", + "Query: Count the total number of movies in the database\n", + "Max Retries: 2\n", + "Recursion Limit: 30\n", + "============================================================\n", + "\n", + "ReAct Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_446205bd_react_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Count the total number of movies in the database\n", + "\n", + "Final ReAct Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Count the total number of movies in the database\n", + " Step 2: Tool call: mongodb_list_collections\n", + " Step 3: Response: comments, embedded_movies, movies, sessions, theat...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_list_collections\n", + "\n", + "comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 4: Tool call: mongodb_schema\n", + " Step 5: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 6: Tool call: mongodb_query_checker\n", + " Step 7: Response: content='```javascript\\ndb.movies.aggregate([{ \"$c...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```javascript\\ndb.movies.aggregate([{ \"$count\": \"totalMovies\" }])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 17, 'prompt_tokens': 110, 'total_tokens': 127, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhi0Wl1tbOdBTaZmOb8HQIQOobOOe', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--5f209ed1-50f6-4e09-8fda-2aadffbe3b3e-0' usage_metadata={'input_tokens': 110, 'output_tokens': 17, 'total_tokens': 127, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 8: Tool call: mongodb_query\n", + " Step 9: Response: [\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + " Step 10: Response: The total number of movies in the database is 21,3...\n", + "\n", + "Final ReAct Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "The total number of movies in the database is 21,349.\n", + "\n", + "ReAct agent succeeded in 10 steps\n", + "\n", + "LangGraph Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_446205bd_graph_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Count the total number of movies in the database\n", + "\n", + "Final LangGraph Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Count the total number of movies in the database\n", + " Step 2: Response: Available collections: comments, embedded_movies, ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 3: Tool call: mongodb_schema\n", + " Step 4: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 5: Tool call: mongodb_query\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"totalMovies\": 21349\n", + " }\n", + "]\n", + " Step 8: Response: **Answer to:** \"Count the total number of movies i...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Count the total number of movies in the database\"\n", + "\n", + "LangGraph agent succeeded in 8 steps\n", + "\n", + "Comparison Summary:\n", + "============================================================\n", + "\n", + "ReAct Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 4.59s\n", + "\n", + "LangGraph Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 3.97s\n", + "\n", + "Execution Style Analysis:\n", + " ReAct Agent:\n", + " - Autonomous reasoning and tool selection\n", + " - Dynamic decision making based on previous results\n", + " - Can get stuck in reasoning loops with complex queries\n", + " - More flexible but less predictable workflow\n", + " LangGraph Agent:\n", + " - Structured, deterministic workflow\n", + " - Predefined step sequence with conditional branches\n", + " - Better error isolation and recovery\n", + " - More predictable but less flexible execution\n", + "\n", + "Memory Pattern Analysis:\n", + " ReAct Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_446205bd_react_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:05]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:06]\n", + " \"πŸ“Š Total movie count request\"\n", + "\n", + "πŸ“ Step 3 [19:36:06]\n", + " \"πŸ”§ List MongoDB collections\"\n", + "\n", + "================================================================================\n", + " LangGraph Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_446205bd_graph_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:10]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:11]\n", + " \"πŸ“Š Total movie count request\"\n", + "\n", + "πŸ“ Step 3 [19:36:11]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "================================================================================\n", + "\n", + "Recommendations:\n", + " - LangGraph agent was more efficient for this query\n", + " - Both agents handled the query successfully\n", + "\n", + "==================== Moderate Query ====================\n", + "Agent Comparison: ReAct vs LangGraph\n", + "============================================================\n", + "Query: List the top 5 directors who have directed the most movies\n", + "Max Retries: 2\n", + "Recursion Limit: 40\n", + "============================================================\n", + "\n", + "ReAct Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_3879a4e0_react_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: List the top 5 directors who have directed the mos...\n", + "\n", + "Final ReAct Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "List the top 5 directors who have directed the most movies\n", + " Step 2: Tool call: mongodb_list_collections\n", + " Step 3: Response: comments, embedded_movies, movies, sessions, theat...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_list_collections\n", + "\n", + "comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 4: Tool call: mongodb_schema\n", + " Step 5: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 6: Tool call: mongodb_query_checker\n", + " Step 7: Response: content='```javascript\\ndb.movies.aggregate([\\n ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```javascript\\ndb.movies.aggregate([\\n { \"$unwind\": \"$directors\" },\\n { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } },\\n { \"$sort\": { \"movieCount\": -1 } },\\n { \"$limit\": 5 }\\n])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 68, 'prompt_tokens': 156, 'total_tokens': 224, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhi0fZrsWZwT2GGpClWhbJ1ZzXwxi', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--b7cae6a8-a0fd-4586-94e9-76e2aa553387-0' usage_metadata={'input_tokens': 156, 'output_tokens': 68, 'total_tokens': 224, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 8: Tool call: mongodb_query\n", + " Step 9: Response: Error: ValueError('Cannot execute command db.movie...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "Error: ValueError('Cannot execute command db.movies.aggregate([ { \"$unwind\": \"$directors\" }, { \"$group\": { _id: \"$directors\", \"movieCount\": { \"$sum\": 1 } } }, { \"$sort\": { \"movieCount\": -1 } }, { \"$limit\": 5 } ])')\n", + " Please fix your mistakes.\n", + " Step 10: Tool call: mongodb_query_checker\n", + " Step 11: Response: content='```javascript\\ndb.movies.aggregate([\\n ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```javascript\\ndb.movies.aggregate([\\n { \"$unwind\": \"$directors\" },\\n { \"$group\": { \"_id\": \"$directors\", \"movieCount\": { \"$sum\": 1 } } },\\n { \"$sort\": { \"movieCount\": -1 } },\\n { \"$limit\": 5 }\\n])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 68, 'prompt_tokens': 156, 'total_tokens': 224, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhi0jDJsZGTMUFAzm3b4mTnCTbjWS', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--a1d6b934-7e74-440c-951a-07bfc6c2a23c-0' usage_metadata={'input_tokens': 156, 'output_tokens': 68, 'total_tokens': 224, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 12: Tool call: mongodb_query\n", + " Step 13: Response: [\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": 40\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"movieCount\": 32\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Miike\",\n", + " \"movieCount\": 31\n", + " },\n", + " {\n", + " \"_id\": \"Steven Spielberg\",\n", + " \"movieCount\": 29\n", + " },\n", + " {\n", + " \"_id\": \"Sidney Lumet\",\n", + " \"movieCount\": 29\n", + " }\n", + "]\n", + " Step 14: Response: The top 5 directors who have directed the most mov...\n", + "\n", + "Final ReAct Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "The top 5 directors who have directed the most movies are:\n", + "\n", + "1. **Woody Allen** - 40 movies\n", + "2. **Martin Scorsese** - 32 movies\n", + "3. **Takashi Miike** - 31 movies\n", + "4. **Steven Spielberg** - 29 movies\n", + "5. **Sidney Lumet** - 29 movies\n", + "\n", + "ReAct agent succeeded in 14 steps\n", + "\n", + "LangGraph Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/2\n", + "Thread: compare_3879a4e0_graph_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: List the top 5 directors who have directed the mos...\n", + "\n", + "Final LangGraph Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "List the top 5 directors who have directed the most movies\n", + " Step 2: Response: Available collections: comments, embedded_movies, ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 3: Tool call: mongodb_schema\n", + " Step 4: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 5: Tool call: mongodb_query\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": ...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": \"Woody Allen\",\n", + " \"movieCount\": 40\n", + " },\n", + " {\n", + " \"_id\": \"Martin Scorsese\",\n", + " \"movieCount\": 32\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Miike\",\n", + " \"movieCount\": 31\n", + " },\n", + " {\n", + " \"_id\": \"Steven Spielberg\",\n", + " \"movieCount\": 29\n", + " },\n", + " {\n", + " \"_id\": \"John Ford\",\n", + " \"movieCount\": 29\n", + " }\n", + "]\n", + " Step 8: Response: **Answer to:** \"List the top 5 directors who have ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"List the top 5 directors who have directed the most movies\"\n", + "\n", + "1. Woody Allen: 40 movies\n", + "2. Martin Scorsese: 32 movies\n", + "3. Takashi Miike: 31 movies\n", + "4. Steven Spielberg: 29 movies\n", + "5. John Ford: 29 movies\n", + "\n", + "LangGraph agent succeeded in 8 steps\n", + "\n", + "Comparison Summary:\n", + "============================================================\n", + "\n", + "ReAct Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 12.06s\n", + "\n", + "LangGraph Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/2\n", + " Execution Time: 3.93s\n", + "\n", + "Execution Style Analysis:\n", + " ReAct Agent:\n", + " - Autonomous reasoning and tool selection\n", + " - Dynamic decision making based on previous results\n", + " - Can get stuck in reasoning loops with complex queries\n", + " - More flexible but less predictable workflow\n", + " LangGraph Agent:\n", + " - Structured, deterministic workflow\n", + " - Predefined step sequence with conditional branches\n", + " - Better error isolation and recovery\n", + " - More predictable but less flexible execution\n", + "\n", + "Memory Pattern Analysis:\n", + " ReAct Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_3879a4e0_react_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:14]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:15]\n", + " \"πŸ“Š List top directors\"\n", + "\n", + "πŸ“ Step 3 [19:36:15]\n", + " \"πŸ”§ List MongoDB collections\"\n", + "\n", + "================================================================================\n", + " LangGraph Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_3879a4e0_graph_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:26]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:27]\n", + " \"πŸ“Š List top directors\"\n", + "\n", + "πŸ“ Step 3 [19:36:27]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "================================================================================\n", + "\n", + "Recommendations:\n", + " - LangGraph agent was more efficient for this query\n", + " - Both agents handled the query successfully\n", + "\n", + "==================== Complex Query ====================\n", + "Agent Comparison: ReAct vs LangGraph\n", + "============================================================\n", + "Query: Find the top 5 directors with most award wins and at least 5 movies\n", + "Max Retries: 3\n", + "Recursion Limit: 50\n", + "============================================================\n", + "\n", + "ReAct Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/3\n", + "Thread: compare_8e075611_react_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Find the top 5 directors with most award wins and ...\n", + "\n", + "Final ReAct Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Find the top 5 directors with most award wins and at least 5 movies\n", + " Step 2: Tool call: mongodb_list_collections\n", + " Step 3: Response: comments, embedded_movies, movies, sessions, theat...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_list_collections\n", + "\n", + "comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 4: Tool call: mongodb_schema\n", + " Step 5: Response: Database name: sample_mflix\n", + "Collection name: comme...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: comments\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "name: String\n", + "email: String\n", + "movie_id: ObjectId\n", + "text: String\n", + "date: Timestamp\n", + "\n", + "/*\n", + "3 documents from comments collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"5a9427648b0beebeb6957b89\"\n", + " },\n", + " \"name\": \"Lisa Rasmussen\",\n", + " \"email\": \"lisa_rasmussen@fakegm\",\n", + " \"movie_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd82da\"\n", + " },\n", + " \"text\": \"Illo nihil occaecati \",\n", + " \"date\": {\n", + " \"$date\": \"1976-12-18T08:14:46Z\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"5a9427648b0beebeb6957bb6\"\n", + " },\n", + " \"name\": \"Ellaria Sand\",\n", + " \"email\": \"indira_varma@gameofth\",\n", + " \"movie_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd8780\"\n", + " },\n", + " \"text\": \"Quidem nesciunt quam \",\n", + " \"date\": {\n", + " \"$date\": \"1985-02-24T20:04:25Z\"\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"5a9427648b0beebeb69579e7\"\n", + " },\n", + " \"name\": \"Mercedes Tyler\",\n", + " \"email\": \"mercedes_tyler@fakegm\",\n", + " \"movie_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd4323\"\n", + " },\n", + " \"text\": \"Eius veritatis vero f\",\n", + " \"date\": {\n", + " \"$date\": \"2002-08-18T04:56:07Z\"\n", + " }\n", + " }\n", + "]\n", + "*/\n", + " Step 6: Tool call: mongodb_query_checker\n", + " Step 7: Response: content='```json\\ndb.movies.aggregate([\\n { \"$m...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query_checker\n", + "\n", + "content='```json\\ndb.movies.aggregate([\\n { \"$match\": { \"awards.wins\": { \"$gt\": 0 } } },\\n { \"$group\": { \"_id\": \"$directors\", \"totalWins\": { \"$sum\": \"$awards.wins\" }, \"movieCount\": { \"$sum\": 1 } } },\\n { \"$match\": { \"movieCount\": { \"$gte\": 5 } } },\\n { \"$sort\": { \"totalWins\": -1 } },\\n { \"$limit\": 5 }\\n])\\n```' additional_kwargs={'refusal': None} response_metadata={'token_usage': {'completion_tokens': 112, 'prompt_tokens': 199, 'total_tokens': 311, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-mini-2024-07-18', 'system_fingerprint': 'fp_34a54ae93c', 'id': 'chatcmpl-Bhi0w3oih1OhY4ldVAAXmKQLEbuAU', 'service_tier': 'default', 'finish_reason': 'stop', 'logprobs': None} id='run--140549af-6ca2-46d0-b972-8ba6bc3c8002-0' usage_metadata={'input_tokens': 199, 'output_tokens': 112, 'total_tokens': 311, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}}\n", + " Step 8: Tool call: mongodb_query\n", + " Step 9: Response: [\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " ...\n", + "\n", + "Final ReAct Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " \"movieCount\": 181\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Steven Spielberg\"\n", + " ],\n", + " \"totalWins\": 696,\n", + " \"movieCount\": 27\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Martin Scorsese\"\n", + " ],\n", + " \"totalWins\": 582,\n", + " \"movieCount\": 26\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Alfonso Cuar\\u00e8n\"\n", + " ],\n", + " \"totalWins\": 575,\n", + " \"movieCount\": 7\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Peter Jackson\"\n", + " ],\n", + " \"totalWins\": 524,\n", + " \"movieCount\": 12\n", + " }\n", + "]\n", + " Step 10: Response: Here are the top 5 directors with the most award w...\n", + "\n", + "Final ReAct Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Here are the top 5 directors with the most award wins, each having directed at least 5 movies:\n", + "\n", + "1. **Steven Spielberg**\n", + " - Total Wins: 696\n", + " - Movie Count: 27\n", + "\n", + "2. **Martin Scorsese**\n", + " - Total Wins: 582\n", + " - Movie Count: 26\n", + "\n", + "3. **Alfonso CuarΓ³n**\n", + " - Total Wins: 575\n", + " - Movie Count: 7\n", + "\n", + "4. **Peter Jackson**\n", + " - Total Wins: 524\n", + " - Movie Count: 12\n", + "\n", + "5. **(Aggregate Total)**\n", + " - Total Wins: 1250\n", + " - Movie Count: 181 (This entry does not correspond to a specific director but represents the total wins across all directors.) \n", + "\n", + "If you need more specific details or additional directors, feel free to ask!\n", + "\n", + "ReAct agent succeeded in 10 steps\n", + "\n", + "LangGraph Agent Execution:\n", + "----------------------------------------\n", + "\n", + "Attempt 1/3\n", + "Thread: compare_8e075611_graph_attempt_1\n", + "Execution steps:\n", + " Step 1: Response: Find the top 5 directors with most award wins and ...\n", + "\n", + "Final LangGraph Response:\n", + "================================\u001b[1m Human Message \u001b[0m=================================\n", + "\n", + "Find the top 5 directors with most award wins and at least 5 movies\n", + " Step 2: Response: Available collections: comments, embedded_movies, ...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "Available collections: comments, embedded_movies, movies, sessions, theaters, users\n", + " Step 3: Tool call: mongodb_schema\n", + " Step 4: Response: Database name: sample_mflix\n", + "Collection name: movie...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_schema\n", + "\n", + "Database name: sample_mflix\n", + "Collection name: movies\n", + "Schema from a sample of documents from the collection:\n", + "_id: ObjectId\n", + "plot: String\n", + "genres: Array\n", + "runtime: Number\n", + "cast: Array\n", + "num_mflix_comments: Number\n", + "poster: String\n", + "title: String\n", + "fullplot: String\n", + "languages: Array\n", + "released: Timestamp\n", + "directors: Array\n", + "writers: Array\n", + "awards.wins: Number\n", + "awards.nominations: Number\n", + "awards.text: String\n", + "lastupdated: String\n", + "year: Number\n", + "imdb.rating: Number\n", + "imdb.votes: Number\n", + "imdb.id: Number\n", + "countries: Array\n", + "type: String\n", + "tomatoes.viewer.rating: Number\n", + "tomatoes.viewer.numReviews: Number\n", + "tomatoes.viewer.meter: Number\n", + "tomatoes.dvd: Timestamp\n", + "tomatoes.lastUpdated: Timestamp\n", + "\n", + "/*\n", + "3 documents from movies collection:\n", + "[\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd63d6\"\n", + " },\n", + " \"plot\": \"Two peasant children,\",\n", + " \"genres\": [\n", + " \"Fantasy\"\n", + " ],\n", + " \"runtime\": 75,\n", + " \"cast\": [\n", + " \"Tula Belle\",\n", + " \"Robin Macdougall\",\n", + " \"Edwin E. Reed\",\n", + " \"Emma Lowry\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Blue Bird\",\n", + " \"fullplot\": \"Two peasant children,\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1633305600000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Maurice Tourneur\"\n", + " ],\n", + " \"writers\": [\n", + " \"Maurice Maeterlinck (\",\n", + " \"Charles Maigne\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-07-20 00:32:04.8\",\n", + " \"year\": 1918,\n", + " \"imdb\": {\n", + " \"rating\": 6.6,\n", + " \"votes\": 446,\n", + " \"id\": 8891\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.6,\n", + " \"numReviews\": 607,\n", + " \"meter\": 60\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2005-09-06T00:00:00Z\"\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-21T18:10:22Z\"\n", + " }\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1391f29313caabcd7472\"\n", + " },\n", + " \"plot\": \"A con artist masquera\",\n", + " \"genres\": [\n", + " \"Drama\"\n", + " ],\n", + " \"runtime\": 117,\n", + " \"cast\": [\n", + " \"Rudolph Christians\",\n", + " \"Miss DuPont\",\n", + " \"Maude George\",\n", + " \"Mae Busch\"\n", + " ],\n", + " \"num_mflix_comments\": 0,\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"Foolish Wives\",\n", + " \"fullplot\": \"\\\"Count\\\" Karanzim, a D\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-1513900800000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Erich von Stroheim\"\n", + " ],\n", + " \"writers\": [\n", + " \"Erich von Stroheim (s\",\n", + " \"Marian Ainslee (title\",\n", + " \"Walter Anthony (title\"\n", + " ],\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-09-05 00:00:37.8\",\n", + " \"year\": 1922,\n", + " \"imdb\": {\n", + " \"rating\": 7.3,\n", + " \"votes\": 1777,\n", + " \"id\": 13140\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 1079,\n", + " \"meter\": 77\n", + " },\n", + " \"dvd\": {\n", + " \"$date\": \"2000-09-19T00:00:00Z\"\n", + " },\n", + " \"critic\": {\n", + " \"rating\": 9.0,\n", + " \"numReviews\": 9,\n", + " \"meter\": 89\n", + " },\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-09-15T17:02:32Z\"\n", + " },\n", + " \"rotten\": 1,\n", + " \"production\": \"Universal Pictures\",\n", + " \"fresh\": 8\n", + " }\n", + " },\n", + " {\n", + " \"_id\": {\n", + " \"$oid\": \"573a1390f29313caabcd42e8\"\n", + " },\n", + " \"plot\": \"A group of bandits st\",\n", + " \"genres\": [\n", + " \"Short\",\n", + " \"Western\"\n", + " ],\n", + " \"runtime\": 11,\n", + " \"cast\": [\n", + " \"A.C. Abadie\",\n", + " \"Gilbert M. 'Broncho B\",\n", + " \"George Barnes\",\n", + " \"Justus D. Barnes\"\n", + " ],\n", + " \"poster\": \"https://m.media-amazo\",\n", + " \"title\": \"The Great Train Robbe\",\n", + " \"fullplot\": \"Among the earliest ex\",\n", + " \"languages\": [\n", + " \"English\"\n", + " ],\n", + " \"released\": {\n", + " \"$date\": {\n", + " \"$numberLong\": \"-2085523200000\"\n", + " }\n", + " },\n", + " \"directors\": [\n", + " \"Edwin S. Porter\"\n", + " ],\n", + " \"rated\": \"TV-G\",\n", + " \"awards\": {\n", + " \"wins\": 1,\n", + " \"nominations\": 0,\n", + " \"text\": \"1 win.\"\n", + " },\n", + " \"lastupdated\": \"2015-08-13 00:27:59.1\",\n", + " \"year\": 1903,\n", + " \"imdb\": {\n", + " \"rating\": 7.4,\n", + " \"votes\": 9847,\n", + " \"id\": 439\n", + " },\n", + " \"countries\": [\n", + " \"USA\"\n", + " ],\n", + " \"type\": \"movie\",\n", + " \"tomatoes\": {\n", + " \"viewer\": {\n", + " \"rating\": 3.7,\n", + " \"numReviews\": 2559,\n", + " \"meter\": 75\n", + " },\n", + " \"fresh\": 6,\n", + " \"critic\": {\n", + " \"rating\": 7.6,\n", + " \"numReviews\": 6,\n", + " \"meter\": 100\n", + " },\n", + " \"rotten\": 0,\n", + " \"lastUpdated\": {\n", + " \"$date\": \"2015-08-08T19:16:10Z\"\n", + " }\n", + " },\n", + " \"num_mflix_comments\": 0\n", + " }\n", + "]\n", + "*/\n", + " Step 5: Tool call: mongodb_query\n", + " Step 6: Tool call: mongodb_query\n", + " Step 7: Response: [\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " ...\n", + "\n", + "Final LangGraph Response:\n", + "=================================\u001b[1m Tool Message \u001b[0m=================================\n", + "Name: mongodb_query\n", + "\n", + "[\n", + " {\n", + " \"_id\": null,\n", + " \"totalWins\": 1250,\n", + " \"movieCount\": 181\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Steven Spielberg\"\n", + " ],\n", + " \"totalWins\": 696,\n", + " \"movieCount\": 27\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Martin Scorsese\"\n", + " ],\n", + " \"totalWins\": 582,\n", + " \"movieCount\": 26\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Alfonso Cuar\\u00e8n\"\n", + " ],\n", + " \"totalWins\": 575,\n", + " \"movieCount\": 7\n", + " },\n", + " {\n", + " \"_id\": [\n", + " \"Peter Jackson\"\n", + " ],\n", + " \"totalWins\": 524,\n", + " \"movieCount\": 12\n", + " }\n", + "]\n", + " Step 8: Response: **Answer to:** \"Find the top 5 directors with most...\n", + "\n", + "Final LangGraph Response:\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Find the top 5 directors with most award wins and at least 5 movies\"\n", + "\n", + "1. None: 181 movies\n", + "2. ['Steven Spielberg']: 27 movies\n", + "3. ['Martin Scorsese']: 26 movies\n", + "4. ['Alfonso CuarΓ¨n']: 7 movies\n", + "5. ['Peter Jackson']: 12 movies\n", + "\n", + "LangGraph agent succeeded in 8 steps\n", + "\n", + "Comparison Summary:\n", + "============================================================\n", + "\n", + "ReAct Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/3\n", + " Execution Time: 11.22s\n", + "\n", + "LangGraph Agent Results:\n", + " Success: βœ…\n", + " Attempts: 1/3\n", + " Execution Time: 5.96s\n", + "\n", + "Execution Style Analysis:\n", + " ReAct Agent:\n", + " - Autonomous reasoning and tool selection\n", + " - Dynamic decision making based on previous results\n", + " - Can get stuck in reasoning loops with complex queries\n", + " - More flexible but less predictable workflow\n", + " LangGraph Agent:\n", + " - Structured, deterministic workflow\n", + " - Predefined step sequence with conditional branches\n", + " - Better error isolation and recovery\n", + " - More predictable but less flexible execution\n", + "\n", + "Memory Pattern Analysis:\n", + " ReAct Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_8e075611_react_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:30]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:30]\n", + " \"πŸ“Š Top directors search\"\n", + "\n", + "πŸ“ Step 3 [19:36:31]\n", + " \"πŸ”§ List MongoDB collections\"\n", + "\n", + "================================================================================\n", + " LangGraph Agent Memory:\n", + "\n", + "πŸ” Thread History: compare_8e075611_graph_attempt_1\n", + "πŸ“Š Total steps: 3\n", + "================================================================================\n", + "\n", + "πŸ“ Step 1 [19:36:41]\n", + " \"πŸ”„ Initial state\"\n", + "\n", + "πŸ“ Step 2 [19:36:41]\n", + " \"πŸ“Š Top directors query\"\n", + "\n", + "πŸ“ Step 3 [19:36:41]\n", + " \"πŸ”§ Available collections list\"\n", + "\n", + "================================================================================\n", + "\n", + "Recommendations:\n", + " - LangGraph agent was more efficient for this query\n", + " - Both agents handled the query successfully\n", + "\n", + "Test Suite Summary:\n", + "==============================\n", + "Simple Query: ReAct βœ… | LangGraph βœ…\n", + "Moderate Query: ReAct βœ… | LangGraph βœ…\n", + "Complex Query: ReAct βœ… | LangGraph βœ…\n" + ] + } + ], + "source": [ + "# Demo 3c: Original problematic query (with safety measures)\n", + "print(\"πŸ“Š Demo 3c: Complex Query with Enhanced Error Handling\")\n", + "print(\"=\" * 50)\n", + "compare_agents_with_memory(\n", + " \"Find the top 5 directors with most award wins and at least 5 movies\",\n", + " max_retries=3,\n", + " recursion_limit=50,\n", + ")\n", + "\n", + "\"\"\"## Demo 3d: Comprehensive Test Suite\"\"\"\n", + "\n", + "print(\"\\n\" + \"=\" * 80 + \"\\n\")\n", + "print(\"πŸ“Š Demo 3d: Comprehensive Agent Test Suite\")\n", + "print(\"=\" * 50)\n", + "\n", + "# Run all test scenarios\n", + "results = run_comparison_tests()\n", + "\n", + "# Show summary\n", + "print(\"\\nTest Suite Summary:\")\n", + "print(\"=\" * 30)\n", + "for test_name, result in results.items():\n", + " if result:\n", + " react_success = \"βœ…\" if result[\"react\"][\"success\"] else \"❌\"\n", + " graph_success = \"βœ…\" if result[\"langgraph\"][\"success\"] else \"❌\"\n", + " print(f\"{test_name}: ReAct {react_success} | LangGraph {graph_success}\")\n", + " else:\n", + " print(f\"{test_name}: ❌ Test Failed\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "u_FBENJVyFfU" + }, + "source": [ + "## Demo 4: List all threads - `list_conversation_threads()`" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "yyhBPC85yKtL", + "outputId": "272ea9ed-5b63-4041-b95c-71c64ffe6f3d" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "πŸ“‹ Available Conversation Threads:\n", + "πŸ“Š Total checkpoints: 222\n", + "==================================================\n", + " 1. Thread: compare_260fd616_graph_attempt_1\n", + " └─ 9 checkpoints\n", + " 2. Thread: compare_260fd616_react_attempt_1\n", + " └─ 11 checkpoints\n", + " 3. Thread: compare_3879a4e0_graph_attempt_1\n", + " └─ 9 checkpoints\n", + " 4. Thread: compare_3879a4e0_react_attempt_1\n", + " └─ 15 checkpoints\n", + " 5. Thread: compare_446205bd_graph_attempt_1\n", + " └─ 9 checkpoints\n", + " 6. Thread: compare_446205bd_react_attempt_1\n", + " └─ 11 checkpoints\n", + " 7. Thread: compare_69c47d7a_graph_attempt_1\n", + " └─ 9 checkpoints\n", + " 8. Thread: compare_69c47d7a_react_attempt_1\n", + " └─ 15 checkpoints\n", + " 9. Thread: compare_8e075611_graph_attempt_1\n", + " └─ 9 checkpoints\n", + " 10. Thread: compare_8e075611_react_attempt_1\n", + " └─ 11 checkpoints\n", + " 11. Thread: compare_d39279d2_graph_attempt_1\n", + " └─ 9 checkpoints\n", + " 12. Thread: compare_d39279d2_react_attempt_1\n", + " └─ 9 checkpoints\n", + " 13. Thread: conversation_demo_7e08f130\n", + " └─ 24 checkpoints\n", + " 14. Thread: demo_basic_1\n", + " └─ 9 checkpoints\n", + " 15. Thread: demo_basic_2\n", + " └─ 9 checkpoints\n", + " 16. Thread: demo_basic_3\n", + " └─ 9 checkpoints\n", + " 17. Thread: demo_basic_4\n", + " └─ 9 checkpoints\n", + " 18. Thread: demo_basic_5\n", + " └─ 9 checkpoints\n", + " 19. Thread: enhanced_test_f4288e1b\n", + " └─ 27 checkpoints\n" + ] + }, + { + "data": { + "text/plain": [ + "['compare_260fd616_graph_attempt_1',\n", + " 'compare_260fd616_react_attempt_1',\n", + " 'compare_3879a4e0_graph_attempt_1',\n", + " 'compare_3879a4e0_react_attempt_1',\n", + " 'compare_446205bd_graph_attempt_1',\n", + " 'compare_446205bd_react_attempt_1',\n", + " 'compare_69c47d7a_graph_attempt_1',\n", + " 'compare_69c47d7a_react_attempt_1',\n", + " 'compare_8e075611_graph_attempt_1',\n", + " 'compare_8e075611_react_attempt_1',\n", + " 'compare_d39279d2_graph_attempt_1',\n", + " 'compare_d39279d2_react_attempt_1',\n", + " 'conversation_demo_7e08f130',\n", + " 'demo_basic_1',\n", + " 'demo_basic_2',\n", + " 'demo_basic_3',\n", + " 'demo_basic_4',\n", + " 'demo_basic_5',\n", + " 'enhanced_test_f4288e1b']" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "list_conversation_threads()" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "adpMU1sZySqV" + }, + "source": [ + "## Demo 5: Enhanced inspection - `inspect_thread_with_summaries_enhanced(thread_id)`" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "qlj_p1p6yY83", + "outputId": "64c182c3-45cb-4ae3-b9b2-3dee9aa59593" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "❌ No checkpoints found for thread: conversation_demo_42dffc93\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Replace with the a thread ID from your MongoDB checkpointing system listed above\n", + "# inspect_thread_with_summaries_enhanced(\"conversation_demo_42dffc93\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "aJg_4D5d_Hee" + }, + "source": [ + "## Demo 6: Interactive Query Interface" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "WIJQl9J8_K3m", + "outputId": "5caae8f3-3fc8-456d-c4bc-dfdf8906383a" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1;30;43mStreaming output truncated to the last 5000 lines.\u001b[0m\n", + " \"_id\": \"Gary Hardwick\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gary Hustwit\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gary Lundgren\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gary Yates\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gaston Kabor\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gast\\u00e8n Duprat\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gene Wilder\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Genndy Tartakovsky\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Geoff Marslett\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Geoffrey Smith\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Georg Fenady\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Abbott\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Armitage\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Casey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Fitzmaurice\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Huang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Ratliff\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"George Sluizer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gerald Potterton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gerardo Olivares\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gerrard Verhage\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giacomo Battiato\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giacomo Campiotti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giacomo Ciarrapico\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gianfranco Mingozzi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gianfranco Rosi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gil Cates Jr.\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gil Kenan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gilles Bourdos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gilles Paquet-Brenner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giorgia Farina\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gisaburo Sugii\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giulio Base\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giulio Manfredonia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giuseppe Colizzi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giuseppe Moccia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Giuseppe Piccioni\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Glen Goei\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Glenn Ficarra\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Glenn Gordon Caron\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Glenn Leyburn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gonzalo L\\u00e8pez-Gallego\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gonzalo Su\\u00e8rez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gordon Parks\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gottfried Reinhardt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Govind Nihalani\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Graham Baker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Grant Harvey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Granz Henman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg Berlanti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg Harrison\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg MacGillivray\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg Manwaring\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg McLean\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg Olliver\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg Spence\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Greg Whiteley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Grigori Kozintsev\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Grzegorz Kr\\u00e8likiewicz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gr\\u00e8mur H\\u00e8konarson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gr\\u00e8ta Olafsd\\u00e8ttir\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gualtiero Jacopetti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Guillaume Ivernel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gustav Hofer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Gustavo Loza\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Guy Jenkin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"G\\u00e8la Babluani\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"G\\u00e8rard Bitton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"G\\u00e8rard Corbiau\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"G\\u00e8rard Depardieu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"G\\u00e8rard Oury\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"G\\u00e8tz Spielmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"H. Bruce Humberstone\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Haile Gerima\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hannes Holm\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hans Fjellestad\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hans-J\\u00e8rgen Syberberg\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hansal Mehta\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hany Abu-Assad\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harald Sicheritz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hari\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harold Prince\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harry Baweja\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harry Bromley Davenport\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harry Elfont\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harry Harris\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harry Winer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Harry d'Abbadie d'Arrast\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hayden Schlossberg\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Heddy Honigmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Heitor Dhalia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Helmut K\\u00e8utner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Helvecio Ratton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hendel Butoy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Henrique Goldman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Henry Barrial\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Henry Cornelius\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Herbert Wise\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hideo Gosha\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hiroshi Shimizu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hiroshi Teshigahara\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ho Choi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Holger Tappe\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Holly Dale\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Homi Adajania\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Howard Hall\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Howard J. Ford\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hrishikesh Mukherjee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hubert Sauper\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hugo Latulippe\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hunter Weeks\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hwi Kim\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hyeong-Cheol Kang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Hype Williams\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ian Fitzgibbon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ian Iqbal Rashid\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ian McCrudden\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Iara Lee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ice Cube\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Igor Kovalyov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Igor Voloshin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ilmar Raag\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ilya Maksimov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ira Sachs\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Irakli Kvirikadze\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Irving Pichel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Isaac Julien\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ishai Setton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ishir\\u00e8 Honda\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Israel C\\u00e8rdenas\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Issa L\\u00e8pez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Isshin Inud\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ivan Sen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ivars Seleckis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J. Stuart Blackton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J.-P. Valkeap\\u00e8\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J.A. Bayona\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J.B. Rogers\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J.P. Sniadecki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J.S. Cardone\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacek Borcuch\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacek Bromski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jack Cardiff\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jack Couffer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jack Hofsiss\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jack Perez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacob Gentry\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacob Thuesen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Becker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Cluzaud\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Dorfmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Feyder\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Fieschi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Martineau\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jacques Perrin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jae-rim Han\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jai-hong Juhn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jake Paltrow\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jake Schreier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jalmari Helander\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James B. Clark\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Bobin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James C. Strouse\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Dearden\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Hayman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Kent\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Mather\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Moll\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"James Watkins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jamie Babbit\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jamin Winans\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jan Balej\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jan Cvitkovic\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jan Egleson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jan Pinkava\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jan-Christoph Glaser\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jane Lipsitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jann Turner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Janne Kuusi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jano Williams\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jarno Laasala\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jason Eisener\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jason Michael Brescia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Javier Rebollo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Javier Ruiz Caldera\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jayson Thiessen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean de Segonzac\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Claude Brisseau\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Claude Lord\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Fran\\u00e8ois Laguionie\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Jacques Zilbermann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Marie Larrieu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Marie Poir\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jean-Philippe Toussaint\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jed Weintrob\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jefery Levy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeff Balsmeyer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeff Wadlow\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeffery Scott Lando\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeffrey Blitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeffrey Lau\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jehane Noujaim\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jen Soska\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jens Jonsson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jens Lien\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeong-ho Lee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeremy Lovering\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeremy Newberger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeremy Podeswa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeremy Saulnier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jeroen Berkvens\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jerry London\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jerry Rees\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jerry Rothwell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jesper M\\u00e8ller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jesse Dylan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jesse Thomas Cook\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jessie Nelson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jill Sprecher\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Brown\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Drake\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Fall\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Gillespie\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Goddard\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Hanon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jim Swaffield\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jin-pyo Park\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jingle Ma\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jir\\u00e8 Barta\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joachim Lafosse\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joachim Trier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joan Churchill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joann Sfar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joanna Kos-Krauze\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joaquim Leit\\u00e8o\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joby Harold\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jocelyn Towne\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jochen Alexander Freydank\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jody Hill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joe Lawlor\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joe Lynch\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joe Maggio\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joel Hopkins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joel Potrykus\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joel Zwick\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Johanna Vuoksenmaa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John 'Bud' Cardos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John A. Davis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Barry\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Bruno\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Cameron Mitchell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Carl Buechler\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Eyres\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John H. Lee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Hamburg\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Hay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John L'Ecuyer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Maringouin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Mathew Matthan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Maybury\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Michael McDonagh\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Moffitt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Patterson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Pilger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Pogue\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Polson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John R. Leonetti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Requa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Rich\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Ridley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Sullivan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Swanbeck\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Wayne\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Webster\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Wells\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"John Williams\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jon Alpert\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jon Gunn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jon Hurwitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jon Kasdan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jon Sherman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonas \\u00e8kerlund\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonathan Ford\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonathan Nossiter\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonathan Parker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonathan Sobol\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonathan Teplitzky\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jonathan Wacks\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jong-bin Yun\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joona Tena\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jordan Galland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jordan Melamed\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jordan Scott\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jordan Vogt-Roberts\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jorge Grau\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jorge Torregrossa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joris Ivens\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josef Rusnak\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joseph Barbera\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joseph Cedar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joseph Kahn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joseph M. Newman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joseph Pelling\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josh Fox\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josh Gordon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josh Lowell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josh Radnor\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josh Trank\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joshua Marston\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joshua Meador\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joshua Michael Stern\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Joshua Seftel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Josiane Balasko\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jos\\u00e8 Alvarenga Jr.\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jos\\u00e8 Ferrer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jos\\u00e8 Henrique Fonseca\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jos\\u00e8 Mar\\u00e8a Forqu\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jo\\u00e8o Canijo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jo\\u00e8o Moreira Salles\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Juan Antonio Bardem\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Juan Pablo Rebella\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Juan Taratuto\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Judith Helfand\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Juha Lehtola\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jukka K\\u00e8rkk\\u00e8inen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Julia Reichert\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Julian Fellowes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Julian Gilbey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Julian Goldberger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Julien Maury\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Julius Sevc\\u00e8k\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Juli\\u00e8n Hern\\u00e8ndez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Jun Ichikawa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Juraj Jakubisko\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Justin Edgar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J\\u00e8rg Wagner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"J\\u00e8r\\u00e8my Clapin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"K. Selvaraghavan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kabir Khan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kai Wessel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kanji Nakajima\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karel Kachyna\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karel Zeman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karen Oganesyan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karey Kirkpatrick\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kari Juusonen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karin Albou\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karin Babinsk\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karl Slovin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karsten Wedel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Karthik Subbaraj\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kasper Barfoed\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Katarzyna Roslaniec\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kate Davis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Katell Quill\\u00e8v\\u00e8r\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kathrine Windfeld\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Katt Shea\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Katy Chevigny\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kay Pollak\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kazuki Ohmori\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kazuyoshi Kumakiri\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kei Kumai\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kei'ichi Sato\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Keith Fulton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Keith Scholey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Keith Truesdell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kenneth Lonergan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kevin Bacon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kevin Deters\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kevin Greutert\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kevin James Dobson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kevin Munroe\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kevin Spacey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Khavn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Khyentse Norbu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ki-hyeong Park\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kief Davidson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kieron J. Walsh\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kieth Merrill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"King Hu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kirill Serebrennikov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kirk Browning\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kirk De Micco\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kirsten Sheridan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kjell-\\u00e8ke Andersson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Klay Hall\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Koldo Serra\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kompin Kemgumnird\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Konrad Niewolski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Konrad Wolf\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kresten Vestbjerg Andersen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kris Elgstrand\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Krishna D.K.\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Krishna Vamshi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Krist\\u00e8n J\\u00e8hannesd\\u00e8ttir\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Krisztina Goda\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kriv Stenders\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Krsto Papic\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kurt Kuenne\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kurt Neumann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kurt Wimmer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kyle Patrick Alvarez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Kyung-Taek Kwak\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"K\\u00e8ji Fukada\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laetitia Masson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laila Pakalnina\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lajos Koltai\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lance Mungia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lance Rivera\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Larry Blamire\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Larry Weinstein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laslo Benedek\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laura Amelia Guzm\\u00e8n\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laura Ma\\u00e8\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laurent Tuel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laurie Colbert\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Laurie Collyer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lavinia Currier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lawrence Blume\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lawrence Guterman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leanne Pooley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lee Hirsch\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leif Lindblom\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leonardo Favio\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leonid Boyko\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leonid Gayday\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leos Carax\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leslie Zemeckis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leslye Headland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Leszek Dawid\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lev L. Spiro\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lexi Alexander\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Liam Lynch\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lidiya Bobrova\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lino Del Fra\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lionel Rogosin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lisa Aschan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lisa Barros D'Sa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lisa Krueger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lisa Langseth\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lisandro Alonso\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Logan Miller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lori Silverbush\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Louie Psihoyos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Louis D'Esposito\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Louis Pepe\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luc Dionne\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luca Ragazzi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luca Vendruscolo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lucas Platt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lucio Fulci\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lucrecia Martel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luc\\u00e8a Puenzo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luigi Cozzi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luis Estrada\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luis Llosa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luis Lopez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luis Valdez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Luke Meyer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lynn Hershman-Leeson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lynne Ramsay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Lynne Stopkewich\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maarit Lalli\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maarten Treurniet\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mabrouk El Mechri\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maciej Dejczer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maciej Pieprzyca\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maciek Szczerbowski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Madeleine Olnek\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Magdalena Piekorz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maggie Greenwald\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mahesh Bhatt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mahesh Manjrekar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mahiro Maeda\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mai Zetterling\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Malcolm Clarke\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Malik Bader\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Malika Zouhali-Worrall\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Man-hui Lee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mandie Fletcher\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maneesh Sharma\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Manfred Stelzer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mania Akbari\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mansoor Khan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Manuel Sicilia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marc Caro\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marc Munden\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marc Rocco\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marcel Pagnol\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marcello Fondato\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marcelo Galv\\u00e8o\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marco Bechis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marco Brambilla\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marco Manetti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marco Martins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marco Petry\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marcos Carnevale\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maren Ade\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maria Blom\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maria Maggenti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mariana Chenillo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mariano Barroso\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mariano Cohn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mariano Llin\\u00e8s\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marilyn Agrelo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marin Karmitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marina Spada\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mario Azzopardi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mario Bava\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mario Camus\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mario Martone\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mario Piluso\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marja Pyykk\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Atkins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Becker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Donskoy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Joffe\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Jonathan Harris\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Linfield\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Rappaport\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Romanek\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Tonderai\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mark Wilkinson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Markus Goller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Markus Imboden\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Markus Imhoof\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marshall Brickman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marteinn Thorsson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martha Stephens\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin Bell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin Donovan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin Jern\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin McDonagh\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin Sul\\u00e8k\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin Weisz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martin Zandvliet\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Martine Dugowson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mart\\u00e8n Rejtman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Marzieh Makhmalbaf\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mar\\u00e8a Lid\\u00e8n\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Masaaki Yuasa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Masato Harada\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Massimiliano Bruno\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mateo Gil\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matheus Souza\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mathieu Amalric\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matt Bettinelli-Olpin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matteo Garrone\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthew Chapman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthew Heineman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthew Irmas\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthew Ogens\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthew Parkhill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthew Warchus\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Matthias Schweigh\\u00e8fer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mattia Torre\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mat\\u00e8as Pi\\u00e8eiro\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maud Nycander\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maurice Tourneur\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mauro Lima\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maur\\u00e8cio Farias\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maxim Pozdorovkin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maxime Giroux\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Maximilian Erlenwein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Med Hondo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Megan Griffiths\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mel Chionglo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mel Smith\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mel Stuart\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Melanie Mayron\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Melissa Martin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Melissa Painter\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mennan Yapo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Merzak Allouache\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Bafaro\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Cohn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Cooney\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Corrente\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Cristofer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael D. Sellers\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Dinner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Dougherty\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Dudok de Wit\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Grossman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Haigney\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Herbig\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Hofmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Lindsay-Hogg\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Madsen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Noer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael O. Sajbel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Oblowitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Parfit\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Patrick King\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Paxton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Pressman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Sinterniklaas\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Snow\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Steiner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Sucsy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Tolkin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michael Walker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Micha\\u00e8l R. Roskam\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michel Blanc\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michel Debats\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michel Munz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michel Negroponte\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michel Poulette\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michele Placido\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michele Soavi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michiel ten Horn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Michiel van Erp\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Miguel Courtois\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Miguel Hermoso\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mika Ninagawa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mikael Marcimain\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Barker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Barnett\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Cahill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Disa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Eschmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Flanagan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Fleiss\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike McCoy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Mendez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Mills\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Nawrocki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Reilly\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike S. Ryan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mike Southon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mikheil Chiaureli\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Milcho Manchevski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Milton Katselas\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Miranda July\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Miroslav Momcilovic\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mitchell Altieri\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mitchell Lichtenstein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Mohsen Amiryoussefi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Monte Hellman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Morgan J. Freeman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Morgan Neville\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Morgan O'Neill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Moufida Tlatli\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Muharrem Gulmez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Muli Segev\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Myshkin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"M\\u00e8lanie Laurent\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"M\\u00e8ns Herngren\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"M\\u00e8ns M\\u00e8rlind\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nacho Cerd\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nadav Lapid\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nadine Labaki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nae Caranfil\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nailah Jefferson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nana Dzhordzhadze\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nancy Meckler\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Narciso Ib\\u00e8\\u00e8ez Serrador\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nash Edgerton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Natalie Portman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Natasha Arthy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nathaniel Kahn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nawapol Thamrongrattanarit\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neal Israel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neele Leana Vollmar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neeraj Pandey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neeraj Vora\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neil Abramson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neil Armfield\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neil Berkeley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neill Blomkamp\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Neill Fearnley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nelson George\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nelson Pereira dos Santos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Niall MacCormick\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nick Hamm\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nick Hurran\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nickolas Perry\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nico Mastorakis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nicolas Cuche\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nicolas Gessner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nicolas Vanier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nicole van Kilsdonk\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nikolai Dostal\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nikolay Gubenko\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nikolay Khomeriki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nikolay Lebedev\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nikos Grammatikos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nikos Panayotopoulos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nina Gilden Seavey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nina Paley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nir Bergman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nisha Ganatra\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nishikant Kamat\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nithiwat Tharathorn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Noah Buschel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Noah Miller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Noam Murro\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nobuhiro Yamashita\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nonzee Nimibutr\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Norman J. Warren\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Norman Z. McLeod\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Norton Virgien\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nour Eddine Lakhmari\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Nunnally Johnson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oksana Bychkova\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ol Parker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Olaf de Fleur Johannesson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Olatunde Osunsanmi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oldrich Lipsk\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ole Gi\\u00e8ver\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oleg Pogodin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oleg Teptsov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oles Sanin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oliver Schmitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Olivier Ducastel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Olivier Marchal\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Omar Shargawi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Onur Tukel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Otto Waalkes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Oz Scott\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"PES\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pablo Fendrik\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paco Le\\u00e8n\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paddy Breathnach\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pamela Romanowsky\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Panna Rittikrai\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paresh Mokashi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pascal Chaumeil\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pascal Laugier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pat Holden\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrice Toye\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patricia Benoit\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrick Archibald\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrick Bokanowski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrick Brice\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrick Hughes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrick Read Johnson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patrick Stettner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patty Jenkins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Patxi Amezcua\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul A. Kaufman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Andrew Williams\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Bartel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Bogart\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Brickman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Crowder\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Etheredge\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Gross\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Jay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul King\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Lazarus\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Michael Glaser\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Morrison\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Ruven\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Sabella\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Satterfield\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paul Wilmshurst\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paula Hern\\u00e8ndez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paulo Morelli\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Paween Purikitpanya\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pedro Costa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pedro Gonz\\u00e8lez-Rubio\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pekka Lehto\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pekka Parikka\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pen Densham\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pere Portabella\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peris Romano\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Perttu Lepp\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pete McCormack\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Andrikidis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Avanzino\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Cattaneo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Chung\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Collinson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Cornwell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Dalle\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter DeLuise\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Delpeut\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Faiman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Fleischmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter H. Hunt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Handke\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Masterson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Mortimer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter R. Hunt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Sehr\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Sollett\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Stebbings\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Strickland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Templeman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Thorwarth\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Ustinov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Peter Werner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Petra Costa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Phil Flores\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Phil Morrison\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Phil Weinstein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philip Frank Messina\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philip Gr\\u00e8ning\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philip Haas\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philip Jackson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philip Martin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philipp Stennert\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philipp St\\u00e8lzl\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philippe Le Guay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Philippe de Broca\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pierre Coffin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pierre Falardeau\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pierre Jolivet\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pierre Morel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pierre Schoeller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Piers Haggard\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Piet De Rycker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pieter Kramer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pieter Kuijpers\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pil-sung Yim\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pin Pin Tan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ping He\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Piotr Dumala\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pitof\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pixote Hunt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Pjer Zalica\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Prashant Nair\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Preston Sturges\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Prince\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Puri Jagannadh\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"P\\u00e8l Sletaune\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"P\\u00e8l \\u00e8ie\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"P\\u00e8ter Forg\\u00e8cs\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Quentin Dupieux\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"R. Balki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"R. Kelly\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rachel Talalay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Radha Bharadwaj\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Radu Jude\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rainer Kaufmann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Raj Nidimoru\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rajat Kapoor\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rajat Mukherjee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rajko Grlic\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ralf Huettner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ralph Fiennes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ralph Smart\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ralph Ziman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ram\\u00e8n Men\\u00e8ndez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Randall Miller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Raoul Peck\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rashid Nugmanov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Raul Garcia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ray Burdis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ray Enright\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Raya Martin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Raymond Depardon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rebecca Zlotowski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Reggie Rock Bythewood\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Reginald Barker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Reinout Oerlemans\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Renato De Maria\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Renos Haralambidis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ren\\u00e8 Goscinny\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Reshef Levi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rezo Chkheidze\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Riad Sattouf\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ricardo Trogi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Riccardo Milani\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Ayoade\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard C. Sarafian\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Dale\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Day\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Elfman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Hobert\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard J. Lewis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Jobson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Kwietniowski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Laxton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Robbins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Rosson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Schenkman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard T. Heffron\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Talmadge\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richard Wilson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Richie Mehta\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rick Alverson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rick Bota\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rick McKay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ricky Gervais\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Riri Riza\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rob Ashford\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rob LaDuca\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rob Sitch\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rob Spera\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rob Stewart\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rob Williams\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Cormack\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Cuffley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Day\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert De Niro\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Drew\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Duvall\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Ellis Miller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Florey\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Frank\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Gardner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Jan Westdijk\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Kirk\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Klane\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Moore\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Shaye\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Siodmak\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Stone\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Thalheim\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robert Young\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roberto Faenza\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roberto Gavald\\u00e8n\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roberto Minervini\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roberto Santucci\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roberto Sneider\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Robin Spry\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rocco DeVilliers\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rocco Papaleo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rod Hardy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rodman Flender\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roel Rein\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roger Avary\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roger Young\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rohan Sippy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rolando Ravello\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Romain Gavras\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roman Coppola\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roman Prygunov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ron Nyswaner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ron Satlof\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rory Kennedy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roschdy Zem\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rosemary Rodriguez\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ross Kagan Marks\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ross Kauffman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ross McElwee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rowan Woods\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rowland V. Lee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Roy Rowland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rudi Lagemann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rudi Van Den Bossche\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ruggero Deodato\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rumle Hammerich\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rupert Wainwright\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Rupert Wyatt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ryan Piers Williams\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ryan White\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ryosuke Hashiguchi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ryuichi Hiroki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"R\\u00e8diger Suchsland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"R\\u00e8nar R\\u00e8narsson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"S.S. Rajamouli\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"S.S. Wilson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sabiha Sumar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sabina Guzzanti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sacha Guitry\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sakari Kirjavainen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Salim Akil\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Salvatore Mereu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sam Jaimes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sam Liu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sam Miller\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sam Taylor\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sam Taylor-Johnson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sam de Jong\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Samir\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sandy Tung\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sang-ho Yeon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sang-il Lee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sang-ok Shin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sangeeth Sivan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sanjay Gupta\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sanping Han\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Santiago Mitre\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Santiago Zannou\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sara Johnsen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sara Sugarman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sarah-Violet Bliss\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Saratswadee Wongsomphet\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Satish Kaushik\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Satoshi Miki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Saul Metzstein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Scott Cooper\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Scott Hamilton Kennedy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Scott J. Gill\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Scott Jeralds\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Scott Reynolds\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Scott Silver\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sean Anders\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sean Fine\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sebastian Dehnhardt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sebasti\\u00e8n Borensztein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sebasti\\u00e8n Lelio\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Serdar Akar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Serge Bozon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sergey Loban\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sergey Mikaelyan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sergio Caballero\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sergio Corbucci\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Seth Kramer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Seth MacFarlane\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Seth Rogen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shaad Ali\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shamim Sarif\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shana Feste\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shane Acker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sharmeen Obaid-Chinoy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sharon Lockhart\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sharon Maguire\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sharon Maymon\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shawn Christensen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shawn Ku\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sheldon Wilson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sheree Folkson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sherry Hormann\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shimako Sato\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shimit Amin\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shin-yeon Won\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shinichir\\u00e8 Watanabe\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shinji Aoyama\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shinji Higuchi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shinobu Yaguchi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shinsuke Sato\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shonali Bose\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Shun Nakahara\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sh\\u00e8hei Morita\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sh\\u00e8ichi Okita\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sh\\u00e8suke Kaneko\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Siddique\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sijie Dai\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Silvio Narizzano\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Simo Halinen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Simon Rumley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Simon Verhoeven\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sirri S\\u00e8reyya \\u00e8nder\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Slawomir Fabicki\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Slobodan Sijan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"So Yong Kim\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sophie Barthes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sophie Letourneur\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Spencer Susser\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Srdan Golubovic\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stan Winston\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stanislav Rostotskiy\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stavros Kazantzidis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stefan Prehn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephan Komandarev\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen Bradley\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen J. Anderson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen Kay\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen Kijak\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen Low\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen St. Leger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stephen Surjik\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Beck\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Bendelack\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve De Jarnatt\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Hickner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Kloves\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Martino\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Wang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steve Yeager\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steven Cantor\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steven Quale\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steven Shainberg\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Steven de Jong\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stu Pollard\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stuart Beattie\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Stuart Orme\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"St\\u00e8phane Aubier\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"St\\u00e8phane Lafleur\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sue Brooks\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sujoy Ghosh\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sukumar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Suresh Krishna\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Susan Froemke\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Susan Jacobson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Susan Muska\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Susumu Kudo\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Suzanne Chisholm\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Suzie Templeton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sven Taddicken\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sven Unterwaldt Jr.\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sylvain White\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sylvia Soska\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Sylvie Verheyde\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"S\\u00e8bastien Lifshitz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"T. Hee\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tae-yong Kim\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Taika Waititi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Takahisa Zeze\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Takao Okawara\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Takashi Koizumi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Takeshi Koike\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Takuya Fukushima\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tamara Jenkins\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Taru M\\u00e8kel\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tar\\u00e8 Ohtani\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tassos Boulmetis\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Taweewat Wantha\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ted Nicolaou\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Terry Green\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Terry Sanders\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Thilo Rothkirch\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Thomas Balm\\u00e8s\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Thomas Gilou\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Thomas Riedelsheimer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tigmanshu Dhulia\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tiller Russell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tim Kirkman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tim Reid\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Timo Tjahjanto\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tjebbo Penning\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Toby Shelton\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Todd Berger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Todd Field\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Todd Graff\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Todd Holland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Todd Louiso\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Todd Strauss-Schulson\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tom Hanks\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tom Noonan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tom Stern\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tom Vaughan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tomm Moore\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tommy Chong\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tommy Lee Wallace\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tommy Wirkola\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tomoyuki Takimoto\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Toni Myers\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony Ayres\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony Cervone\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony Craig\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony Jaa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony McNamara\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony Mitchell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tony Randel\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Torsten K\\u00e8nstler\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Trent Harris\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Troy Byer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tudor Giurgiu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Turner Ross\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tuukka Tiensuu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tyler Gillett\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Tyler Measom\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Udayan Prasad\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ulrik Imtiaz Rolfsen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ulrike Ottinger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Umesh Shukla\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ute Wieland\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vadim Jean\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vadim Perelman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Valeria Bruni Tedeschi\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Veit Harlan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vera Storozheva\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Ver\\u00e8nica Chen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vicco von B\\u00e8low\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vicente Ferraz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Victor Cook\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Victor Mignatti\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Victor Schertzinger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vidhu Vinod Chopra\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Viktor Shamirov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vince Offer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vincent J. Donehue\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vincent Paronnaud\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vincent Patar\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vincenzo Salemme\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vinko Bresan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vishnuvardhan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vladimir Menshov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vladimir Naumov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vladim\\u00e8r Mich\\u00e8lek\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vlasta Posp\\u00e8silov\\u00e8\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Vyacheslav Krishtofovich\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"V\\u00e8ctor Garc\\u00e8a\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"V\\u00e8ctor Gaviria\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wai Man Yip\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Walerian Borowczyk\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Walon Green\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Walter Carvalho\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wayne Kramer\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Weikai Huang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wes Ball\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wesley Ruggles\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Will Finn\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Will Koopman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Will Speck\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Willard Huyck\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Willem van de Sande Bakhuyzen\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William A. Seiter\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Boyd\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Brent Bell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William C. de Mille\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Hanna\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Heise\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William K. Howard\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Mesa\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Peter Blatty\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Phillips\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"William Sachs\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Witold Leszczynski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wojciech Marczewski\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wolfgang Becker\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Wolfgang Lauenstein\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Woo-Suk Kang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Xan Cassavetes\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Xaver Schwarzenberger\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Xavier Dolan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Xavier Gens\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Xavier Palud\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Xiao Lu Xue\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yann Samuell\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yasuhiro Yoshiura\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yen-Ping Chu\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yi'nan Diao\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yi-kwan Kang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yibai Zhang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yilmaz Erdogan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yilmaz G\\u00e8ney\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yorgos Lanthimos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yorgos Tsemberopoulos\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yoshihiro Nakamura\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yoshimitsu Morita\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yoshitar\\u00e8 Nomura\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Youssef Delara\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yung Chang\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yurek Bogayevicz\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yuriy Bykov\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yvan Attal\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yves All\\u00e8gret\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Yvette Kaplan\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zach Braff\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zackary Adler\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zaida Bergroth\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zal Batmanglij\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zalman King\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zeki \\u00e8kten\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zev Berman\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zhuangzhuang Tian\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"Zolt\\u00e8n F\\u00e8bri\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"\\u00e8lvaro Brechner\",\n", + " \"movieCount\": 2\n", + " },\n", + " {\n", + " \"_id\": \"\\u00e8mile Gaudreault\",\n", + " \"movieCount\": 2\n", + " }\n", + "]\n", + "==================================\u001b[1m Ai Message \u001b[0m==================================\n", + "\n", + "**Answer to:** \"Directors with 2 movies\"\n", + "Found **1811** results. Showing first 10:\n", + "\n", + "1. Aaron J. Wiederspahn: 2 movies\n", + "2. Aaron Lipstadt: 2 movies\n", + "3. AarΓ¨n FernΓ¨ndez Lesur: 2 movies\n", + "4. Abbas Fahdel: 2 movies\n", + "5. Abhishek Chaubey: 2 movies\n", + "6. Abraham Polonsky: 2 movies\n", + "7. Achero MaΓ¨as: 2 movies\n", + "8. Adam Bernstein: 2 movies\n", + "9. Adam Bhala Lough: 2 movies\n", + "10. Adam Brooks: 2 movies\n", + "\n", + "... and 1801 more results.\n", + "πŸ’‘ **Tip**: Try 'Show me the top 10...' for more manageable results\n", + "\n", + "[interactive_94e95ca1] Enter your query: exit\n" + ] + } + ], + "source": [ + "interactive_query()" + ] + } + ], + "metadata": { + "colab": { + "provenance": [], + "toc_visible": true + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {} + } + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}