KheemDH commited on
Commit
462a74e
·
1 Parent(s): 1a2c3c5
Files changed (2) hide show
  1. README.md +103 -11
  2. requirements.txt +293 -0
README.md CHANGED
@@ -1,13 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
- title: CustomerSupportAgent
3
- emoji: 📊
4
- colorFrom: indigo
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.13.0
8
- app_file: app.py
9
- pinned: false
10
- short_description: This presents an intelligent customer support agent.
11
- ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🧑‍💻 Intelligent Customer Support Agent with LangGraph 🤖
2
+
3
+ ## 📚 Project Overview
4
+
5
+ This repository presents an intelligent customer support agent powered by LangGraph—a robust tool designed for building intricate workflows with language models. The agent is programmed to classify customer queries, evaluate sentiment, and deliver suitable responses or escalate inquiries when necessary. In this version, the agent leverages the **browser-use** library to consult online resources and uses a Gradio interface for testing.
6
+
7
+ ## 💡 Purpose
8
+
9
+ Efficient and accurate customer support is essential in today’s competitive business landscape. By automating initial customer interactions, response times can be significantly shortened, thereby enhancing customer satisfaction. This project demonstrates how advanced language models combined with a graph-based workflow can be used to create an effective and scalable support system capable of handling diverse customer concerns.
10
+
11
+ ## 🛠 Core Components
12
+
13
+ - **State Management:** Utilizes `TypedDict` to track and manage the state of each customer interaction.
14
+ - **Query Categorization:** Classifies queries into categories such as Technical, Billing, or General.
15
+ - **Sentiment Analysis:** Assesses the emotional tone of customer queries.
16
+ - **Response Generation:** Constructs responses based on query category and sentiment.
17
+ - **Escalation Protocol:** Automatically escalates queries with negative sentiment to a human agent.
18
+ - **Browser-Based Assistance:** Employs the **browser-use** library to consult online sources for informed, up-to-date responses.
19
+ - **Workflow Graph:** Leverages LangGraph to build an adaptable and extendable workflow.
20
+
21
+ ## 📝 How It Works
22
+
23
+ 1. **Setup:** Install the necessary libraries and prepare the Python environment.
24
+ 2. **State Design:** Create a structure to store query data (category, sentiment, response).
25
+ 3. **Node Functions:** Define functions for categorization, sentiment analysis, and generating responses.
26
+ 4. **Graph Design:** Use `StateGraph` to establish the workflow, incorporating nodes and edges for the complete support process.
27
+ 5. **Routing Logic:** Conditionally route the query based on its category and sentiment.
28
+ 6. **Graph Compilation:** Compile the workflow into an executable application.
29
+ 7. **Execution:** Process customer queries through the workflow and present results via the Gradio UI.
30
+
31
+ ## 📊 Workflow Diagram
32
+
33
+ The following diagram illustrates the workflow of the customer support agent—from query categorization and sentiment analysis to routing and escalation:
34
+
35
+ ![Customer Support Workflow](image.jpg)
36
+
37
+ ## 📊 Browser Use
38
+
39
+ ![Customer Support Workflow](agent_history.gif)
40
+
41
+ ## ✅ Project Summary
42
+
43
+ This project showcases the versatility and power of LangGraph in creating AI-driven workflows. By merging natural language processing with graph-based techniques and augmenting capabilities with browser-based data fetching, we’ve built a customer support agent capable of efficiently addressing a wide range of queries. The system is easily extendable and can be integrated into existing support pipelines or databases.
44
+
45
  ---
 
 
 
 
 
 
 
 
 
 
46
 
