{"id":29092241,"url":"https://github.com/harshnarayanjha/kabuai","last_synced_at":"2026-05-17T06:31:38.324Z","repository":{"id":301194933,"uuid":"1006594482","full_name":"HarshNarayanJha/KabuAI","owner":"HarshNarayanJha","description":"Your Personal AI Agent for Stock Market Analysis and Guidance. Smart Investing Conversations Start Here!","archived":false,"fork":false,"pushed_at":"2025-06-25T15:54:45.000Z","size":767,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-25T16:54:35.399Z","etag":null,"topics":["agent","ai","ai-agent","langgraph","llm","stock-market","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HarshNarayanJha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-22T15:56:37.000Z","updated_at":"2025-06-25T15:54:50.000Z","dependencies_parsed_at":"2025-06-25T17:04:47.390Z","dependency_job_id":null,"html_url":"https://github.com/HarshNarayanJha/KabuAI","commit_stats":null,"previous_names":["harshnarayanjha/kabuai"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HarshNarayanJha/KabuAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshNarayanJha%2FKabuAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshNarayanJha%2FKabuAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshNarayanJha%2FKabuAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshNarayanJha%2FKabuAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HarshNarayanJha","download_url":"https://codeload.github.com/HarshNarayanJha/KabuAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HarshNarayanJha%2FKabuAI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262389457,"owners_count":23303341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai","ai-agent","langgraph","llm","stock-market","streamlit"],"created_at":"2025-06-28T07:04:07.005Z","updated_at":"2025-10-27T13:39:48.190Z","avatar_url":"https://github.com/HarshNarayanJha.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kabu AI\n\n_Your Personal AI Agent for Stock Market Analysis and guidance_\n\nSmart Investing Conversations Start Here.\n\n## Overview\n\nKabuAI is a smart and multi-agent AI assistant that helps you make strong stock market decisions.\nYou can ask KabuAI anything related to the Stock Market, such as prices and histories, news, or ask it to analyze the current\nfinancial status of a company, and decide your investment strategy.\nOr if you feel like it, you can ask KabuAI to suggest you one.\n\n![KabuAI running](./images/streamlit_ui.png)\n\n## Architecture\n\nKabuAI is powered by [LangChain](https://www.langchain.com/) and [LangGraph](https://www.langchain.com/langgraph) under the hood,\nwith [FastAPI](https://fastapi.tiangolo.com/) serving the API, and finally [Streamlit](https://streamlit.io/) providing user access to all of this.\n\nLangGraph enables KabuAI to be really powerful about it's decision making by incorporating the latest LLMs into the graph\nthat understand user's query better. The ability to make predictable routes based on user's query feels like magic.\n\nFastAPI serves a quick and easy way to serve streaming async routes for interacting with the powerful agent at the back.\n\n### LangGraph Framework\n\nKabuAI is made with a lot of graphs and chains working together. User's query is first handled by the supervisor agent _boss_\nwhich uses a powerful LLM to make its decisions. It then delegates tasks to each of the agents available to it, each of which\nspecialize in different areas of stock market analysis. Finally, it validates every data produced by the agents before returning to\nthe user.\n\n![Graph by Me](./images/KabuAI.png)\n\nHere is the big picture generated by langgraph itself that depicts the whole graph network.\n\n![Graph](./kabuai/graph.png)\n\n## Agents\n\nKabuAI is made up with 6 agents working together.\n\n1. Boss\n   This is the main supervisor agent that looks over everything and delegates tasks to other agents.\n\n   ![Boss Agent](./kabuai/boss_graph.png)\n\n2. Stock\n   This agent specializes in stock data fetching and summarizing just like the user wants.\n   It has access to tools to fetch stock data from [yfinance](https://ranaroussi.github.io/yfinance/index.html),\n   store it in a data model, and then summarize it based on user's query.\n\n   ![Boss Agent](./kabuai/stock_graph.png)\n\n3. Search\n   This agent can search the web for the latest news and data using [DuckDuckGo](https://www.duckduckgo.com/) search API.\n   It feeds the LLM with the news and sentiment analysis which will be relevant for making further decisions.\n\n   ![Search Agent](./kabuai/search_graph.png)\n\n4. Analyzer\n   This agent analyzes the stock data and news to give detailed insights about the stock, and an analysis score.\n   It has access to search tool to search the web if it needs anything latest.\n\n   ![Analyzer Agent](./kabuai/analyzer_graph.png)\n\n## Tools\n\nKabuAI uses these tools\n\n- `fetch_stock_details` -\u003e Uses [yfinance](https://ranaroussi.github.io/yfinance/index.html)\n- `search_web` -\u003e Uses [DuckDuckGo](https://www.duckduckgo.com/)\n  ...\n\n## Process Flow\n\nThe FastAPI endpoint `/chat` accepts an `APIState` as input, which is similar to the `StockBossState`, but is a little more permissive about the values (serialization and more).\nThe state is then passed over to the boss agent, which uses a LLM as a router to decide which agent to go to next.\nAfter the decision is made, a system prompt is generated for the next agent describing its work,\nwhich is then performed by the agent, using tools if applicable, and then returned back to the boss agent.\nThen the boss agent is again asked to make a routing decision. This continues until the LLM decides to goto FINISH.\n\nAt each special event, such as an handoff/delegation, or a tool call, or a llm token generation, Server Side Events are emitted from the endpoint,\nwhich are used by the Streamlit chat frontend to update it's state. This doesn't make the user wait for the complete response to come, and makes using KabuAI interactive!\n\n## Usage\n\nThe streamlit app is hosted at [https://kabuai.onrender.com](https://kabuai.onrender.com). You can try it out there. Please don't use it too much since API is rate limited.\n\nAnother way to try out is setup the development environment.\n\n### Setup\n\nThe project is ~100% in Python and uses [uv](https://github.com/astral-sh/uv) and for package management, which makes it really simple.\n\nFork and clone this repository, then change to the cloned directory.\n\n```sh\ngit clone https://githu.com/HarshNarayanJha/KabuAI.git\ncd KabuAI\n```\n\nThen setup the environment, then install dependencies.\n\n```sh\nuv sync\n```\n\nThat's all, it makes the venv and installs deps.\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\nor, using traditional pip (commands may change depending on your OS/Setup)\n\u003c/summary\u003e\n\n```sh\npython -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n```\n\n_PS: See, uv makes it a lot simpler_\n\n\u003c/details\u003e\n\n### Configuration\n\nKabuAI requires a little configuration to be done before being able to run. You will see a `.env.example` and `.env.ui.example` file in the root of the project.\nCopy that to `.env` and `.env.ui` respectively.\n\n```sh\ncp .env.example .env\ncp .env.ui.example .env.ui\n```\n\nand fill in the environment variables\n\n- `GOOGLE_API_KEY`: Your very own Google API Key to call the LLMs.\n\n- `CHAT_MODEL_LIGHT`: Chat model to use for the light Chat calls. Specify in [langchain](https://python.langchain.com/docs/integrations/chat/) style (`provider:model_name`)\n- `CHAT_MODEL`: Chat model to use for the medium Chat calls.\n- `CHAT_MODEL_HEAVY`: Chat model to use for the heavy Chat calls.\n\n- `LLM_MODEL_LIGHT`: LLM model to use for the light llm calls.\n- `LLM_MODEL`: LLM model to use for the medium llm calls.\n- `LLM_MODEL_HEAVY`: LLM model to use for the heavy llm calls.\n\n- `TEMPERATURE`: Temperature to use for the LLM calls.\n\n- `ALLOWED_ORIGINS`: CORS allowed origins, separated by commas. Example: \"http://localhost:8501,http://127.0.0.1:8501\"\n- `PORT`: Port to run the server on.\n\nAnd for the UI\n\n- `API_URL`: Server API endpoint.\n- `INITIAL_MESSAGE`: Initial message in the chat by KabuAI\n\nCommon in both\n\n- `DEBUG`: Enable debug mode for LangGraph agents and Streamlit requests.\n\nNote: You may need to add more `*_API_KEY` variables depending on which models you choose. Refer to the LangGraph docs.\n\n### Running the Application\n\nThere are helper scripts in the root of the project to run the various components of KabuAI. I plan to move to Docker Compose soon™️.\n\n- `./run_cli.sh` -\u003e Runs KabuAI's graph in cli mode. You can send messages to it and get responses.\n- `./run_server.sh` -\u003e Runs FastAPI server to expose an endpoint to interact with the agent.\n- `./run_ui.sh` -\u003e Runs the streamlit interface to interact with the agent. Requires to have the server running. NOT the CLI.\n\nYou can see what each script runs. For the imports to work correctly, CLI and server require you to go into the `kabuai` directory before invoking python or uvicorn.\n\nThere is a test script `./test_sse_events.py` that you can use to test the FastAPI server and sse events.\n\n## Streamlit Interface\n\nThe streamlit app is located inside the `./ui` directory. It is a simple multi-page application serving different pages for different purposes.\nIt uses `requests_sse` package to listen to the Server Side Events emitted by the FastAPI backend.\n\nIt currently shows handoff events and tool calls, as well as message streaming, with data elements for stock and search results and a chat layout using streamlit's built in components.\n\n### Features\n\n- Ask Stock Details\n- Know Current and Past Prices\n- Get latest news\n- Analyze stock data\n\n## The name\n\nNow we come to the good part...\n\n\u003e Why name this KabuAI?\n\nSo previously I picked the name VentureAI, which sounded good enough, but not that good. I searched and settled on Kabu, or KabuAI.\n\n“Kabu” (株) means stock/share in Japanese.\n\nSo, KabuAI. Period.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n\n\u0026copy; Harsh Narayan Jha\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshnarayanjha%2Fkabuai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshnarayanjha%2Fkabuai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshnarayanjha%2Fkabuai/lists"}