ai-microcore 5.0.0__tar.gz → 5.0.0.dev2__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 (50) hide show
  1. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/LICENSE +19 -19
  2. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/PKG-INFO +37 -81
  3. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/README.md +304 -344
  4. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/__init__.py +233 -234
  5. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/_env.py +240 -228
  6. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/_llm_functions.py +299 -418
  7. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/_prepare_llm_args.py +47 -47
  8. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/ai_func/__init__.py +277 -278
  9. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/ai_func/ai-func.json.j2 +10 -10
  10. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/ai_func/ai-func.pythonic.j2 +9 -9
  11. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/ai_func/ai-func.tag.j2 +34 -34
  12. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/ai_modules.py +18 -18
  13. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/configuration.py +493 -611
  14. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/embedding_db/__init__.py +183 -183
  15. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/embedding_db/chromadb.py +187 -187
  16. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/embedding_db/qdrant.py +262 -262
  17. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/file_cache.py +103 -103
  18. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/file_storage.py +375 -378
  19. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/images.py +7 -14
  20. ai_microcore-5.0.0.dev2/microcore/interactive_setup.py +82 -0
  21. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/json_parsing.py +244 -244
  22. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/__init__.py +1 -1
  23. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/anthropic.py +139 -139
  24. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/google_genai.py +205 -281
  25. ai_microcore-5.0.0.dev2/microcore/llm/google_vertex_ai.py +145 -0
  26. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/local_llm.py +100 -100
  27. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/local_transformers.py +267 -267
  28. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/openai.py +344 -385
  29. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/llm/shared.py +40 -40
  30. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/lm_client.py +0 -0
  31. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/logging.py +186 -186
  32. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/mcp.py +421 -421
  33. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/message_types.py +99 -138
  34. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/metrics.py +42 -42
  35. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/presets.py +17 -18
  36. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/python.py +68 -68
  37. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/templating/__init__.py +0 -0
  38. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/templating/jinja2.py +28 -28
  39. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/text2speech/elevenlabs.py +73 -73
  40. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/tokenizing.py +79 -79
  41. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/types.py +58 -79
  42. ai_microcore-5.0.0.dev2/microcore/ui.py +98 -0
  43. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/utils.py +651 -656
  44. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/wrappers/__init__.py +0 -0
  45. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/wrappers/llm_response_wrapper.py +204 -177
  46. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/microcore/wrappers/prompt_wrapper.py +26 -26
  47. {ai_microcore-5.0.0 → ai_microcore-5.0.0.dev2}/pyproject.toml +60 -77
  48. ai_microcore-5.0.0/microcore/interactive_setup.py +0 -174
  49. ai_microcore-5.0.0/microcore/llm_backends.py +0 -301
  50. ai_microcore-5.0.0/microcore/ui.py +0 -219
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023—2026 Vitalii Stepanenko
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023—2025 Vitalii Stepanenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
20
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,14 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-microcore
3
- Version: 5.0.0
3
+ Version: 5.0.0.dev2
4
4
  Summary: # Minimalistic Foundation for AI Applications
5
- Keywords: llm,large language models,ai,similarity search,ai search,gpt,openai,framework,adapter,anthropic,google gemini,google vertex ai
5
+ Keywords: llm,large language models,ai,similarity search,ai search,gpt,openai,framework,adapter
6
6
  Author-email: Vitalii Stepanenko <mail@vitaliy.in>
7
7
  Maintainer-email: Vitalii Stepanenko <mail@vitaliy.in>
8
8
  Requires-Python: >=3.10
9
9
  Description-Content-Type: text/markdown
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Classifier: Programming Language :: Python :: 3.12
14
13
  Classifier: Programming Language :: Python :: 3.13
@@ -16,8 +15,6 @@ Classifier: License :: OSI Approved :: MIT License
16
15
  Classifier: Operating System :: OS Independent
17
16
  Classifier: Intended Audience :: Developers
18
17
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
19
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
- Classifier: Development Status :: 5 - Production/Stable
21
18
  License-File: LICENSE
22
19
  Requires-Dist: openai>=0.28.1,<2
23
20
  Requires-Dist: python-dotenv~=1.1.0
@@ -30,22 +27,20 @@ Requires-Dist: mcp>=1.10.1,<2.0
30
27
  Requires-Dist: fastmcp>=2.10.2,<3.0
31
28
  Requires-Dist: docstring_parser~=0.16.0
