genaitiwari commited on
Commit
433146a
Β·
1 Parent(s): b0540b3

updated readme

Browse files
Files changed (2) hide show
  1. README.md +188 -25
  2. cs-flow.png β†’ cs_flow.png +0 -0
README.md CHANGED
@@ -1,33 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: Langgraph
3
- emoji: πŸ“ˆ
4
- colorFrom: yellow
5
- colorTo: red
6
- sdk: streamlit
7
- sdk_version: 1.41.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- short_description: Langgraph
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- # Langgraph
15
- ## UseCases
 
 
 
 
 
 
 
16
 
17
- ### 1. Basic Chatbot
18
- reference:
19
- ![alt text](basic_chatbot.png)
 
 
 
 
20
 
21
- ### 2. Chatbt with Tool
22
- reference:
23
- ![alt text](chatbot_with_search_tool.png)
24
 
25
- ### 3. Appointment Receptionist
26
- reference:
27
- ![alt text](appointment_receptionist.png)
28
 
29
- ### 4. Customer Support
30
- reference:
31
- ![alt text](cs_flow.png)
32
- ![alt text](customer_support.png)
33
 
 
 
1
+ Here’s the rewritten section with the Streamlit app instructions integrated into the provided structure:
2
+
3
+ ---
4
+
5
+ title: Langgraph
6
+ emoji: πŸ“ˆ
7
+ colorFrom: yellow
8
+ colorTo: red
9
+ sdk: streamlit
10
+ sdk_version: 1.41.1
11
+ app_file: app.py
12
+ pinned: false
13
+ license: apache-2.0
14
+ short_description: Langgraph
15
+
16
+ ---
17
+
18
+ # πŸš€ LangGraph: Building Stateful AI Agents as Graphs
19
+
20
+ **Official Links**
21
+ - [GitHub Repository](https://github.com/langchain-ai/langgraph)
22
+ - [Documentation](https://langchain-ai.github.io/langgraph/)
23
+ - [LangChain Academy Course](https://github.com/gayashan4lk/langchain-academy-lang-graph-intro) (Free Intro)
24
+ - [Prebuilt Agents & Templates](https://langchain-ai.github.io/langgraph/concepts/template_applications/)
25
+
26
+ ---
27
+
28
+ ## πŸ“Œ Overview
29
+ LangGraph is a Python library for creating **stateful, multi-step AI workflows** using Large Language Models (LLMs). It enables dynamic decision-making through graph-based architectures, allowing developers to design agents that loop, branch, and interact with tools/APIs. Inspired by Pregel and Apache Beam, it’s widely used by companies like LinkedIn, Uber, and Elastic.
30
+
31
+ ---
32
+
33
+ ## πŸ”‘ Key Features
34
+ 1. **Graph-Based Workflows**
35
+ - Define workflows as **nodes** (tasks) and **edges** (connections).
36
+ - Supports **conditional edges** (e.g., "If tool call needed, route to tools node").
37
+
38
+ 2. **State Management**
39
+ - Persist conversation history, tool outputs, or custom data across interactions using checkpoints.
40
+
41
+ 3. **Multi-Actor Support**
42
+ - Build collaborative agents (e.g., one agent retrieves data, another generates responses).
43
+
44
+ 4. **Prebuilt Agents**
45
+ - Use templates like `create_react_agent` for ReAct-style agents or customize workflows.
46
+
47
+ 5. **LangGraph Platform** (Commercial)
48
+ - Deploy agents at scale with streaming, background runs, and monitoring.
49
+
50
+ ---
51
+
52
+ ## πŸ› οΈ Getting Started
53
+
54
+ ### Installation
55
+ ```bash
56
+ pip install -U langgraph # Core library
57
+ pip install langchain_groq streamlit # For Groq models and Streamlit UI
58
+ ```
59
+
60
+ ### Basic Example: ReAct Agent
61
+ ```python
62
+ from langgraph.prebuilt import create_react_agent
63
+ from langchain_groq import ChatGroq # Changed import
64
+ import os
65
+
66
+ # Define a search tool (remains the same)
67
+ @tool
68
+ def search(query: str):
69
+ if "san francisco" in query.lower():
70
+ return "60Β°F, foggy"
71
+ return "90Β°F, sunny"
72
+
73
+ # Initialize agent with Groq
74
+ model = ChatGroq(
75
+ temperature=0,
76
+ model_name="mixtral-8x7b-32768" # Groq model name
77
+ )
78
+ checkpointer = MemorySaver() # Persists state
79
+ app = create_react_agent(model, [search], checkpointer=checkpointer)
80
+
81
+ # Invoke with thread_id for state retention (same)
82
+ response = app.invoke(
83
+ {"messages": [{"role": "user", "content": "Weather in SF?"}]},
84
+ config={"configurable": {"thread_id": 42}}
85
+ )
86
+ print(response["messages"][-1].content) # Outputs weather details
87
+ ```
88
+
89
+ Key:
90
+ 1. Uses `langchain_groq.ChatGroq`
91
+ 2. Specifies Groq model name (`mixtral-8x7b-32768` or `llama2-70b-4096`)
92
+ 3. Requires `GROQ_API_KEY` environment variable
93
+
94
+ Set your API key:
95
+ ```python
96
+ os.environ["GROQ_API_KEY"] = "your-key-here"
97
+ ```
98
+
99
  ---
100
+
101
+ ## πŸš€ Running the Streamlit App
102
+
103
+ This project includes a Streamlit-based web interface for interacting with the Groq ReAct Agent. Follow the steps below to set up and run the app.
104
+
105
+ ### Prerequisites
106
+ 1. **Python 3.8+**: Ensure Python is installed on your system.
107
+ 2. **Groq API Key**: Obtain your API key from the [Groq Cloud Console](https://console.groq.com/).
108
+
109
+ ### Steps to Run
110
+ 1. Clone the repository:
111
+ ```bash
112
+ git clone https://github.com/aitiwari/langgraph.git
113
+ cd langgraph
114
+ ```
115
+
116
+ 2. Install the required dependencies:
117
+ ```bash
118
+ pip install -r requirements.txt
119
+ ```
120
+
121
+ 3. Set your Groq API key as an environment variable:
122
+ ```bash
123
+ export GROQ_API_KEY="your-api-key-here"
124
+ ```
125
+
126
+ 4. Start the Streamlit app:
127
+ ```bash
128
+ streamlit run app.py
129
+ ```
130
+
131
+ 5. Open your browser and navigate to the URL provided in the terminal (usually `http://localhost:8501`).
132
+
133
+ ### Using the App
134
+ - **Input Field**: Type your question or query in the chat input box at the bottom of the screen.
135
+ - **Chat History**: The conversation history will be displayed above the input field.
136
+ - **API Key**: If you didn't set the `GROQ_API_KEY` environment variable, you'll be prompted to enter it in the app.
137
+
138
+ ### Example Queries
139
+ - "What's the weather in San Francisco?"
140
+ - "Tell me about the weather in New York."
141
+
142
+ ### Stopping the App
143
+ To stop the Streamlit app, press `Ctrl+C` in the terminal where the app is running.
144
+
145
+ ---
146
+
147
+ ## 🌟 Use Cases
148
+
149
+ ### 1. Basic Chatbot
150
+ **Prompt**: What is generative AI?
151
+ **Reference**:
152
+ ![alt text](basic_chatbot.png)
153
+
154
+ ### 2. Chatbot with Tool
155
+ **Prompt**: Latest news from the India vs Australia match?
156
+ **Reference**:
157
+ ![alt text](chatbot_with_search_tool.png)
158
+
159
+ ### 3. Appointment Receptionist
160
+ **Prompt 1**: Book an appointment for priti.
161
+ **Prompt 2**: Yes or No.
162
+ **Reference**:
163
+ ![alt text](appointment_receptionist.png)
164
+
165
+ ### 4. Customer Support
166
+ **Reference**:
167
+ ![alt text](cs_flow.png)
168
+ ![alt text](customer_support.png)
169
+
170
  ---
171
 
172
+ ## πŸ“š Templates & Community
173
+ Explore prebuilt templates for chatbots, retrieval agents, and more:
174
+ ```bash
175
+ langgraph new # CLI to create apps from templates
176
+ ```
177
+ | Template | Description | Link |
178
+ |-------------------|--------------------------------------|----------------------------------------|
179
+ | ReAct Agent | Tool-calling agent with memory | [GitHub](https://github.com/langchain-ai/langgraph/tree/main/examples) |
180
+ | Retrieval Agent | RAG with dynamic context fetching | [Docs](https://langchain-ai.github.io/langgraph/concepts/template_applications/) |
181
 
182
+ ---
183
+
184
+ ## πŸ“– References
185
+ 1. [Official Documentation](https://langchain-ai.github.io/langgraph/)
186
+ 2. [GitHub Examples](https://github.com/langchain-ai/langgraph/tree/main/examples)
187
+ 3. [Agentic RAG Guide](https://medium.com/@wendell_89912/building-an-agentic-rag-with-langgraph-a-step-by-step-guide-009c5f0cce0a)
188
+ 4. [Production Case Studies](https://blog.langchain.dev/top-5-langgraph-agents-in-production-2024/)
189
 
190
+ ---
 
 
191
 
192
+ For advanced use cases (multi-agent systems, human-in-the-loop), refer to the [LangGraph Platform](https://www.langchain.com/langgraph) or explore the [LangChain Academy](https://github.com/gayashan4lk/langchain-academy-lang-graph-intro).
 
 
193
 
194
+ ---
 
 
 
195
 
196
+ This version integrates the Streamlit app instructions seamlessly into the existing structure while maintaining the original tone and style.
cs-flow.png β†’ cs_flow.png RENAMED
File without changes