Stock chat
The purpose of this flow is to act as a finance expert to answer questions about the markets. It uses an agent that, upon a request for actions, accesses data from Yahoo Finance and then uses that information to generate a precise response.
Stock Chat – Finance‑Expert Chatbot
🧩 Overview
The workflow automates the conversion of a user’s plain‑text query about the stock market into a precise, data‑driven response.
When a user submits a question, the system first extracts any ticker symbols, determines the user’s intent, selects an appropriate tool (Yahoo Finance), gathers the required data, and finally formats a natural‑language answer. The entire process is orchestrated by an LLM‑powered agent that dynamically chooses actions and combines the results into a single coherent reply.
⚙️ Main Features
- Intent detection – a language model analyzes the user’s query to identify the requested financial information.
- Ticker extraction – a prompt template parses the user message and returns a list of relevant stock symbols.
- Dynamic tool selection – an agent selects the Yahoo Finance tool when data retrieval is needed.
- Contextual data retrieval – the tool pulls real‑time or recent financial data (price, news, etc.) for the requested ticker(s).
- Structured response generation – a second prompt template merges the data with the user’s original question to produce a concise, well‑formatted answer.
- End‑to‑end orchestration – a LangGraph React agent coordinates all steps and manages conversation memory.
🔄 Workflow Steps
| Component Name | Role in the Workflow | Key Inputs | Key Outputs |
|---|---|---|---|
| Chat Input | Receives the user’s message and session metadata. | User message text; conversation ID; session ID. | Structured message containing the user query. |
| Prompt for Ticker Extraction | Builds a prompt that extracts ticker symbols from the user message. | User message text. | Prompt string requesting a list of tickers. |
| Intent Analyzer | Uses a language model to interpret the user’s intent and return the extracted tickers. | Prompt string from the previous step. | Message with a plain‑text list of ticker symbols. |
| Prompt for Agent Specialist | Generates the initial prompt for the finance‑expert agent, embedding the list of tickers. | List of ticker symbols. | Prompt string for the agent. |
| Agent Orchestrator | Runs the LangGraph React agent, selecting tools and performing actions based on the prompt. | Prompt string from the previous step; Yahoo Finance tool. | Structured response containing financial data (e.g., price, news). |
| Yahoo Finance Tool | Retrieves requested information (price, news, etc.) for a given ticker symbol. | Ticker symbol; requested information type. | Data payload with financial details. |
| Prompt for Final Response | Builds a prompt that combines the agent’s data with the original user task. | Agent’s financial data; original user query. | Prompt string for final answer generation. |
| Response Generator | A language model turns the prompt into a natural‑language reply. | Prompt string from the previous step. | Final answer text. |
| Chat Output | Delivers the generated reply back to the user in the chat interface. | Final answer text. | Displayed chat message. |
🧠 Notes
- The system relies on the availability of a functional Yahoo Finance API; missing or rate‑limited data will cause the agent to report an error gracefully.
- All prompts are crafted to be as concise as possible, minimizing the amount of data the LLM must process, which improves latency.
- The LangGraph agent uses a short‑term memory of the last several turns, ensuring that follow‑up questions can reference earlier context.
- The
Intent Analyzermodel can be swapped with any compatible LLM; the same applies to theResponse Generator. - The workflow assumes that the user’s query contains at least one valid ticker symbol; otherwise, the agent will prompt the user for clarification.
- The system does not store any personal user data beyond what is required for the current conversation session.