pylogtracer 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. pylogtracer-0.0.2/LICENSE +201 -0
  2. pylogtracer-0.0.2/PKG-INFO +380 -0
  3. pylogtracer-0.0.2/README.md +330 -0
  4. pylogtracer-0.0.2/pyproject.toml +127 -0
  5. pylogtracer-0.0.2/setup.cfg +76 -0
  6. pylogtracer-0.0.2/setup.py +30 -0
  7. pylogtracer-0.0.2/src/pylogtracer/__init__.py +5 -0
  8. pylogtracer-0.0.2/src/pylogtracer/agents/__init__.py +0 -0
  9. pylogtracer-0.0.2/src/pylogtracer/agents/qa_agent.py +448 -0
  10. pylogtracer-0.0.2/src/pylogtracer/agents/root_cause_analyzer.py +185 -0
  11. pylogtracer-0.0.2/src/pylogtracer/llm/__init__.py +0 -0
  12. pylogtracer-0.0.2/src/pylogtracer/llm/llm_factory.py +229 -0
  13. pylogtracer-0.0.2/src/pylogtracer/logtracer.py +582 -0
  14. pylogtracer-0.0.2/src/pylogtracer/multiagent/__init__.py +0 -0
  15. pylogtracer-0.0.2/src/pylogtracer/multiagent/context_bridge.py +168 -0
  16. pylogtracer-0.0.2/src/pylogtracer/preprocessing/__init__.py +0 -0
  17. pylogtracer-0.0.2/src/pylogtracer/preprocessing/error_extractor.py +285 -0
  18. pylogtracer-0.0.2/src/pylogtracer/preprocessing/error_type_classifier.py +592 -0
  19. pylogtracer-0.0.2/src/pylogtracer/preprocessing/smart_reader.py +388 -0
  20. pylogtracer-0.0.2/src/pylogtracer/utils/__init__.py +0 -0
  21. pylogtracer-0.0.2/src/pylogtracer/utils/time_resolver.py +429 -0
  22. pylogtracer-0.0.2/src/pylogtracer.egg-info/PKG-INFO +380 -0
  23. pylogtracer-0.0.2/src/pylogtracer.egg-info/SOURCES.txt +25 -0
  24. pylogtracer-0.0.2/src/pylogtracer.egg-info/dependency_links.txt +1 -0
  25. pylogtracer-0.0.2/src/pylogtracer.egg-info/requires.txt +18 -0
  26. pylogtracer-0.0.2/src/pylogtracer.egg-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,380 @@
