{"id":29028508,"url":"https://github.com/jiyashetty28/basic-llm-chatbot-using-langgraph","last_synced_at":"2025-06-26T07:34:33.223Z","repository":{"id":300814514,"uuid":"1007260579","full_name":"jiyashetty28/Basic-LLM-Chatbot-using-Langgraph","owner":"jiyashetty28","description":"This is a simple chatbot project built using LangGraph, a graph-based framework for orchestrating LLMs, and powered by the Groq API with the LLaMA3-8B-8192 model. The chatbot demonstrates how to structure conversational flows using state graphs and message reducers for memory. Ideal for learning how to integrate LLMs into modular applications.","archived":false,"fork":false,"pushed_at":"2025-06-23T18:16:01.000Z","size":99,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T19:19:46.818Z","etag":null,"topics":["chatbot","graph-visualization","groq-api","langchain-python","langgraph-python","reducers","stategraph"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/jiyashetty28.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-23T17:58:26.000Z","updated_at":"2025-06-23T18:25:46.000Z","dependencies_parsed_at":"2025-06-23T19:19:51.341Z","dependency_job_id":"d3239761-0058-41e9-9a2c-5d6e7e348503","html_url":"https://github.com/jiyashetty28/Basic-LLM-Chatbot-using-Langgraph","commit_stats":null,"previous_names":["jiyashetty28/basic-llm-chatbot-using-langgraph"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jiyashetty28/Basic-LLM-Chatbot-using-Langgraph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiyashetty28%2FBasic-LLM-Chatbot-using-Langgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiyashetty28%2FBasic-LLM-Chatbot-using-Langgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiyashetty28%2FBasic-LLM-Chatbot-using-Langgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiyashetty28%2FBasic-LLM-Chatbot-using-Langgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiyashetty28","download_url":"https://codeload.github.com/jiyashetty28/Basic-LLM-Chatbot-using-Langgraph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiyashetty28%2FBasic-LLM-Chatbot-using-Langgraph/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262022943,"owners_count":23246422,"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":["chatbot","graph-visualization","groq-api","langchain-python","langgraph-python","reducers","stategraph"],"created_at":"2025-06-26T07:34:30.147Z","updated_at":"2025-06-26T07:34:33.202Z","avatar_url":"https://github.com/jiyashetty28.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 Basic Chatbot using LangGraph \u0026 Groq API\r\n\r\nWelcome to this minimal yet functional chatbot project that leverages the **LangGraph Graph API** and **Groq's LLaMA3-8B-8192 model**! This chatbot demonstrates how to structure conversational flows using a graph-based state machine and large language models.\r\n\r\n---\r\n\r\n## 📌 Features\r\n\r\n- 🌐 Built using **LangGraph** – A graph-based framework for building LLM-powered applications.\r\n- 🚀 Powered by **Groq API** with **LLaMA3-8B-8192** model.\r\n- 🔁 Graph execution flow: Define states → Add LLM node → Connect via edges → Compile → Invoke.\r\n- 🧠 Stateful memory with message history via `add_messages`.\r\n- 🔎 Visualizes graph using Mermaid.\r\n\r\n---\r\n\r\n## 📁 Project Structure\r\n\r\n```\r\n.\r\n├── 1-basicchatbot.ipynb     # Jupyter Notebook with complete chatbot code\r\n├── .env                     # Stores your Groq API Key\r\n└── README.md                # Project documentation\r\n```\r\n\r\n---\r\n\r\n## 🧰 Requirements\r\n\r\nMake sure you have the following Python packages installed:\r\n\r\n```bash\r\npip install langgraph langchain langchain-groq python-dotenv\r\n```\r\n\r\n---\r\n\r\n## 🔐 .env Configuration\r\n\r\nCreate a `.env` file in the same directory as your notebook/script and add:\r\n\r\n```env\r\nGROQ_API_KEY=your_groq_api_key_here\r\n```\r\n\r\n---\r\n\r\n## 🧱 How It Works\r\n\r\n### 1. **Define State**\r\n\r\n```python\r\nclass State(TypedDict):\r\n    messages: Annotated[list, add_messages]\r\n```\r\n\r\nThe chatbot keeps track of all messages in a list using `add_messages`, which appends new user/LLM messages to the state.\r\n\r\n---\r\n\r\n### 2. **Initialize Groq LLM**\r\n\r\n```python\r\nfrom langchain_groq import ChatGroq\r\nllm = ChatGroq(model=\"llama3-8b-8192\")\r\n```\r\n\r\nYou can also use `init_chat_model(\"groq:llama3-8b-8192\")` for compatibility with LangChain.\r\n\r\n---\r\n\r\n### 3. **Define Node Function**\r\n\r\n```python\r\ndef chatbot(state: State):\r\n    return {\"messages\": [llm.invoke(state[\"messages\"])]}\r\n```\r\n\r\nThe chatbot node takes the current state and returns a new message generated by the LLM.\r\n\r\n---\r\n\r\n### 4. **Build and Compile Graph**\r\n\r\n```python\r\ngraph_builder.add_node(\"llmchatbot\", chatbot)\r\ngraph_builder.add_edge(START, \"llmchatbot\")\r\ngraph_builder.add_edge(\"llmchatbot\", END)\r\n\r\ngraph = graph_builder.compile()\r\n```\r\n\r\nThis builds the LangGraph with a simple START → LLM → END flow.\r\n\r\n---\r\n\r\n### 5. **Invoke the Chatbot**\r\n\r\n```python\r\nresponse = graph.invoke({\"messages\": \"Hiiii\"})\r\nprint(response[\"messages\"][-1].content)\r\n```\r\n\r\n---\r\n\r\n## 🧠 Graph Visualization\r\n\r\nTo visualize the LangGraph structure:\r\n\r\n```python\r\nfrom IPython.display import Image, display\r\ndisplay(Image(graph.get_graph().draw_mermaid_png()))\r\n```\r\n\r\n---\r\n\r\n## 📸 Demo Output\r\n\r\n```text\r\nInput:  Hiiii\r\nOutput: Hello! How can I help you today?\r\n```\r\n\r\n---\r\n\r\n## 💡 Notes\r\n\r\n- This is a **minimal working prototype**. You can extend it with more nodes like context handling, retrieval, tools, or memory chains.\r\n- You can swap out Groq with **OpenAI**, **Mistral**, or any other LLM backend supported by LangChain.\r\n- Don't forget to **keep your API keys secure**.\r\n\r\n---\r\n\r\n## ✨ Credits\r\n\r\n- 🧠 [LangGraph](https://github.com/langchain-ai/langgraph)\r\n- ⚡ [Groq API](https://console.groq.com/)\r\n- 🤖 [LangChain](https://www.langchain.com/)\r\n\r\n---\r\n\r\n## 📜 License\r\n\r\nThis project is licensed under the MIT License. Feel free to modify and build upon it!\r\n\r\n---\r\n## 🧑‍💻 Author\r\nJiya Shetty 📧 jiyashetty173@somaiya.edu 👩‍🎓 TY BTech Electronics and Computer Engineering 📍 K. J. Somaiya College of Engineering\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiyashetty28%2Fbasic-llm-chatbot-using-langgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiyashetty28%2Fbasic-llm-chatbot-using-langgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiyashetty28%2Fbasic-llm-chatbot-using-langgraph/lists"}