llm-agents-from-scratch 0.0.1__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 (52) hide show
  1. llm_agents_from_scratch-0.0.1/.github/dependabot.yml +19 -0
  2. llm_agents_from_scratch-0.0.1/.github/workflows/lint.yml +34 -0
  3. llm_agents_from_scratch-0.0.1/.github/workflows/release.yml +56 -0
  4. llm_agents_from_scratch-0.0.1/.github/workflows/unit_test.yml +46 -0
  5. llm_agents_from_scratch-0.0.1/.gitignore +27 -0
  6. llm_agents_from_scratch-0.0.1/.pre-commit-config.yaml +75 -0
  7. llm_agents_from_scratch-0.0.1/.python-versions +4 -0
  8. llm_agents_from_scratch-0.0.1/CHANGELOG.md +26 -0
  9. llm_agents_from_scratch-0.0.1/LICENSE +201 -0
  10. llm_agents_from_scratch-0.0.1/Makefile +21 -0
  11. llm_agents_from_scratch-0.0.1/PKG-INFO +21 -0
  12. llm_agents_from_scratch-0.0.1/README.md +6 -0
  13. llm_agents_from_scratch-0.0.1/codecov.yml +8 -0
  14. llm_agents_from_scratch-0.0.1/docs/index.md +0 -0
  15. llm_agents_from_scratch-0.0.1/mypy.ini +8 -0
  16. llm_agents_from_scratch-0.0.1/pyproject.toml +78 -0
  17. llm_agents_from_scratch-0.0.1/pytest.ini +2 -0
  18. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/__init__.py +13 -0
  19. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/_version.py +1 -0
  20. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/base/__init__.py +0 -0
  21. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/base/llm.py +69 -0
  22. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/base/tool.py +85 -0
  23. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/core/__init__.py +4 -0
  24. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/core/agent.py +63 -0
  25. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/core/task_handler.py +76 -0
  26. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/data_structures/__init__.py +18 -0
  27. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/data_structures/agent.py +54 -0
  28. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/data_structures/llm.py +43 -0
  29. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/data_structures/tool.py +30 -0
  30. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/listings/__init__.py +0 -0
  31. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/listings/ch02/__init__.py +0 -0
  32. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/llms/__init__.py +3 -0
  33. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/llms/ollama/__init__.py +3 -0
  34. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/llms/ollama/llm.py +126 -0
  35. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/llms/ollama/utils.py +175 -0
  36. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/py.typed +0 -0
  37. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/tools/__init__.py +3 -0
  38. llm_agents_from_scratch-0.0.1/src/llm_agents_from_scratch/tools/simple_function.py +209 -0
  39. llm_agents_from_scratch-0.0.1/tests/__init__.py +0 -0
  40. llm_agents_from_scratch-0.0.1/tests/api/__init__.py +0 -0
  41. llm_agents_from_scratch-0.0.1/tests/api/test_data_structure_imports.py +17 -0
  42. llm_agents_from_scratch-0.0.1/tests/api/test_llm_imports.py +15 -0
  43. llm_agents_from_scratch-0.0.1/tests/api/test_root_imports.py +15 -0
  44. llm_agents_from_scratch-0.0.1/tests/conftest.py +44 -0
  45. llm_agents_from_scratch-0.0.1/tests/llms/__init__.py +0 -0
  46. llm_agents_from_scratch-0.0.1/tests/llms/test_base.py +10 -0
  47. llm_agents_from_scratch-0.0.1/tests/llms/test_ollama.py +364 -0
  48. llm_agents_from_scratch-0.0.1/tests/test_agent.py +113 -0
  49. llm_agents_from_scratch-0.0.1/tests/tools/__init__.py +0 -0
  50. llm_agents_from_scratch-0.0.1/tests/tools/test_base.py +21 -0
  51. llm_agents_from_scratch-0.0.1/tests/tools/test_function_tool.py +185 -0
  52. llm_agents_from_scratch-0.0.1/uv.lock +1686 -0