47
+ ## 🚀 Getting Started
48
+
49
+ Follow these steps to set up the project and run the customer support agent application.
50
+
51
+ ### 1. Clone the Repository
52
+
53
+ Clone this repository to your local machine:
54
+
55
+ ```bash
56
+ git clone https://github.com/alphatechlogics/LangGraphAgent.git
57
+ cd LangGraphAgent
58
+ ```
59
+
60
+ ### 2. Create a Virtual Environment
61
+
62
+ We recommend using uv to set up your Python environment:
63
+
64
+ ```bash
65
+ uv venv --python 3.11
66
+ source .venv/bin/activate
67
+ ```
68
+
69
+ Note: The prompt should now show your virtual environment (e.g., (LangGraphAgent)).
70
+
71
+ ### 3. Activate the Virtual Environment
72
+
73
+ ```bash
74
+ source venv/bin/activate
75
+ ```
76
+
77
+ ### 4. Install Required Dependencies
78
+
79
+ Install the necessary packages. We use uv pip to ensure packages are installed within the virtual environment:
80
+
81
+ ```bash
82
+ uv pip install langgraph langchain_openai gradio
83
+ uv pip install --pre browser-use
84
+ playwright install
85
+ ```
86
+
87
+ ### 5. Set Up Your OpenAI API Key
88
+
89
+ Create a .env file in the project root directory and add your OpenAI API key. This is required to interact with the OpenAI models:
90
+
91
+ ```makefile
92
+ OPENAI_API_KEY=your_openai_api_key_here
93
+ ```
94
+
95
+ ### 6. Run the Application
96
+
97
+ After installing the dependencies and setting up the .env file, you can run the application:
98
+
99
+ ```bash
100
+ python customer_support_gradio.py
101
+ ```
102
+
103
+ ### 7. Access the App
104
+
105
+ Once the app is running, open your browser and navigate to the URL shown in the terminal (typically `http://127.0.0.1:7860`) to interact with the customer support agent.
requirements.txt ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ aiohappyeyeballs==2.4.4
3
+ aiohttp==3.11.11
4
+ aiosignal==1.3.2
5
+ altair==5.5.0
6
+ annotated-types==0.7.0
7
+ antlr4-python3-runtime==4.9.3
8
+ anyio==4.7.0
9
+ apturl==0.5.2
10
+ asgiref==3.5.0
11
+ async-timeout==4.0.3
12
+ attrs==24.3.0
13
+ backoff==2.2.1
14
+ bcrypt==4.2.1
15
+ beautifulsoup4==4.12.3
16
+ blinker==1.4
17
+ Brlapi==0.8.3
18
+ build==1.2.2.post1
19
+ cachetools==5.5.0
20
+ certifi==2020.6.20
21
+ cffi==1.17.1
22
+ chardet==4.0.0
23
+ charset-normalizer==3.4.1
24
+ chroma-hnswlib==0.7.3
25
+ chromadb==0.4.14
26
+ click==8.0.3
27
+ colorama==0.4.4
28
+ coloredlogs==15.0.1
29
+ command-not-found==0.3
30
+ contourpy==1.3.1
31
+ cryptography==44.0.0
32
+ cupshelpers==1.0
33
+ cycler==0.12.1
34
+ dataclasses-json==0.6.7
35
+ dbus-python==1.2.18
36
+ defer==1.0.6
37
+ Deprecated==1.2.15
38
+ distro==1.7.0
39
+ distro-info==1.1+ubuntu0.2
40
+ duplicity==0.8.21
41
+ durationpy==0.9
42
+ effdet==0.4.1
43
+ emoji==2.14.0
44
+ et_xmlfile==2.0.0
45
+ eval_type_backport==0.2.2
46
+ exceptiongroup==1.2.2
47
+ fastapi==0.115.6
48
+ fasteners==0.14.1
49
+ ffmpy==0.5.0
50
+ filelock==3.16.1
51
+ filetype==1.2.0
52
+ flatbuffers==24.12.23
53
+ fonttools==4.55.3
54
+ frozenlist==1.5.0
55
+ fsspec==2024.12.0
56
+ future==0.18.2
57
+ gitdb==4.0.12
58
+ GitPython==3.1.44
59
+ google-api-core==2.24.0
60
+ google-auth==2.37.0
61
+ google-cloud-vision==3.9.0
62
+ googleapis-common-protos==1.66.0
63
+ gradio==5.12.0
64
+ gradio_client==1.5.4
65
+ greenlet==3.1.1
66
+ grpcio==1.68.1
67
+ grpcio-status==1.68.1
68
+ gyp==0.1
69
+ h11==0.13.0
70
+ html5lib==1.1
71
+ httpcore==1.0.7
72
+ httplib2==0.20.2
73
+ httptools==0.6.4
74
+ httpx==0.28.1
75
+ httpx-sse==0.4.0
76
+ huggingface-hub==0.27.0
77
+ humanfriendly==10.0
78
+ idna==3.3
79
+ importlib_metadata==8.5.0
80
+ importlib_resources==6.4.5
81
+ iopath==0.1.10
82
+ jeepney==0.7.1
83
+ Jinja2==3.1.5
84
+ jiter==0.8.2
85
+ joblib==1.4.2
86
+ jq==1.8.0
87
+ jsonpatch==1.33
88
+ jsonpath-python==1.0.6
89
+ jsonpointer==3.0.0
90
+ jsonschema==4.23.0
91
+ jsonschema-specifications==2024.10.1
92
+ keyring==23.5.0
93
+ kiwisolver==1.4.8
94
+ kubernetes==31.0.0
95
+ langchain==0.3.13
96
+ langchain-chroma==0.1.4
97
+ langchain-community==0.3.13
98
+ langchain-core==0.3.28
99
+ langchain-openai==0.2.14
100
+ langchain-text-splitters==0.3.4
101
+ langdetect==1.0.9
102
+ langgraph==0.2.63
103
+ langgraph-checkpoint==2.0.10
104
+ langgraph-sdk==0.1.51
105
+ langsmith==0.2.6
106
+ language-selector==0.1
107
+ launchpadlib==1.10.16
108
+ layoutparser==0.3.4
109
+ lazr.restfulclient==0.14.4
110
+ lazr.uri==1.0.6
111
+ lockfile==0.12.2
112
+ louis==3.20.0
113
+ lxml==5.3.0
114
+ macaroonbakery==1.3.1
115
+ Mako==1.1.3
116
+ Markdown==3.7
117
+ markdown-it-py==3.0.0
118
+ MarkupSafe==2.0.1
119
+ marshmallow==3.23.2
120
+ matplotlib==3.10.0
121
+ mdurl==0.1.2
122
+ mmh3==5.0.1
123
+ monotonic==1.6
124
+ more-itertools==8.10.0
125
+ mpmath==1.3.0
126
+ msgpack==1.1.0
127
+ multidict==6.1.0
128
+ mypy-extensions==1.0.0
129
+ narwhals==1.22.0
130
+ nest-asyncio==1.6.0
131
+ netifaces==0.11.0
132
+ networkx==3.4.2
133
+ nltk==3.9.1
134
+ numpy==1.26.4
135
+ nvidia-cublas-cu12==12.4.5.8
136
+ nvidia-cuda-cupti-cu12==12.4.127
137
+ nvidia-cuda-nvrtc-cu12==12.4.127
138
+ nvidia-cuda-runtime-cu12==12.4.127
139
+ nvidia-cudnn-cu12==9.1.0.70
140
+ nvidia-cufft-cu12==11.2.1.3
141
+ nvidia-curand-cu12==10.3.5.147
142
+ nvidia-cusolver-cu12==11.6.1.9
143
+ nvidia-cusparse-cu12==12.3.1.170
144
+ nvidia-nccl-cu12==2.21.5
145
+ nvidia-nvjitlink-cu12==12.4.127
146
+ nvidia-nvtx-cu12==12.4.127
147
+ oauthlib==3.2.2
148
+ olefile==0.46
149
+ omegaconf==2.3.0
150
+ onnx==1.17.0
151
+ onnxruntime==1.20.1
152
+ openai==1.58.1
153
+ opencv-python==4.10.0.84
154
+ openpyxl==3.1.5
155
+ opentelemetry-api==1.29.0
156
+ opentelemetry-exporter-otlp-proto-common==1.29.0
157
+ opentelemetry-exporter-otlp-proto-grpc==1.29.0
158
+ opentelemetry-instrumentation==0.50b0
159
+ opentelemetry-instrumentation-asgi==0.50b0
160
+ opentelemetry-instrumentation-fastapi==0.50b0
161
+ opentelemetry-proto==1.29.0
162
+ opentelemetry-sdk==1.29.0
163
+ opentelemetry-semantic-conventions==0.50b0
164
+ opentelemetry-util-http==0.50b0
165
+ orjson==3.10.12
166
+ overrides==7.7.0
167
+ packaging==24.2
168
+ pandas==2.2.3
169
+ paramiko==2.9.3
170
+ pdf2image==1.17.0
171
+ pdfminer.six==20231228
172
+ pdfplumber==0.11.4
173
+ pexpect==4.8.0
174
+ pi_heif==0.21.0
175
+ pikepdf==9.4.2
176
+ pillow==11.0.0
177
+ portalocker==3.0.0
178
+ posthog==3.7.4
179
+ propcache==0.2.1
180
+ proto-plus==1.25.0
181
+ protobuf==5.29.2
182
+ psutil==6.1.1
183
+ ptyprocess==0.7.0
184
+ pulsar-client==3.5.0
185
+ pyarrow==19.0.0
186
+ pyasn1==0.6.1
187
+ pyasn1_modules==0.4.1
188
+ pycairo==1.20.1
189
+ pycocotools==2.0.8
190
+ pycparser==2.22
191
+ pycups==2.0.1
192
+ pydantic==2.9.2
193
+ pydantic-settings==2.7.0
194
+ pydantic_core==2.23.4
195
+ pydeck==0.9.1
196
+ pydub==0.25.1
197
+ Pygments==2.18.0
198
+ PyGObject==3.42.1
199
+ PyJWT==2.3.0
200
+ pymacaroons==0.13.0
201
+ PyMuPDF==1.25.1
202
+ PyNaCl==1.5.0
203
+ pypandoc==1.14
204
+ pyparsing==2.4.7
205
+ pypdf==5.1.0
206
+ PyPDF2==3.0.1
207
+ pypdfium2==4.30.1
208
+ PyPika==0.48.9
209
+ pyproject_hooks==1.2.0
210
+ pyRFC3339==1.1
211
+ python-apt==2.4.0+ubuntu4
212
+ python-dateutil==2.9.0.post0
213
+ python-debian==0.1.43+ubuntu1.1
214
+ python-docx==1.1.2
215
+ python-dotenv==1.0.1
216
+ python-iso639==2024.10.22
217
+ python-magic==0.4.27
218
+ python-multipart==0.0.20
219
+ python-oxmsg==0.0.1
220
+ python-pptx==1.0.2
221
+ pytz==2022.1
222
+ pyxdg==0.27
223
+ PyYAML==6.0.2
224
+ RapidFuzz==3.11.0
225
+ referencing==0.36.0
226
+ regex==2024.11.6
227
+ reportlab==3.6.8
228
+ requests==2.32.3
229
+ requests-oauthlib==2.0.0
230
+ requests-toolbelt==1.0.0
231
+ rich==13.9.4
232
+ rpds-py==0.22.3
233
+ rsa==4.9
234
+ ruff==0.9.2
235
+ safehttpx==0.1.6
236
+ safetensors==0.4.5
237
+ scipy==1.14.1
238
+ screen-resolution-extra==0.0.0
239
+ SecretStorage==3.3.1
240
+ semantic-version==2.10.0
241
+ shellingham==1.5.4
242
+ six==1.16.0
243
+ smmap==5.0.2
244
+ sniffio==1.3.1
245
+ soupsieve==2.6
246
+ SQLAlchemy==2.0.36
247
+ starlette==0.41.3
248
+ streamlit==1.41.1
249
+ sympy==1.13.1
250
+ systemd-python==234
251
+ tenacity==9.0.0
252
+ tiktoken==0.8.0
253
+ timm==1.0.12
254
+ tokenizers==0.21.0
255
+ toml==0.10.2
256
+ tomli==2.2.1
257
+ tomlkit==0.13.2
258
+ torch==2.5.1
259
+ torchvision==0.20.1
260
+ tornado==6.4.2
261
+ tqdm==4.67.1
262
+ transformers==4.47.1
263
+ triton==3.1.0
264
+ typer==0.15.1
265
+ typing-inspect==0.9.0
266
+ typing_extensions==4.12.2
267
+ tzdata==2024.2
268
+ ubuntu-drivers-common==0.0.0
269
+ ubuntu-pro-client==8001
270
+ ufw==0.36.1
271
+ unattended-upgrades==0.1
272
+ unstructured==0.16.11
273
+ unstructured-client==0.28.1
274
+ unstructured-inference==0.8.1
275
+ unstructured.pytesseract==0.3.13
276
+ urllib3==1.26.5
277
+ usb-creator==0.3.7
278
+ uvicorn==0.34.0
279
+ uvloop==0.21.0
280
+ wadllib==1.3.6
281
+ watchdog==6.0.0
282
+ watchfiles==1.0.3
283
+ webencodings==0.5.1
284
+ websocket-client==1.8.0
285
+ websockets==14.1
286
+ wrapt==1.17.0
287
+ wsproto==1.0.0
288
+ xdg==5
289
+ xkit==0.0.0
290
+ xlrd==2.0.1
291
+ XlsxWriter==3.2.0
292
+ yarl==1.18.3
293
+ zipp==3.21.0