32
29
  Requires-Dist: httpx~=0.28.1
33
- Project-URL: Bug Tracker, https://github.com/Nayjest/ai-microcore/issues
34
30
  Project-URL: Source Code, https://github.com/Nayjest/ai-microcore
35
31
 
36
- # AI MicroCore: A Minimalistic Foundation for AI Applications
37
-
38
- <p align="center">
39
- <a href="https://pypi.org/project/ai-microcore/" target="_blank"><img src="https://img.shields.io/github/v/release/Nayjest/ai-microcore.svg" alt="Release Notes"></a>
40
- <a href="https://app.codacy.com/gh/Nayjest/ai-microcore/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade" target="_blank"><img src="https://app.codacy.com/project/badge/Grade/441d03416bc048828c649129530dcbc3" alt="Code Quality"></a>
41
- <a href="https://github.com/Nayjest/ai-microcore/actions/workflows/pylint.yml" target="_blank"><img src="https://github.com/Nayjest/ai-microcore/actions/workflows/pylint.yml/badge.svg" alt="Pylint"></a>
42
- <a href="https://github.com/Nayjest/ai-microcore/actions/workflows/tests.yml" target="_blank"><img src="https://github.com/Nayjest/ai-microcore/actions/workflows/tests.yml/badge.svg" alt="Tests"></a>
43
- <img src="https://raw.githubusercontent.com/Nayjest/ai-microcore/main/coverage.svg" alt="Code Coverage">
44
- <a href="https://github.com/vshymanskyy/StandWithUkraine/blob/main/README.md" target="_blank"><img src="https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/refs/heads/main/badges/StandWithUkraine.svg" alt="Stand With Ukraine"></a>
45
- <a href="https://github.com/Nayjest/ai-microcore/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/static/v1?label=license&message=MIT&color=d08aff" alt="License"></a>
32
+ <p align="right">
33
+ <a href="https://github.com/Nayjest/ai-microcore/releases" target="_blank"><img src="https://img.shields.io/github/v/release/Nayjest/ai-microcore.svg" alt="Release Notes"></a>
34
+ <a href="https://app.codacy.com/gh/Nayjest/ai-microcore/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade" target="_blank"><img src="https://app.codacy.com/project/badge/Grade/441d03416bc048828c649129530dcbc3" alt="Code Quality"></a>
35
+ <a href="https://github.com/Nayjest/ai-microcore/actions/workflows/pylint.yml" target="_blank"><img src="https://github.com/Nayjest/ai-microcore/actions/workflows/pylint.yml/badge.svg" alt="Pylint"></a>
36
+ <img src="https://raw.githubusercontent.com/Nayjest/ai-microcore/main/coverage.svg" alt="Code Coverage">
37
+ <a href="https://github.com/Nayjest/ai-microcore/actions/workflows/tests.yml" target="_blank"><img src="https://github.com/Nayjest/ai-microcore/actions/workflows/tests.yml/badge.svg" alt="Tests"></a>
38
+ <a href="https://github.com/Nayjest/ai-microcore/blob/main/LICENSE" target="_blank"><img src="https://img.shields.io/static/v1?label=license&message=MIT&color=d08aff" alt="License"></a>
46
39
  </p>
47
40
 
48
41
 
42
+ # AI MicroCore: A Minimalistic Foundation for AI Applications
43
+
49
44
  **MicroCore** is a collection of python adapters for Large Language Models
50
45
  and Vector Databases / Semantic Search APIs allowing to
51
46
  communicate with these services in a convenient way, make them easily switchable
@@ -55,7 +50,7 @@ It defines interfaces for features typically used in AI applications,
55
50
  which allows you to keep your application as simple as possible and try various models & services
56
51
  without need to change your application code.
57
52
 
58
- You can even switch between text completion and chat completion models only using configuration.
53
+ You even can switch between text completion and chat completion models only using configuration.
59
54
 
60
55
  Thanks to LLM-agnostic MCP integration,
61
56
  **MicroCore** connects MCP tools to any language models easily,
@@ -107,7 +102,7 @@ Similarity search features will work out of the box if you have the `chromadb` p
107
102
  There are a few options available for configuring microcore:
108
103
 
109
104
  - Use `microcore.configure(**params)`