@@ -0,0 +1,19 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
12
+ - package-ecosystem: "uv"
13
+ directory: "/"
14
+ schedule:
15
+ interval: "weekly"
16
+ groups:
17
+ all-python-packages:
18
+ patterns:
19
+ - "**"
@@ -0,0 +1,34 @@
1
+ name: Linting
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ types:
8
+ - opened
9
+ - synchronize
10
+ jobs:
11
+ lint:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: get code
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v6
19
+ with:
20
+ # Install a specific version of uv.
21
+ version: "0.5.21"
22
+ enable-cache: true
23
+
24
+ - name: "Set up Python"
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version: "3.13"
28
+
29
+ - name: Install the project
30
+ run: uv sync --all-extras --dev
31
+
32
+ - name: Run linter and formatter
33
+ run: |
34
+ uv run make lint
@@ -0,0 +1,56 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ packages: write
14
+ steps:
15
+ - name: Install apt dependencies
16
+ run: |
17
+ sudo apt-get update
18
+ sudo apt-get install libcurl4-openssl-dev libssl-dev
19
+ - uses: actions/checkout@v4.2.2
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v6
23
+ with:
24
+ # Install a specific version of uv.
25
+ version: "0.5.21"
26
+ enable-cache: true
27
+
28
+ - name: "Set up Python"
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: "3.13"
32
+
33
+ - name: Install the project
34
+ run: uv sync --all-extras --dev
35
+
36
+ - name: Build package
37
+ run: uv build
38
+
39
+ - name: Publish package
40
+ uses: pypa/gh-action-pypi-publish@v1.12.4
41
+ with:
42
+ user: __token__
43
+ password: ${{ secrets.PYPI_API_TOKEN }}
44
+
45
+ release_github:
46
+ needs: deploy
47
+ runs-on: ubuntu-latest
48
+ permissions:
49
+ contents: write
50
+ steps:
51
+ - name: Create GitHub Release
52
+ id: create_release
53
+ uses: ncipollo/release-action@v1.16.0
54
+ with:
55
+ artifacts: "dist/*"
56
+ generateReleaseNotes: true
@@ -0,0 +1,46 @@
1
+ name: Unit Testing and Upload Coverage
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ types:
8
+ - opened
9
+ - synchronize
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ id-token: write
15
+ contents: read
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.10", "3.11", "3.12","3.13"]
20
+ steps:
21
+ - name: get code
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v6
26
+ with:
27
+ # Install a specific version of uv.
28
+ version: "0.5.21"
29
+ enable-cache: true
30
+ python-version: ${{ matrix.python-version }}
31
+
32
+ - name: Install the project
33
+ run: uv sync --all-extras --dev
34
+
35
+ - name: Run tests
36
+ run: |
37
+ uv run make coverage
38
+
39
+ - if: matrix.python-version == '3.13'
40
+ name: Upload results to Codecov
41
+ uses: codecov/codecov-action@v5
42
+ with:
43
+ token: ${{ secrets.CODECOV_TOKEN }}
44
+ slug: nerdai/llm-agents-from-scratch
45
+ fail_ci_if_error: true
46
+ verbose: true
@@ -0,0 +1,27 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # local dev
10
+ .ipynb_checkpoints
11
+ .__pycache__
12
+ __pycache__
13
+ .vscode
14
+ .mypy_cache
15
+ .pytest_cache
16
+ .ruff_cache
17
+ .env
18
+
19
+
20
+ # Virtual environments
21
+ .venv
22
+
23
+
24
+ # coverage
25
+ .coverage
26
+ coverage.xml
27
+ htmlcov/
@@ -0,0 +1,75 @@
1
+ ---
2
+ default_language_version:
3
+ python: python3.13
4
+
5
+ repos:
6
+ - repo: https://github.com/pre-commit/pre-commit-hooks
7
+ rev: v4.5.0
8
+ hooks:
9
+ - id: check-byte-order-marker
10
+ - id: check-merge-conflict
11
+ - id: check-symlinks
12
+ - id: check-toml
13
+ - id: check-yaml
14
+ args: [--unsafe]
15
+ - id: detect-private-key
16
+ - id: end-of-file-fixer
17
+ - id: mixed-line-ending
18
+ - id: trailing-whitespace
19
+ - repo: https://github.com/astral-sh/ruff-pre-commit
20
+ rev: v0.12.0
21
+ hooks:
22
+ - id: ruff-check
23
+ args: [ --fix ]
24
+ - id: ruff-format
25
+ - repo: https://github.com/psf/black-pre-commit-mirror
26
+ rev: 23.10.1
27
+ hooks:
28
+ - id: black
29
+ alias: black
30
+ exclude: ".*uv.lock"
31
+ args: [--line-length=79]
32
+ - repo: https://github.com/adamchainz/blacken-docs
33
+ rev: 1.16.0
34
+ hooks:
35
+ - id: blacken-docs
36
+ name: black-docs-text
37
+ alias: black
38
+ types_or: [rst, markdown, tex]
39
+ additional_dependencies: [black==23.10.1]
40
+ # Using PEP 8's line length in docs prevents excess left/right scrolling
41
+ args: [--line-length=79]
42
+ - repo: https://github.com/psf/black-pre-commit-mirror
43
+ rev: 23.10.1
44
+ hooks:
45
+ - id: black-jupyter
46
+ name: black-docs-jupyter
47
+ alias: black
48
+ files: ^(docs/|notebooks/)
49
+ # Using PEP 8's line length in docs prevents excess left/right scrolling
50
+ args: [--line-length=79]
51
+ - repo: https://github.com/pre-commit/mirrors-mypy
52
+ rev: v1.14.1
53
+ hooks:
54
+ - id: mypy
55
+ name: mypy
56
+ entry: mypy --config-file=mypy.ini --explicit-package-bases src
57
+ additional_dependencies:
58
+ - pydantic>=2.10.5
59
+ # https://github.com/python/mypy/issues/13916 -- duplicate module error with .pyi and .py files
60
+ pass_filenames: false
61
+ - repo: https://github.com/pappasam/toml-sort
62
+ rev: v0.23.1
63
+ hooks:
64
+ - id: toml-sort-fix
65
+ exclude: ".*uv.lock"
66
+ - repo: https://github.com/pycqa/isort
67
+ rev: 5.12.0
68
+ hooks:
69
+ - id: isort
70
+ args: [--profile=black, --line-length=79]
71
+ - repo: https://github.com/astral-sh/uv-pre-commit
72
+ # uv version.
73
+ rev: 0.5.8
74
+ hooks:
75
+ - id: uv-lock
@@ -0,0 +1,4 @@
1
+ 3.13
2
+ 3.12
3
+ 3.11
4
+ 3.10
@@ -0,0 +1,26 @@
1
+ <!-- markdownlint-disable-file MD024 -->
2
+
3
+ # Changelog
4
+
5
+ All notable changes to this project will be documented in this file.
6
+ The format is based on [Keep a Changelog](https://keepachangelog.com/),
7
+ and this project adheres to [Semantic Versioning](https://semver.org/).
8
+
9
+ ## Unreleased
10
+
11
+ ...
12
+
13
+ ## [0.0.1] - 2025-07-01
14
+
15
+ ### Added
16
+
17
+ - Add `AsyncSimpleFunctionTool` (#20)
18
+ - Rename `FunctionTool` to `SimpleFunctionTool` (#19)
19
+ - Implement `__call__` for `FunctionTool` (#18)
20
+ - Add simple function tool that allows for passing as an LLM tool (#16)
21
+ - Add tools to `OllamaLLM.chat` request and required utils (#14)
22
+ - Add initial implementation of `OllamaLLM` (#11)
23
+ - Add implementation of `base.tool.BaseTool` and relevant data structures (#12)
24
+ - Add `tools` to `LLM.chat` and update relevant data structures (#8)
25
+ - Add scaffolding for `TaskHandler` (#6)
26
+ - Add `LLMAgent` and associated data structures (#6)
@@ -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,21 @@
1
+ help: ## Show all Makefile targets.
2
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
3
+
4
+ format: ## Run code autoformatters (black).
5
+ pre-commit install
6
+ git ls-files | xargs pre-commit run black --files
7
+
8
+ lint: ## Run linters: pre-commit (black, ruff, codespell) and mypy
9
+ pre-commit install && git ls-files | xargs pre-commit run --show-diff-on-failure --files
10
+
11
+ test:
12
+ pytest tests -v --capture=no
13
+
14
+ coverage: # for ci purposes
15
+ pytest --cov llm_agents_from_scratch --cov-report=xml tests
16
+
17
+ coverage-report: ## Show coverage summary in terminal
18
+ coverage report -m
19
+
20
+ coverage-html: ## Generate HTML coverage report
21
+ coverage html
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-agents-from-scratch
3
+ Version: 0.0.1
4
+ Summary: Build an LLM agent, equipped with MCP, from scratch.
5
+ Author-email: Andrei Fajardo <andrei@nerdai.io>
6
+ License-Expression: Apache-2.0
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: asyncio>=3.4.3
10
+ Requires-Dist: jsonschema>=4.24.0
11
+ Requires-Dist: mcp[cli]>=1.9.4
12
+ Requires-Dist: ollama>=0.5.1
13
+ Requires-Dist: pydantic>=2.11.7
14
+ Description-Content-Type: text/markdown
15
+
16
+ # LLM Agents From Scratch
17
+
18
+ ---------------------------------------------------------------------------------------
19
+ [![Linting](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/lint.yml/badge.svg)](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/lint.yml)
20
+ [![Unit Testing and Upload Coverage](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/unit_test.yml/badge.svg)](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/unit_test.yml)
21
+ [![codecov](https://codecov.io/gh/nerdai/llm-agents-from-scratch/graph/badge.svg?token=I1CXFJXEXK)](https://codecov.io/gh/nerdai/llm-agents-from-scratch)
@@ -0,0 +1,6 @@
1
+ # LLM Agents From Scratch
2
+
3
+ ---------------------------------------------------------------------------------------
4
+ [![Linting](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/lint.yml/badge.svg)](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/lint.yml)
5
+ [![Unit Testing and Upload Coverage](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/unit_test.yml/badge.svg)](https://github.com/nerdai/llm-agents-from-scratch/actions/workflows/unit_test.yml)
6
+ [![codecov](https://codecov.io/gh/nerdai/llm-agents-from-scratch/graph/badge.svg?token=I1CXFJXEXK)](https://codecov.io/gh/nerdai/llm-agents-from-scratch)
@@ -0,0 +1,8 @@
1
+ coverage:
2
+ status:
3
+ project: # https://docs.codecov.com/docs/commit-status
4
+ default:
5
+ target: 80%
6
+ threshold: 5%
7
+ github_checks:
8
+ annotations: false
File without changes
@@ -0,0 +1,8 @@
1
+ [mypy]
2
+ warn_return_any = True
3
+ warn_unused_configs = True
4
+ disallow_untyped_defs = True
5
+ ignore_missing_imports = True
6
+ explicit_package_bases = True
7
+ mypy_path = "src"
8
+ plugins = pydantic.mypy
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [dependency-groups]
6
+ dev = [
7
+ "black>=24.10.0",
8
+ "codespell>=2.3.0",
9
+ "fire>=0.7.0",
10
+ "ipykernel>=6.29.5",
11
+ "isort>=5.13.2",
12
+ "mypy>=1.14.1",
13
+ "pre-commit>=4.1.0",
14
+ "pylint>=3.3.3",
15
+ "pytest>=8.3.4",
16
+ "pytest-asyncio>=0.25.2",
17
+ "pytest-cov>=6.0.0",
18
+ "pytest-mock>=3.14.0",
19
+ "ruff>=0.9.2"
20
+ ]
21
+
22
+ [project]
23
+ name = "llm-agents-from-scratch"
24
+ version = "0.0.1"
25
+ description = "Build an LLM agent, equipped with MCP, from scratch."
26
+ license = "Apache-2.0"
27
+ readme = "README.md"
28
+ authors = [
29
+ {name = "Andrei Fajardo", email = "andrei@nerdai.io"}
30
+ ]
31
+ requires-python = ">=3.10"
32
+ dependencies = [
33
+ "asyncio>=3.4.3",
34
+ "jsonschema>=4.24.0",
35
+ "mcp[cli]>=1.9.4",
36
+ "ollama>=0.5.1",
37
+ "pydantic>=2.11.7"
38
+ ]
39
+
40
+ [tool.ruff]
41
+ line-length = 80
42
+
43
+ [tool.ruff.format]
44
+ quote-style = "double"
45
+ indent-style = "space"
46
+ docstring-code-format = true
47
+
48
+ [tool.ruff.lint]
49
+ select = [
50
+ "A", # flake8-builtins
51
+ "B", # flake8-bugbear
52
+ "COM", # flake8-commas
53
+ "C4", # flake8-comprehensions
54
+ "RET", # flake8-return
55
+ "SIM", # flake8-simplify
56
+ "ICN", # flake8-import-conventions
57
+ "Q", # flake8-quotes
58
+ "RSE", # flake8-raise
59
+ "D", # pydocstyle
60
+ "E", # pycodestyle
61
+ "F", # pyflakes
62
+ "I", # isort
63
+ "W", # pycodestyle
64
+ "N", # pep8-naming
65
+ "ERA", # eradicate
66
+ "PL", # pylint
67
+ "D213" # Multiline Docstrings start on newline
68
+ ]
69
+ ignore = [
70
+ "A002" # Ignore variable `input` is shadowing a Python builtin in function
71
+ ]
72
+
73
+ [tool.ruff.lint.per-file-ignores]
74
+ "__init__.py" = ["D104"]
75
+ "tests/**/*.py" = ["D"]
76
+
77
+ [tool.ruff.lint.pydocstyle]
78
+ convention = "google" # Ensures Google style
@@ -0,0 +1,2 @@
1
+ [pytest]
2
+ asyncio_mode=auto
@@ -0,0 +1,13 @@
1
+ """Build an LLM agent from scratch."""
2
+
3
+ from llm_agents_from_scratch._version import VERSION
4
+
5
+ # Disable the F403 warning for wildcard imports
6
+ # ruff: noqa: F403, F401
7
+ from .core import *
8
+ from .core import __all__ as _core_all
9
+
10
+ __version__ = VERSION
11
+
12
+
13
+ __all__ = sorted(_core_all) # noqa: PLE0605
@@ -0,0 +1 @@
1
+ VERSION = "0.0.1"