1
+ Metadata-Version: 2.4
2
+ Name: pylogtracer
3
+ Version: 0.0.2
4
+ Summary: Provider-agnostic log analysis package with LLM support and LangGraph ReAct agent
5
+ Home-page: https://github.com/Karthik.K/pylogtracer
6
+ Author: Karthik.K
7
+ Author-email: pylogtracer <karthikkashi98@gmail.com>
8
+ License-Expression: MIT
9
+ Project-URL: Homepage, https://github.com/KarthikKashi98/pylogtracer
10
+ Project-URL: Repository, https://github.com/KarthikKashi98/pylogtracer
11
+ Project-URL: Issues, https://github.com/KarthikKashi98/pylogtracer/issues
12
+ Project-URL: Documentation, https://github.com/KarthikKashi98/pylogtracer#readme
13
+ Keywords: log analysis,llm,langchain,langgraph,log tracer,root cause analysis,devops,observability,ollama,openai,anthropic
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: System :: Logging
25
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
26
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: langchain>=0.2.0
31
+ Requires-Dist: langchain-core>=0.2.0
32
+ Requires-Dist: langchain-openai>=0.1.0
33
+ Requires-Dist: langchain-anthropic>=0.1.0
34
+ Requires-Dist: langchain-ollama>=0.1.0
35
+ Requires-Dist: langgraph>=0.1.0
36
+ Requires-Dist: pydantic>=2.0.0
37
+ Requires-Dist: python-dotenv>=1.0.0
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=7.0; extra == "dev"
40
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
41
+ Requires-Dist: flake8>=6.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.0; extra == "dev"
43
+ Requires-Dist: twine>=5.0; extra == "dev"
44
+ Requires-Dist: build>=1.0; extra == "dev"
45
+ Requires-Dist: tox>=4.0; extra == "dev"
46
+ Requires-Dist: tox-gh-actions>=3.0; extra == "dev"
47
+ Dynamic: author
48
+ Dynamic: home-page
49
+ Dynamic: license-file
50
+
51
+ # pylogtracer
52
+
53
+ > Provider-agnostic log analysis package with LLM support and a dynamic ReAct agent.
54
+
55
+ [![Python](https://img.shields.io/badge/python-3.9%2B-blue)](https://www.python.org/)
56
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
57
+ [![PyPI](https://img.shields.io/badge/pypi-pylogtracer-orange)](https://pypi.org/project/pylogtracer/)
58
+
59
+ ---
60
+
61
+ ## What is pylogtracer?
62
+
63
+ `pylogtracer` is a Python package that helps you analyze log files using LLMs. It works in two modes:
64
+
65
+ - **Library mode** — direct function calls, no agent needed, works without LLM
66
+ - **Agent mode** — ask free-form questions, a LangGraph ReAct agent decides which tools to call
67
+
68
+ It supports any LLM provider — Ollama (local), OpenAI, Anthropic, or any custom API.
69
+
70
+ ---
71
+
72
+ ## Features
73
+
74
+ - **Provider agnostic** — OpenAI, Anthropic, Ollama, or any OpenAI-compatible API
75
+ - **Keyword learning** — LLM learns error patterns once, reuses them for free next time
76
+ - **ReAct agent** — multi-step reasoning, calls multiple tools per question
77
+ - **Time resolver** — understands `"10am"`, `"yesterday"`, `"2 hours ago"`
78
+ - **Cluster analysis** — groups related errors into incidents automatically
79
+ - **Search** — find any log entry by keyword, incident ID, or error snippet
80
+ - **No .env required** — pass config directly to `LogTracer`
81
+
82
+ ---
83
+
84
+ ## Installation
85
+
86
+ ```bash
87
+ pip install pylogtracer
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Quick Start
93
+
94
+ ```python
95
+ from pylogtracer import LogTracer
96
+
97
+ # Ollama (local, no API key needed)
98
+ tracer = LogTracer(
99
+ file_path = "app.log",
100
+ llm_config = {
101
+ "provider": "ollama",
102
+ "model": "qwen2.5:7b",
103
+ "base_url": "http://localhost:11434"
104
+ }
105
+ )
106
+
107
+ # Library mode — no LLM needed
108
+ print(tracer.summary())
109
+ print(tracer.error_frequency())
110
+ print(tracer.health_check())
111
+
112
+ # Agent mode — LLM required
113
+ print(tracer.ask("what caused the crash at 10am?"))
114
+ print(tracer.ask("show INC1000004 related logs and how long it lasted"))
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Supported Providers
120
+
121
+ | Provider | Example Model | API Key |
122
+ |-----------|---------------------------------|----------|
123
+ | Ollama | `qwen2.5:7b`, `llama3`, `mistral` | No |
124
+ | OpenAI | `gpt-4o-mini`, `gpt-4o` | Yes |
125
+ | Anthropic | `claude-3-5-haiku-20241022` | Yes |
126
+ | Custom | Any OpenAI-compatible API | Optional |
127
+
128
+ ```python
129
+ # OpenAI
130
+ tracer = LogTracer("app.log", llm_config={
131
+ "provider": "openai",
132
+ "model": "gpt-4o-mini",
133
+ "api_key": "sk-..."
134
+ })
135
+
136
+ # Anthropic
137
+ tracer = LogTracer("app.log", llm_config={
138
+ "provider": "anthropic",
139
+ "model": "claude-3-5-haiku-20241022",
140
+ "api_key": "sk-ant-..."
141
+ })
142
+
143
+ # Custom / vLLM / LM Studio
144
+ tracer = LogTracer("app.log", llm_config={
145
+ "provider": "custom",
146
+ "model": "my-model",
147
+ "base_url": "http://my-server:8000/v1",
148
+ "api_key": "optional"
149
+ })
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Library Mode — All Methods
155
+
156
+ ```python
157
+ tracer = LogTracer("app.log") # no LLM needed for library mode
158
+
159
+ # Overview
160
+ tracer.summary()
161
+ # {'total_entries': 100, 'total_errors': 30, 'total_clusters': 11,
162
+ # 'error_types': [...], 'first_error': '...', 'last_error': '...'}
163
+
164
+ # Error counts
165
+ tracer.error_frequency()
166
+ tracer.error_frequency(date="2024-03-01")
167
+ tracer.error_frequency(from_dt="2024-03-01 09:00:00", to_dt="2024-03-01 11:00:00")
168
+
169
+ # Filter errors
170
+ tracer.errors_by_date("2024-03-01")
171
+ tracer.errors_in_range("2024-03-01 09:00:00", "2024-03-01 11:00:00")
172
+
173
+ # Last incident
174
+ tracer.last_incident()
175
+
176
+ # System health
177
+ tracer.health_check()
178
+ # {'healthy': False, 'status': 'CRITICAL', 'total_errors': 30, ...}
179
+
180
+ # Incident duration
181
+ tracer.incident_duration()
182
+ # {'start': '...', 'end': '...', 'duration_human': '6 minutes 12 seconds', ...}
183
+
184
+ # Search
185
+ tracer.search("INC1000001") # by incident ID
186
+ tracer.search("connection refused") # by keyword
187
+ tracer.get_related_logs("INC1000004") # all logs in same cluster
188
+ tracer.get_entry_details("INC1000004") # full entry with traceback
189
+
190
+ # Root cause (LLM required)
191
+ tracer.root_cause_analysis()
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Agent Mode — Ask Anything
197
+
198
+ ```python
199
+ tracer = LogTracer("app.log", llm_config={...})
200
+
201
+ # Simple questions
202
+ tracer.ask("what is the last error?")
203
+ tracer.ask("is the system healthy?")
204
+ tracer.ask("how many DB errors happened?")
205
+
206
+ # Time-based (auto-resolved — no need to specify exact timestamps)
207
+ tracer.ask("what errors happened at 10am?")
208
+ tracer.ask("show errors from yesterday")
209
+ tracer.ask("what happened 2 hours ago?")
210
+ tracer.ask("errors between 9am and 11am")
211
+
212
+ # Identifier search
213
+ tracer.ask("show me INC1000004 related logs")
214
+ tracer.ask("what happened with REQ-456?")
215
+
216
+ # Multi-step (agent calls multiple tools automatically)
217
+ tracer.ask("what caused the crash and how long did it last?")
218
+ tracer.ask("compare errors today vs yesterday")
219
+ tracer.ask("show INC1000004 related logs and diagnose the root cause")
220
+ ```
221
+
222
+ ---
223
+
224
+ ## How the Agent Works
225
+
226
+ The agent uses a **LangGraph ReAct loop** — it thinks, calls a tool, sees the result, and decides whether to call another tool or answer:
227
+
228
+ ```
229
+ User: "what caused the crash and how long did it last?"
230
+
231
+ [think] → I need last_incident first
232
+
233
+ [tool] → last_incident() → sees cluster
234
+
235
+ [think] → now I need root_cause and duration
236
+
237
+ [tool] → root_cause() → LLM analysis
238
+
239
+ [tool] → incident_duration() → 6 minutes 12 seconds
240
+
241
+ [think] → I have everything now
242
+
243
+ FINAL_ANSWER: "The crash was caused by..."
244
+ ```
245
+
246
+ ---
247
+
248
+ ## Time Resolution
249
+
250
+ The agent automatically understands relative time — no need for exact timestamps:
251
+
252
+ | You say | Resolved to |
253
+ |----------------------|------------------------------------|
254
+ | `"10am"` | today 10:00:00 → 10:59:59 |
255
+ | `"yesterday 2pm"` | yesterday 14:00:00 → 14:59:59 |
256
+ | `"this morning"` | today 06:00:00 → 12:00:00 |
257
+ | `"2 hours ago"` | now - 2h → now |
258
+ | `"last 30 minutes"` | now - 30m → now |
259
+ | `"last night"` | yesterday 20:00:00 → today 06:00:00|
260
+ | `"March 1"` | 2024-03-01 |
261
+
262
+ ---
263
+
264
+ ## Architecture
265
+
266
+ ```
267
+ from pylogtracer import LogTracer ← single entry point
268
+
269
+ LogTracer
270
+ ├── preprocessing/
271
+ │ ├── smart_reader.py log reading, filtering, search
272
+ │ ├── error_extractor.py clustering, deduplication
273
+ │ └── error_type_classifier.py regex + keyword learning + LLM
274
+
275
+ ├── agents/
276
+ │ ├── qa_agent.py LangGraph ReAct agent (ask())
277
+ │ └── root_cause_analyzer.py LLM root cause analysis
278
+
279
+ ├── multiagent/
280
+ │ └── context_bridge.py agent-to-agent context loop
281
+
282
+ ├── llm/
283
+ │ └── llm_factory.py provider-agnostic LLM factory
284
+
285
+ └── utils/
286
+ └── time_resolver.py relative time resolution
287
+ ```
288
+
289
+ ---
290
+
291
+ ## How Keyword Learning Works
292
+
293
+ The classifier uses a 3-pass system to minimize LLM calls:
294
+
295
+ ```
296
+ Pass 1 — Named exception regex (free):
297
+ "ConnectionError: timed out" → ConnectionError ✓
298
+
299
+ Pass 2 — Keyword store (free, learned this session):
300
+ "database connection refused" → DatabaseConnectionError ✓
301
+ (learned from a previous LLM call this session)
302
+
303
+ Pass 3 — LLM batch (only truly unknown errors):
304
+ LLM classifies + returns keywords for future use
305
+ Keywords stored → next similar error is FREE
306
+ ```
307
+
308
+ ---
309
+
310
+ ## Configuration Options
311
+
312
+ ```python
313
+ LogTracer(
314
+ file_path = "app.log", # path to log file
315
+ llm_config = { # LLM provider config
316
+ "provider": "ollama",
317
+ "model": "qwen2.5:7b",
318
+ "base_url": "http://localhost:11434",
319
+ "api_key": "optional",
320
+ "temperature": 0.0,
321
+ "max_tokens": 1024,
322
+ },
323
+ gap_seconds = 60, # seconds between entries to split incidents
324
+ max_retries = 2, # max times LLM can request more context
325
+ )
326
+ ```
327
+
328
+ ---
329
+
330
+ ## Requirements
331
+
332
+ ```
333
+ langchain>=0.2.0
334
+ langchain-core>=0.2.0
335
+ langchain-openai>=0.1.0
336
+ langchain-anthropic>=0.1.0
337
+ langchain-ollama>=0.1.0
338
+ langgraph>=0.1.0
339
+ pydantic>=2.0.0
340
+ python-dotenv>=1.0.0
341
+ ```
342
+
343
+ ---
344
+
345
+ ## Running Tests
346
+
347
+ ```bash
348
+ # Install dev dependencies
349
+ pip install pytest pytest-cov
350
+
351
+ # Run all tests
352
+ pytest tests/ -v
353
+
354
+ # Run specific test
355
+ pytest tests/test_smart_reader.py -v
356
+ ```
357
+
358
+ ---
359
+
360
+ ## CI/CD
361
+
362
+ Every push to `main` runs tests on Python 3.10, 3.11, and 3.12.
363
+ Every GitHub Release automatically publishes to PyPI.
364
+
365
+ ---
366
+
367
+ ## License
368
+
369
+ MIT
370
+
371
+ ---
372
+
373
+ ## Contributing
374
+
375
+ Pull requests welcome! Please run tests before submitting.
376
+
377
+ ```bash
378
+ pip install -e .
379
+ pytest tests/ -v
380
+ ```