110
- <br>💡 <small>All configuration options appear in IDE autocompletion tooltips</small>
105
+ <br>💡 <small>All configuration options should be available in IDE autocompletion tooltips</small>
111
106
  - Create a `.env` file in your project root; examples: [basic.env](https://github.com/Nayjest/ai-microcore/blob/main/.env.example), [Mistral Large.env](https://github.com/Nayjest/ai-microcore/blob/main/.env.mistral.example), [Anthropic Claude 3 Opus.env](https://github.com/Nayjest/ai-microcore/blob/main/.env.anthropic.example), [Gemini on Vertex AI.env](https://github.com/Nayjest/ai-microcore/blob/main/.env.google-vertex-gemini.example), [Gemini on AI Studio.env](https://github.com/Nayjest/ai-microcore/blob/main/.env.gemini.example)
112
107
  - Use a custom configuration file: `mc.configure(DOT_ENV_FILE='dev-config.ini')`
113
108
  - Define OS environment variables
@@ -115,20 +110,26 @@ There are a few options available for configuring microcore:
115
110
  For the full list of available configuration options, you may also check [`microcore/config.py`](https://github.com/Nayjest/ai-microcore/blob/main/microcore/configuration.py#L175).
116
111
 
117
112
  ### Installing vendor-specific packages
118
- For models working not via OpenAI API, you may need to install additional packages:
119
- #### Anthropic Claude
113
+ For the models working not via OpenAI API, you may need to install additional packages:
114
+ #### Anthropic Claude 3
120
115
  ```bash
121
116
  pip install anthropic
122
117
  ```
123
- #### Google Gemini via AI Studio or Vertex AI
118
+ #### Google Gemini via AI Studio
119
+ ```bash
120
+ pip install google-generativeai
121
+ ```
122
+ #### Google Gemini via Vertex AI
124
123
  ```bash
125
- pip install google-genai
124
+ pip install vertexai
126
125
  ```
126
+ 📌Additonaly for working through [Vertex AI](https://cloud.google.com/vertex-ai) you need to
127
+ [install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install)
128
+ and [configure the authorization](https://cloud.google.com/sdk/docs/authorizing).
127
129
 
128
130
  #### Local language models via Hugging Face Transformers
129
131
 
130
- You will need to install transformers and a deep learning library of your choice
131
- (PyTorch, TensorFlow, Flax, etc).
132
+ You will need to install transformers and deep learning library of your choice (PyTorch, TensorFlow, Flax, etc).
132
133
 
133
134
  See [transformers installation](https://huggingface.co/docs/transformers/installation).
134
135
 
@@ -144,13 +145,13 @@ See [transformers installation](https://huggingface.co/docs/transformers/install
144
145
  Vector database functions are available via `microcore.texts`.
145
146
 
146
147
  #### ChromaDB
147
- The default vector database is [Chroma](https://www.trychroma.com/).
148
+ Default vector database is [Chroma](https://www.trychroma.com/).
148
149
  In order to use vector database functions with ChromaDB, you need to install the `chromadb` package:
149
150
  ```bash
150
151
  pip install chromadb
151
152
  ```
152
- By default, MicroCore will use ChromaDB PersistentClient (if the corresponding package is installed).
153
- Alternatively, you can run Chroma as a separate service and configure MicroCore to use HttpClient:
153
+ By default, MicroCore will use ChromaDB PersistentClient (if corresponding package is installed).
154
+ Alternatively, you can run Chroma as separate service and configure MicroCore to use HttpClient:
154
155
 
155
156
  ```python
156
157
  from microcore import configure
@@ -173,7 +174,7 @@ configure(
173
174
  EMBEDDING_DB_TYPE=EmbeddingDbType.QDRANT,
174
175
  EMBEDDING_DB_HOST="localhost",
175
176
  EMBEDDING_DB_PORT="6333",
176
- EMBEDDING_DB_SIZE=384, # number of dimensions in the SentenceTransformer model
177
+ EMBEDDING_DB_SIZE=384, # dimentions quantity in used SentenceTransformer model
177
178
  EMBEDDING_DB_FUNCTION=SentenceTransformer("paraphrase-multilingual-MiniLM-L12-v2"),
178
179
  )
179
180
  ```
@@ -196,11 +197,11 @@ use_logging()
196
197
  # Basic usage
197
198
  ai_response = llm('What is your model name?')
198
199
 
199
- # You may also pass a list of strings as prompt
200
+ # You also may pass a list of strings as prompt
200
201
  # - For chat completion models elements are treated as separate messages
201
202
  # - For completion LLMs elements are treated as text lines
202
203
  llm(['1+2', '='])
203
- llm('1+2=', model='gpt-5.2')
204
+ llm('1+2=', model='gpt-4')
204
205
 
205
206
  # To specify a message role, you can use dictionary or classes
206
207
  llm(dict(role='system', content='1+2='))
@@ -289,12 +290,12 @@ LLM Microcore supports all models & API providers having OpenAI API.
289
290
  ## 🖼️ Examples
290
291
 
291
292
  #### [Code review tool](https://github.com/llm-microcore/microcore/blob/main/examples/code-review-tool)
292
- Performs a code review by LLM for changes in git .patch files in any programming languages.
293
+ Performs code review by LLM for changes in git .patch files in any programming languages.
293
294
 
294
295
  #### [Image analysis](https://colab.research.google.com/drive/1qTJ51wxCv3VlyqLt3M8OZ7183YXPFpic) (Google Colab)
295
296
  Determine the number of petals and the color of the flower from a photo (gpt-4-turbo)
296
297
 
297
- #### [Benchmark LLMs on math problems](https://www.kaggle.com/code/nayjest/gigabenchmark-llm-accuracy-math-problems) (Kaggle Notebook)
298
+ #### [Banchmark LLMs on math problems](https://www.kaggle.com/code/nayjest/gigabenchmark-llm-accuracy-math-problems) (Kaggle Notebook)
298
299
  Benchmark accuracy of 20+ state of the art models on solving olympiad math problems. Inferencing local language models via HuggingFace Transformers, parallel inference.
299
300
 
300
301
  #### [Generate meme image](https://github.com/Nayjest/ai-microcore/blob/main/examples/generate_meme_image.py)
@@ -302,61 +303,16 @@ Simple example demonstrating image generation using [OpenAI GPT Image](https://p
302
303
 
303
304
 
304
305
  #### [Local inference with PyTorch / Transformers](https://github.com/Nayjest/ai-microcore/blob/main/examples/pytorch_transformers.py)
305
- Text generation using HF/Transformers model locally (example with Qwen 3 0.6B).
306
+ Text generation using HF/Transformers model locally (example withQwen 3 0.6B).
306
307
 
307
308
  #### [Other examples](https://github.com/llm-microcore/microcore/tree/main/examples)
308
309
 
309
310
  ## Python functions as AI tools
310
- *Usage Example*:
311
- ```python
312
- from microcore.ai_func import ai_func
313
-
314
- @ai_func
315
- def search_products(
316
- query: str,
317
- category: str = "all",
318
- max_results: int = 10,
319
- in_stock_only: bool = False
320
- ):
321
- """
322
- Search for products in the catalog.
323
-
324
- Args:
325
- query: Search terms to find matching products
326
- category: Product category to filter by (e.g., "electronics", "clothing")
327
- max_results: Maximum number of results to return
328
- in_stock_only: If True, only return products currently in stock
329
-
330
- Returns:
331
- List of matching products with name, price, and availability
332
- """
333
- # Implementation would go here
334
- pass
335
- ```
336
- *Output*:
337
- ```
338
- # Search for products in the catalog.
339
-
340
- Args:
341
- query: Search terms to find matching products
342
- category: Product category to filter by (e.g., "electronics", "clothing")
343
- max_results: Maximum number of results to return
344
- in_stock_only: If True, only return products currently in stock
345
-
346
- Returns:
347
- List of matching products with name, price, and availability
348
- {
349
- "call": "search_products",
350
- "query": <str>,
351
- "category": <str> (default = "all"),
352
- "max_results": <int> (default = 10),
353
- "in_stock_only": <bool> (default = False)
354
- }
355
311
 
356
- ```
312
+ @TODO
357
313
 
358
314
  ## 🤖 AI Modules
359
- **This is an experimental feature.**
315
+ **This is experimental feature.**
360
316
 
361
317
  Tweaks the Python import system to provide automatic setup of MicroCore environment
362
318
  based on metadata in module docstrings.
@@ -376,5 +332,5 @@ Please see [CONTRIBUTING](https://github.com/Nayjest/ai-microcore/blob/main/CONT
376
332
  ## 📝 License
377
333
 
378
334
  Licensed under the [MIT License](https://github.com/Nayjest/ai-microcore/blob/main/LICENSE)
379
- © 2023–2026 [Vitalii Stepanenko](mailto:mail@vitaliy.in)
335
+ © 2023 [Vitalii Stepanenko](mailto:mail@vitaliy.in)
380
336