{"id":222829,"date":"2025-05-04T12:37:22","date_gmt":"2025-05-04T12:37:22","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/build-your-own-warren-buffett-agent-in-5-minutes\/"},"modified":"2025-05-04T12:37:22","modified_gmt":"2025-05-04T12:37:22","slug":"build-your-own-warren-buffett-agent-in-5-minutes","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=222829","title":{"rendered":"Build Your Own Warren Buffett Agent in 5 Minutes"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p>What if you could ask Warren Buffett about a stock, market trends, or long-term investing, anytime you wanted? With reports suggesting he may soon step down as CEO of Berkshire Hathaway, it\u2019s a good moment to reflect on the lasting value of his principles. For decades, Buffett has been a steady voice in investing, known for his focus on value, patience, and understanding what you own. In this guide, I will show you how to turn those principles into a conversational Warren Buffett <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/10\/what-are-ai-agents\/\" target=\"_blank\" rel=\"noreferrer noopener\">agent<\/a> that evaluates companies through his lens, and interacts using real-time stock data and news. The goal isn\u2019t to recreate Buffett, but to build a chatbot that helps you think the way he might.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-project-goal-and-architecture\">Project Goal and Architecture<\/h2>\n<p>Our objective is clear: Create a Warren Buffett agent that interacts like him It should discuss investment philosophy, analyze stocks using his core principles, and leverage real-time data. <\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"872\" height=\"473\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp\" alt=\"Warren Buffett Agent\" class=\"wp-image-233467\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp 872w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1-300x163.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1-768x417.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1-150x81.webp 150w\" sizes=\"(max-width: 872px) 100vw, 872px\"\/><\/figure>\n<\/div>\n<p>The main components are:<\/p>\n<ol class=\"wp-block-list\">\n<li><strong>Language Model (OpenAI):<\/strong> Provides the conversational ability and persona adherence.<\/li>\n<li><strong><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/06\/langchain-guide\/\" target=\"_blank\" rel=\"noreferrer noopener\">LangChain<\/a>:<\/strong> Acts as the framework, connecting the language model, tools, and memory.<\/li>\n<li><strong>Stock Data API (Yahoo Finance):<\/strong> Fetches current stock prices and fundamental data.<\/li>\n<li><strong>News API (SerpAPI):<\/strong> Retrieves recent news headlines for context.<\/li>\n<li><strong><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2021\/07\/streamlit-quickly-turn-your-ml-models-into-web-apps\/\" target=\"_blank\" rel=\"noreferrer noopener\">Streamlit<\/a>:<\/strong> Builds the web-based chat interface for user interaction.<\/li>\n<\/ol>\n<p>If this is your first time building agents, checkout our detailed guide \u2013 <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2024\/07\/build-ai-agents-from-scratch\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Build an AI Agent from Scratch?<\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-step-1-prepare-your-environment\">Step 1: Prepare Your Environment<\/h2>\n<p>Before coding, ensure your computer is ready.<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Install Python:<\/strong> You need Python version 3.8 or newer.<\/li>\n<li><strong>Get API Keys:<\/strong> Obtain an API key from OpenAI for language capabilities. Get another key from SerpAPI for news searches. Keep these keys secure.<\/li>\n<li><strong>Install Libraries:<\/strong> Open your computer\u2019s terminal or command prompt. Run the following command to install the necessary <\/li>\n<li><strong>Python packages:<\/strong><\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>pip install langchain langchain-openai langchain-community openai yfinance google-search-results streamlit python-dotenv streamlit-chat<\/code><\/pre>\n<ul class=\"wp-block-list\">\n<li><strong>Create .env File (Optional):<\/strong> In the directory where you will save your script, you can create a file named .env. Add your keys like this:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>OPENAI_API_KEY=\"sk-YOUR_KEY_HERE\"\n\nSERPAPI_API_KEY=\"YOUR_KEY_HERE\"<\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-step-2-start-the-script-and-import-libraries\">Step 2: Start the Script and Import Libraries<\/h2>\n<p>Create a new Python file (e.g., buffett_chatbot.py). Begin by importing the required modules at the top:<\/p>\n<pre class=\"wp-block-code\"><code>import streamlit as st\n\nimport os\n\nimport json\n\nimport yfinance as yf\n\nfrom dotenv import load_dotenv\n\n# LangChain components\n\nfrom langchain_openai import ChatOpenAI\n\nfrom langchain.agents import AgentExecutor, create_openai_functions_agent\n\nfrom langchain.memory import ConversationBufferMemory\n\nfrom langchain.prompts import ChatPromptTemplate, MessagesPlaceholder\n\nfrom langchain_core.messages import SystemMessage # No need for HumanMessage\/AIMessage here anymore\n\nfrom langchain.tools import Tool\n\nfrom langchain_community.utilities import SerpAPIWrapper\n\n# --- Load .env file (as a fallback) ---\n\nload_dotenv()<\/code><\/pre>\n<p>These imports bring in Streamlit for the interface, os for environment variables, json for data handling, yfinance for stocks, dotenv for key loading, and various LangChain components for the agent logic.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-step-3-set-up-the-streamlit-interface\">Step 3: Set-up the Streamlit Interface<\/h2>\n<p>Configure the basic application layout and create sidebar inputs for API keys:<\/p>\n<pre class=\"wp-block-code\"><code># --- Page Config ---\n\nst.set_page_config(page_title=\"Warren Buffett Bot\", layout=\"wide\")\n\nst.title(\"Warren Buffett Investment Chatbot \ud83d\udcc8\")\n\nst.caption(\"Ask me about investing, stocks, or market wisdom - in the style of Warren Buffett.\")\n\n# --- API Key Input in Sidebar ---\n\nst.sidebar.header(\"API Configuration\")\n\n# Initialize session state for keys if they don't exist\n\nif 'openai_api_key' not in st.session_state:\n\n\u00a0\u00a0\u00a0st.session_state.openai_api_key = \"\"\n\nif 'serpapi_api_key' not in st.session_state:\n\n\u00a0\u00a0\u00a0st.session_state.serpapi_api_key = \"\"\n\n# Create text input fields for keys, storing values in session state\n\ninput_openai_key = st.sidebar.text_input(\n\n\u00a0\u00a0\u00a0\"OpenAI API Key\", type=\"password\", value=st.session_state.openai_api_key, key=\"openai_input\"\n\n)\n\ninput_serpapi_key = st.sidebar.text_input(\n\n\u00a0\u00a0\u00a0\"SerpAPI API Key\", type=\"password\", value=st.session_state.serpapi_key, key=\"serpapi_input\"\n\n)\n\n# Update session state with current input values\n\nst.session_state.openai_api_key = input_openai_key\n\nst.session_state.serpapi_key = input_serpapi_key\n\n# Determine which keys are active (user input takes priority)\n\nactive_openai_key = st.session_state.openai_api_key or os.getenv(\"OPENAI_API_KEY\")\n\nactive_serpapi_key = st.session_state.serpapi_api_key or os.getenv(\"SERPAPI_API_KEY\")\n\n# --- Display API Status ---\n\nst.sidebar.header(\"API Status\")\n\n# (Add the if\/else blocks using st.sidebar.success\/error\/warning as in the provided code)\n\nif active_openai_key: st.sidebar.success(...) else: st.sidebar.error(...)\n\n# Check and display SerpAPI status similarly<\/code><\/pre>\n<p>This code sets up the visual part of the Streamlit chatbot application. It uses st.session_state to remember the API keys entered by the user during their session.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-step-4-define-core-settings-and-the-buffett-persona\">Step 4: Define Core Settings and the Buffett Persona<\/h2>\n<p>Establish constants for the AI model and define the detailed instructions (system prompt) that shape the chatbot\u2019s personality:<\/p>\n<pre class=\"wp-block-code\"><code># --- Constants &amp; Prompt ---\n\nMODEL_NAME = \"gpt-4o\" # Specify the OpenAI model\n\nTEMPERATURE = 0.5 \u00a0 \u00a0 # Controls AI creativity (lower is more predictable)\n\nMEMORY_KEY = \"chat_history\" # Key for storing conversation history\n\nBUFFETT_SYSTEM_PROMPT = \"\"\"\n\nYou are a conversational AI assistant modeled after Warren Buffett, the legendary value investor. Embody his persona accurately. \n\n**Your Core Principles:**\n\n* \u00a0 **Value Investing:** Focus on finding undervalued companies with solid fundamentals (earnings, low debt, strong management). Judge businesses, not stock tickers.\n\n* \u00a0 **Long-Term Horizon:** Think in terms of decades, not days or months. Discourage short-term speculation and market timing.\n\n* \u00a0 **Margin of Safety:** Only invest when the market price is significantly below your estimate of intrinsic value. Be conservative.\n\n* \u00a0 **Business Moats:** Favor companies with durable competitive advantages (strong brands, network effects, low-cost production, regulatory advantages).\n\n* \u00a0 **Understand the Business:** Only invest in companies you understand. \"Risk comes from not knowing what you're doing.\"\n\n* \u00a0 **Management Quality:** Assess the integrity and competence of the company's leadership.\n\n* \u00a0 **Patience and Discipline:** Wait for the right opportunities (\"fat pitches\"). Avoid unnecessary activity. Be rational and unemotional.\n\n* \u00a0 **Circle of Competence:** Stick to industries and businesses you can reasonably understand. Acknowledge what you don't know.\n\n**Your Communication Style:**\n\n* \u00a0 **Wise and Folksy:** Use simple language, analogies, and occasional humor, much like Buffett does in his letters and interviews.\n\n* \u00a0 **Patient and Calm:** Respond thoughtfully, avoiding hype or panic.\n\n* \u00a0 **Educational:** Explain your reasoning clearly, referencing your core principles.\n\n* \u00a0 **Prudent:** Be cautious about making specific buy\/sell recommendations without thorough analysis based on your principles. Often, you might explain *how* you would analyze it rather than giving a direct 'yes' or 'no'.\n\n* \u00a0 **Quote Yourself:** Occasionally weave in famous Buffett quotes where appropriate (e.g., \"Price is what you pay; value is what you get.\", \"Be fearful when others are greedy and greedy when others are fearful.\").\n\n* \u00a0 **Acknowledge Limitations:** If asked about something outside your expertise (e.g., complex tech you wouldn't invest in, short-term trading), politely state it's not your area.\n\n**Interaction Guidelines:**\n\n* \u00a0 When asked for stock recommendations, first use your tools to gather fundamental data (P\/E, earnings, debt if possible) and recent news.\n\n* \u00a0 Analyze the gathered information through the lens of your core principles (moat, management, valuation, long-term prospects).\n\n* \u00a0 Explain your thought process clearly.\n\n* \u00a0 If a company seems to fit your criteria, express cautious optimism, emphasizing the need for further due diligence by the investor.\n\n* \u00a0 If a company doesn't fit (e.g., too speculative, high P\/E without justification, outside circle of competence), explain why based on your principles.\n\n* \u00a0 If asked for general advice, draw upon your well-known philosophies.\n\n* \u00a0 Maintain conversational context using the provided chat history. Refer back to previous points if relevant.\n\nRemember: You are simulating Warren Buffett. Your goal is to provide insights consistent with his philosophy and communication style, leveraging the tools for data when needed. Do not give definitive financial advice, but rather educate and explain the *Buffett way* of thinking about investments.\n\n\"\"\"<\/code><\/pre>\n<p>Implement the functions that allow the chatbot to get external stock and news data.<\/p>\n<pre class=\"wp-block-code\"><code># --- Tool Definitions ---\n\n# 1. Stock Data Tool (Yahoo Finance) - No changes needed here\n\n@st.cache_data(show_spinner=False) # Add caching for yfinance calls\n\ndef get_stock_info(symbol: str) -&gt; str:\n\n\u00a0\u00a0\u00a0# ... (keep the existing get_stock_info function code) ...\n\n\u00a0\u00a0\u00a0\"\"\"\n\n\u00a0\u00a0\u00a0Fetches key financial data for a given stock symbol using Yahoo Finance...\n\n\u00a0\u00a0\u00a0\"\"\"\n\n\u00a0\u00a0\u00a0try:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ticker = yf.Ticker(symbol)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0info = ticker.info\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if not info or info.get('regularMarketPrice') is None and info.get('currentPrice') is None and info.get('previousClose') is None:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hist = ticker.history(period=\"5d\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if hist.empty:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return f\"Error: Could not retrieve any data for symbol {symbol}.\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0last_close = hist['Close'].iloc[-1] if not hist.empty else 'N\/A'\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0current_price = info.get(\"currentPrice\") or info.get(\"regularMarketPrice\") or last_close\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0else:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0current_price = info.get(\"currentPrice\") or info.get(\"regularMarketPrice\") or info.get(\"previousClose\", \"N\/A\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0data = {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"symbol\": symbol, \"companyName\": info.get(\"longName\", \"N\/A\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"currentPrice\": current_price, \"peRatio\": info.get(\"trailingPE\") or info.get(\"forwardPE\", \"N\/A\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"earningsPerShare\": info.get(\"trailingEps\", \"N\/A\"), \"marketCap\": info.get(\"marketCap\", \"N\/A\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"dividendYield\": info.get(\"dividendYield\", \"N\/A\"), \"priceToBook\": info.get(\"priceToBook\", \"N\/A\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"sector\": info.get(\"sector\", \"N\/A\"), \"industry\": info.get(\"industry\", \"N\/A\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"summary\": info.get(\"longBusinessSummary\", \"N\/A\")[:500] + (\"...\" if len(info.get(\"longBusinessSummary\", \"\")) &gt; 500 else \"\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if data[\"currentPrice\"] == \"N\/A\": return f\"Error: Could not retrieve current price for {symbol}.\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return json.dumps(data)\n\n\u00a0\u00a0\u00a0except Exception as e: return f\"Error fetching data for {symbol} using yfinance: {str(e)}.\"\n\nstock_data_tool = Tool(\n\n\u00a0\u00a0\u00a0name=\"get_stock_financial_data\",\n\n\u00a0\u00a0\u00a0func=get_stock_info,\n\n\u00a0\u00a0\u00a0description=\"Useful for fetching fundamental financial data for a specific stock symbol (ticker)...\" # Keep description\n\n)\n\n# 2. News Search Tool (SerpAPI) - Now uses active_serpapi_key\n\ndef create_news_search_tool(api_key):\n\n\u00a0\u00a0\u00a0if api_key:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0params = {\"engine\": \"google_news\", \"gl\": \"us\", \"hl\": \"en\", \"num\": 5}\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0search_wrapper = SerpAPIWrapper(params=params, serpapi_api_key=api_key)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Test connectivity during creation (optional, can slow down startup)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# search_wrapper.run(\"test query\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Tool(\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name=\"search_stock_news\",\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0func=search_wrapper.run,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0description=\"Useful for searching recent news articles about a specific company or stock symbol...\" # Keep description\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0except Exception as e:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0print(f\"SerpAPI Tool Creation Warning: {e}\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Fallback to a dummy tool if key is provided but invalid\/error occurs\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Tool(\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name=\"search_stock_news\",\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0func=lambda x: f\"News search unavailable (SerpAPI key configured, but error occurred: {e}).\",\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0description=\"News search tool (currently unavailable due to configuration error).\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0else:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Dummy tool if no key is available\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return Tool(\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name=\"search_stock_news\",\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0func=lambda x: \"News search unavailable (SerpAPI key not provided).\",\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0description=\"News search tool (unavailable - API key needed).\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\nnews_search_tool = create_news_search_tool(active_serpapi_key)\n\ntools = [stock_data_tool, news_search_tool]<\/code><\/pre>\n<p>These functions become the \u2018senses\u2019 of your <strong>stock data analysis bot<\/strong>, allowing it to access current information. Wrapping them as Tool objects makes them usable by LangChain.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-step-6-assemble-the-langchain-agent\">Step 6: Assemble the LangChain Agent<\/h2>\n<p>Configure the core AI logic: the language model, the prompt structure, memory management, and the agent executor that ties them together. This happens within the main part of the script, often inside conditional checks.<\/p>\n<pre class=\"wp-block-code\"><code># --- Main App Logic ---\n\n# Check if the essential OpenAI key is provided\n\nif not active_openai_key:\n\n\u00a0\u00a0\u00a0st.warning(\"Please enter your OpenAI API Key in the sidebar...\", icon=\"\ud83d\udd11\")\n\n\u00a0\u00a0\u00a0st.stop() # Stop if no key\n\n# --- LangChain Agent Setup (conditional on key) ---\n\ntry:\n\n\u00a0\u00a0\u00a0# Initialize the OpenAI LLM\n\n\u00a0\u00a0\u00a0llm = ChatOpenAI(\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0model=MODEL_NAME, temperature=TEMPERATURE, openai_api_key=active_openai_key\n\n\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0# Create the prompt template\n\n\u00a0\u00a0\u00a0prompt_template = ChatPromptTemplate.from_messages(\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SystemMessage(content=BUFFETT_SYSTEM_PROMPT),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MessagesPlaceholder(variable_name=MEMORY_KEY),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(\"human\", \"{input}\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MessagesPlaceholder(variable_name=\"agent_scratchpad\"),\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n\n\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0# Initialize or re-initialize agent components in session state\n\n\u00a0\u00a0\u00a0reinitialize_agent = False\n\n\u00a0\u00a0\u00a0# (Add the logic to check if 'agent_executor' exists or if keys changed)\n\n\u00a0\u00a0\u00a0# ...\n\n\u00a0\u00a0\u00a0if reinitialize_agent:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Initialize memory\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state['memory'] = ConversationBufferMemory(memory_key=MEMORY_KEY, return_messages=True)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Create the agent\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0agent = create_openai_functions_agent(llm, tools, prompt_template)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Create the executor\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state['agent_executor'] = AgentExecutor(\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0agent=agent, tools=tools, memory=st.session_state['memory'], verbose=True, # Set verbose=False for production\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0handle_parsing_errors=True, max_iterations=5\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Store keys used for this agent instance\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state.agent_openai_key = active_openai_key\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state.agent_serpapi_key = active_serpapi_key\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# st.experimental_rerun() # Rerun to apply changes\n\n\u00a0\u00a0\u00a0# Continue with chat history initialization and display...<\/code><\/pre>\n<p>This is the core <strong>LangChain chatbot development<\/strong> section. It sets up the agent using the persona, tools, and memory, enabling intelligent conversation via <strong>OpenAI API integration<\/strong>. Using st.session_state here is essential for maintaining the agent\u2019s memory across user interactions.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-step-7-implement-the-chat-interaction-loop\">Step 7: Implement the Chat Interaction Loop<\/h2>\n<p>Add the code that handles displaying the conversation and processing user input through the agent.<\/p>\n<pre class=\"wp-block-code\"><code># --- Chat History and Interaction ---\n\n\u00a0\u00a0\u00a0# Initialize chat history if it doesn't exist\n\n\u00a0\u00a0\u00a0if \"messages\" not in st.session_state:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state[\"messages\"] = [\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0{\"role\": \"assistant\", \"content\": \"Greetings! ...\"} # Initial message\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0]\n\n\u00a0\u00a0\u00a0# Display existing chat messages\n\n\u00a0\u00a0\u00a0for msg in st.session_state.messages:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.chat_message(msg[\"role\"]).write(msg[\"content\"])\n\n\u00a0\u00a0\u00a0# Get new user input\n\n\u00a0\u00a0\u00a0if prompt := st.chat_input(\"Ask Buffett Bot...\"):\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Display user message\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state.messages.append({\"role\": \"user\", \"content\": prompt})\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.chat_message(\"user\").write(prompt)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Prepare input for the agent\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0agent_input = {\"input\": prompt}\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Invoke the agent executor\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0try:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0with st.spinner(\"Buffett is pondering...\"):\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Get the executor instance from session state\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0agent_executor_instance = st.session_state['agent_executor']\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0response = agent_executor_instance.invoke(agent_input)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Display assistant response\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0output = response.get('output', \"Sorry, an error occurred.\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state.messages.append({\"role\": \"assistant\", \"content\": output})\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.chat_message(\"assistant\").write(output)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0except Exception as e:\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Handle errors during agent execution\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0error_message = f\"An error occurred: {str(e)}\"\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.error(error_message, icon=\"\ud83d\udd25\")\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# Add error to chat display\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.session_state.messages.append({\"role\": \"assistant\", \"content\": f\"Sorry... {e}\"})\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.chat_message(\"assistant\").write(f\"Sorry... {e}\")\n\n\u00a0\u00a0\u00a0# Optional: Add the button to clear history\n\n\u00a0\u00a0\u00a0if st.sidebar.button(\"Clear Chat History\"):\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0# (Code to clear st.session_state.messages and st.session_state.memory)\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0st.rerun()<\/code><\/pre>\n<p>This part makes the <strong>Streamlit chatbot application<\/strong> interactive. It reads user input, sends it to the LangChain agent executor, and displays both the user\u2019s query and the bot\u2019s generated response.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-step-8-run-the-warren-buffett-agent\">Step 8: Run the Warren Buffett Agent<\/h2>\n<p>Save the complete Python script. Open your terminal in the script\u2019s directory and run:<\/p>\n<pre class=\"wp-block-code\"><code>streamlit run buffett_chatbot.py\u00a0\u00a0\u00a0<\/code><\/pre>\n<p>Run this file in the terminal and your browser will open the application, ready for you to input API keys and interact with the chatbot.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-analysing-the-output\">Analysing the Output<\/h2>\n<p>Let\u2019s test Mr. Buffett agent with some of our questions. You can access the same <a href=\"https:\/\/huggingface.co\/spaces\/harshxmishra\/BuffettBot\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">here<\/a>. <\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"497\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent.webp\" alt=\"Warren Buffett Agent \" class=\"wp-image-233457\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent.webp 872w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-300x171.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-768x438.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-150x85.webp 150w\" sizes=\"auto, (max-width: 872px) 100vw, 872px\"\/><\/figure>\n<p>Our streamlit app looks like this, Here we have the option to fill our own OpenAI key and SerpAPI key. Now lets test the bot\u2026<\/p>\n<p><strong>Question 1:<\/strong> <em>\u201cMr. Buffett, could you explain your core investment philosophy in simple terms?\u201d<\/em><\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"546\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/unnamed-5.webp\" alt=\"core investment philosophy\" class=\"wp-image-233460\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/unnamed-5.webp 1000w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/unnamed-5-300x164.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/unnamed-5-768x419.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/unnamed-5-150x82.webp 150w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\"\/><\/figure>\n<p><strong>Question 2:<\/strong> <em>\u201cAnalyze Apple (AAPL) based on its current fundamentals. Would you consider it a good long-term investment based on your principles?\u201d<\/em><\/p>\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"492\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-2.webp\" alt=\"\" class=\"wp-image-233462\" style=\"width:606px;height:auto\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-2.webp 872w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-2-300x169.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-2-768x433.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-2-150x85.webp 150w\" sizes=\"auto, (max-width: 872px) 100vw, 872px\"\/><\/figure>\n<p><strong>Question 3:<\/strong> <em>\u201cWhat are your thoughts on Microsoft (MSFT) considering its recent news and developments?\u201d<\/em><\/p>\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"872\" height=\"453\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-3.webp\" alt=\"Question 3\" class=\"wp-image-233464\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-3.webp 872w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-3-300x156.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-3-768x399.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/05\/Question-3-150x78.webp 150w\" sizes=\"auto, (max-width: 872px) 100vw, 872px\"\/><\/figure>\n<p>Based on the above outputs, we can see that the bot is performing well and using all its functionalities to get to the final output. It is using Warren Buffet persona that we defined earlier to answer all the questions. The bot is utilizing yfinance to get the latest stock prices and PE ratios. SerpAPI is used to get the latest news on the stocks.\u00a0\u00a0<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p>This Warren Buffett agent can be a useful companion for anyone looking to explore value investing through the lens of timeless principles. Whether you\u2019re just starting out or refining your approach, this agent can help you think more clearly and patiently about the markets, just like Buffett would.<\/p>\n<p>You can try it live here: <a href=\"https:\/\/huggingface.co\/spaces\/harshxmishra\/BuffettBot\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">BuffettBot on Hugging Face<\/a>.<\/p>\n<p>Have a question you\u2019d like the agent to answer? Drop it in the comments, I\u2019d love to hear what you ask and how the agent responds.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-frequently-asked-questions\">Frequently Asked Questions<\/h2>\n<div class=\"schema-faq wp-block-yoast-faq-block\">\n<div class=\"schema-faq-section\" id=\"faq-question-1746359085105\"><strong class=\"schema-faq-question\">Q1. Where do I get OpenAI and SerpAPI keys?<\/strong> <\/p>\n<p class=\"schema-faq-answer\"><strong>OpenAI:<\/strong> Visit platform.openai.com, sign up, and navigate to the API keys section.<br \/><strong>SerpAPI: <\/strong>Visit serpapi.com, register, and find your API key in your account dashboard.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746359103349\"><strong class=\"schema-faq-question\">Q2. Is the stock data always accurate?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. The bot uses Yahoo Finance via yfinance. While generally reliable for widely traded stocks, data can have delays or occasional inaccuracies. It\u2019s good for educational purposes but always cross-reference with official sources for actual investment decisions.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746359116563\"><strong class=\"schema-faq-question\">Q3. Can I customize the Buffett persona?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. Absolutely. Modify the BUFFETT_SYSTEM_PROMPT string in the code. You can adjust his principles, communication style, or even add specific knowledge areas.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746359130131\"><strong class=\"schema-faq-question\">Q4. Why does the bot sometimes say the news search is unavailable?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. This happens if you haven\u2019t provided a valid SerpAPI key in the sidebar or the .env file, or if there was an error connecting to SerpAPI.<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1746359142529\"><strong class=\"schema-faq-question\">Q5. <strong>Can this bot give guaranteed investment advice?<\/strong><\/strong> <\/p>\n<p class=\"schema-faq-answer\">A. No. This chatbot is an educational simulation based on Warren Buffett\u2019s style and principles. It does not provide financial advice. Always consult with a qualified financial advisor before making investment decisions.<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"border-top py-3 author-info my-4\">\n<div class=\"author-card d-flex align-items-center\">\n<div class=\"flex-shrink-0 overflow-hidden\">\n                                    <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/harsh9480979\/\" class=\"text-decoration-none active-avatar\"><br \/>\n                                                                       <img decoding=\"async\" src=\"https:\/\/av-eks-lekhak.s3.amazonaws.com\/media\/lekhak-profile-images\/converted_image_0fBqNLi.webp\" width=\"48\" height=\"48\" alt=\"Harsh Mishra\" loading=\"lazy\" class=\"rounded-circle\"\/><\/p>\n<p>                                <\/a>\n                                <\/div>\n<\/p><\/div>\n<p>Harsh Mishra is an AI\/ML Engineer who spends more time talking to Large Language Models than actual humans. Passionate about GenAI, NLP, and making machines smarter (so they don\u2019t replace him just yet). When not optimizing models, he\u2019s probably optimizing his coffee intake. \ud83d\ude80\u2615<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<p><h4 class=\"fs-24 text-dark\">Login to continue reading and enjoy expert-curated content.<\/h4>\n<p>                        <button class=\"btn btn-primary mx-auto d-table\" data-bs-toggle=\"modal\" data-bs-target=\"#loginModal\" id=\"readMoreBtn\">Keep Reading for Free<\/button>\n                    <\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>What if you could ask Warren Buffett about a stock, market trends, or long-term investing, anytime you wanted? With reports suggesting he may soon step down as CEO of Berkshire Hathaway, it\u2019s a good moment to reflect on the lasting value of his principles. For decades, Buffett has been a steady voice in investing, known [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":222830,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[3038,47870,5293,11610,6868],"dealstore":[],"offerexpiration":[],"class_list":["post-222829","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-agent","tag-buffett","tag-build","tag-minutes","tag-warren"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Build Your Own Warren Buffett Agent in 5 Minutes - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=222829\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Build Your Own Warren Buffett Agent in 5 Minutes - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"What if you could ask Warren Buffett about a stock, market trends, or long-term investing, anytime you wanted? With reports suggesting he may soon step down as CEO of Berkshire Hathaway, it\u2019s a good moment to reflect on the lasting value of his principles. For decades, Buffett has been a steady voice in investing, known [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=222829\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-04T12:37:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"872\" \/>\n\t<meta property=\"og:image:height\" content=\"473\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=222829#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=222829\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Build Your Own Warren Buffett Agent in 5 Minutes\",\"datePublished\":\"2025-05-04T12:37:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=222829\"},\"wordCount\":1177,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=222829#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp\",\"keywords\":[\"Agent\",\"Buffett\",\"Build\",\"Minutes\",\"Warren\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=222829#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=222829\",\"url\":\"https:\/\/fivemor.com\/?p=222829\",\"name\":\"Build Your Own Warren Buffett Agent in 5 Minutes - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=222829#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=222829#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp\",\"datePublished\":\"2025-05-04T12:37:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=222829#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=222829\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=222829#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp\",\"width\":872,\"height\":473},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=222829#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Build Your Own Warren Buffett Agent in 5 Minutes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Build Your Own Warren Buffett Agent in 5 Minutes - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=222829","og_locale":"en_US","og_type":"article","og_title":"Build Your Own Warren Buffett Agent in 5 Minutes - Som2ny Network","og_description":"What if you could ask Warren Buffett about a stock, market trends, or long-term investing, anytime you wanted? With reports suggesting he may soon step down as CEO of Berkshire Hathaway, it\u2019s a good moment to reflect on the lasting value of his principles. For decades, Buffett has been a steady voice in investing, known [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=222829","og_site_name":"Som2ny Network","article_published_time":"2025-05-04T12:37:22+00:00","og_image":[{"width":872,"height":473,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=222829#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=222829"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Build Your Own Warren Buffett Agent in 5 Minutes","datePublished":"2025-05-04T12:37:22+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=222829"},"wordCount":1177,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=222829#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp","keywords":["Agent","Buffett","Build","Minutes","Warren"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=222829#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=222829","url":"https:\/\/fivemor.com\/?p=222829","name":"Build Your Own Warren Buffett Agent in 5 Minutes - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=222829#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=222829#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp","datePublished":"2025-05-04T12:37:22+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=222829#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=222829"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=222829#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/05\/Warren-Buffett-Agent-1.webp.webp","width":872,"height":473},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=222829#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Build Your Own Warren Buffett Agent in 5 Minutes"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/222829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=222829"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/222829\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/222830"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=222829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=222829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=222829"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=222829"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=222829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}