ai-microcore 5.0.0.dev8__tar.gz → 5.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.
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/PKG-INFO +51 -13
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/README.md +50 -12
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/__init__.py +1 -1
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/google_genai.py +2 -1
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/openai.py +14 -1
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/LICENSE +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/_env.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/_llm_functions.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/_prepare_llm_args.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/ai_func/__init__.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/ai_func/ai-func.json.j2 +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/ai_func/ai-func.pythonic.j2 +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/ai_func/ai-func.tag.j2 +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/ai_modules.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/configuration.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/embedding_db/__init__.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/embedding_db/chromadb.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/embedding_db/qdrant.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/file_cache.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/file_storage.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/images.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/interactive_setup.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/json_parsing.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/__init__.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/anthropic.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/local_llm.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/local_transformers.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm/shared.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/llm_backends.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/lm_client.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/logging.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/mcp.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/message_types.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/metrics.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/presets.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/python.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/templating/__init__.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/templating/jinja2.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/text2speech/elevenlabs.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/tokenizing.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/types.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/ui.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/utils.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/wrappers/__init__.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/wrappers/llm_response_wrapper.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/microcore/wrappers/prompt_wrapper.py +0 -0
- {ai_microcore-5.0.0.dev8 → ai_microcore-5.0.1}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ai-microcore
|
|
3
|
-
Version: 5.0.
|
|
3
|
+
Version: 5.0.1
|
|
4
4
|
Summary: # Minimalistic Foundation for AI Applications
|
|
5
5
|
Keywords: llm,large language models,ai,similarity search,ai search,gpt,openai,framework,adapter,anthropic,google gemini,google vertex ai
|
|
6
6
|
Author-email: Vitalii Stepanenko <mail@vitaliy.in>
|
|
@@ -116,21 +116,14 @@ For the full list of available configuration options, you may also check [`micro
|
|
|
116
116
|
|
|
117
117
|
### Installing vendor-specific packages
|
|
118
118
|
For models working not via OpenAI API, you may need to install additional packages:
|
|
119
|
-
#### Anthropic Claude
|
|
119
|
+
#### Anthropic Claude
|
|
120
120
|
```bash
|
|
121
121
|
pip install anthropic
|
|
122
122
|
```
|
|
123
|
-
#### Google Gemini via AI Studio
|
|
123
|
+
#### Google Gemini via AI Studio or Vertex AI
|
|
124
124
|
```bash
|
|
125
|
-
pip install google-
|
|
125
|
+
pip install google-genai
|
|
126
126
|
```
|
|
127
|
-
#### Google Gemini via Vertex AI
|
|
128
|
-
```bash
|
|
129
|
-
pip install vertexai
|
|
130
|
-
```
|
|
131
|
-
📌Additionally for working through [Vertex AI](https://cloud.google.com/vertex-ai) you need to
|
|
132
|
-
[install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install)
|
|
133
|
-
and [configure the authorization](https://cloud.google.com/sdk/docs/authorizing).
|
|
134
127
|
|
|
135
128
|
#### Local language models via Hugging Face Transformers
|
|
136
129
|
|
|
@@ -207,7 +200,7 @@ ai_response = llm('What is your model name?')
|
|
|
207
200
|
# - For chat completion models elements are treated as separate messages
|
|
208
201
|
# - For completion LLMs elements are treated as text lines
|
|
209
202
|
llm(['1+2', '='])
|
|
210
|
-
llm('1+2=', model='gpt-
|
|
203
|
+
llm('1+2=', model='gpt-5.2')
|
|
211
204
|
|
|
212
205
|
# To specify a message role, you can use dictionary or classes
|
|
213
206
|
llm(dict(role='system', content='1+2='))
|
|
@@ -314,8 +307,53 @@ Text generation using HF/Transformers model locally (example with Qwen 3 0.6B).
|
|
|
314
307
|
#### [Other examples](https://github.com/llm-microcore/microcore/tree/main/examples)
|
|
315
308
|
|
|
316
309
|
## 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
|
+
}
|
|
317
355
|
|
|
318
|
-
|
|
356
|
+
```
|
|
319
357
|
|
|
320
358
|
## 🤖 AI Modules
|
|
321
359
|
**This is an experimental feature.**
|
|
@@ -81,21 +81,14 @@ For the full list of available configuration options, you may also check [`micro
|
|
|
81
81
|
|
|
82
82
|
### Installing vendor-specific packages
|
|
83
83
|
For models working not via OpenAI API, you may need to install additional packages:
|
|
84
|
-
#### Anthropic Claude
|
|
84
|
+
#### Anthropic Claude
|
|
85
85
|
```bash
|
|
86
86
|
pip install anthropic
|
|
87
87
|
```
|
|
88
|
-
#### Google Gemini via AI Studio
|
|
88
|
+
#### Google Gemini via AI Studio or Vertex AI
|
|
89
89
|
```bash
|
|
90
|
-
pip install google-
|
|
90
|
+
pip install google-genai
|
|
91
91
|
```
|
|
92
|
-
#### Google Gemini via Vertex AI
|
|
93
|
-
```bash
|
|
94
|
-
pip install vertexai
|
|
95
|
-
```
|
|
96
|
-
📌Additionally for working through [Vertex AI](https://cloud.google.com/vertex-ai) you need to
|
|
97
|
-
[install the Google Cloud CLI](https://cloud.google.com/sdk/docs/install)
|
|
98
|
-
and [configure the authorization](https://cloud.google.com/sdk/docs/authorizing).
|
|
99
92
|
|
|
100
93
|
#### Local language models via Hugging Face Transformers
|
|
101
94
|
|
|
@@ -172,7 +165,7 @@ ai_response = llm('What is your model name?')
|
|
|
172
165
|
# - For chat completion models elements are treated as separate messages
|
|
173
166
|
# - For completion LLMs elements are treated as text lines
|
|
174
167
|
llm(['1+2', '='])
|
|
175
|
-
llm('1+2=', model='gpt-
|
|
168
|
+
llm('1+2=', model='gpt-5.2')
|
|
176
169
|
|
|
177
170
|
# To specify a message role, you can use dictionary or classes
|
|
178
171
|
llm(dict(role='system', content='1+2='))
|
|
@@ -279,8 +272,53 @@ Text generation using HF/Transformers model locally (example with Qwen 3 0.6B).
|
|
|
279
272
|
#### [Other examples](https://github.com/llm-microcore/microcore/tree/main/examples)
|
|
280
273
|
|
|
281
274
|
## Python functions as AI tools
|
|
275
|
+
*Usage Example*:
|
|
276
|
+
```python
|
|
277
|
+
from microcore.ai_func import ai_func
|
|
278
|
+
|
|
279
|
+
@ai_func
|
|
280
|
+
def search_products(
|
|
281
|
+
query: str,
|
|
282
|
+
category: str = "all",
|
|
283
|
+
max_results: int = 10,
|
|
284
|
+
in_stock_only: bool = False
|
|
285
|
+
):
|
|
286
|
+
"""
|
|
287
|
+
Search for products in the catalog.
|
|
288
|
+
|
|
289
|
+
Args:
|
|
290
|
+
query: Search terms to find matching products
|
|
291
|
+
category: Product category to filter by (e.g., "electronics", "clothing")
|
|
292
|
+
max_results: Maximum number of results to return
|
|
293
|
+
in_stock_only: If True, only return products currently in stock
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
List of matching products with name, price, and availability
|
|
297
|
+
"""
|
|
298
|
+
# Implementation would go here
|
|
299
|
+
pass
|
|
300
|
+
```
|
|
301
|
+
*Output*:
|
|
302
|
+
```
|
|
303
|
+
# Search for products in the catalog.
|
|
304
|
+
|
|
305
|
+
Args:
|
|
306
|
+
query: Search terms to find matching products
|
|
307
|
+
category: Product category to filter by (e.g., "electronics", "clothing")
|
|
308
|
+
max_results: Maximum number of results to return
|
|
309
|
+
in_stock_only: If True, only return products currently in stock
|
|
310
|
+
|
|
311
|
+
Returns:
|
|
312
|
+
List of matching products with name, price, and availability
|
|
313
|
+
{
|
|
314
|
+
"call": "search_products",
|
|
315
|
+
"query": <str>,
|
|
316
|
+
"category": <str> (default = "all"),
|
|
317
|
+
"max_results": <int> (default = 10),
|
|
318
|
+
"in_stock_only": <bool> (default = False)
|
|
319
|
+
}
|
|
282
320
|
|
|
283
|
-
|
|
321
|
+
```
|
|
284
322
|
|
|
285
323
|
## 🤖 AI Modules
|
|
286
324
|
**This is an experimental feature.**
|
|
@@ -222,6 +222,7 @@ class _GenerationContext:
|
|
|
222
222
|
model_name = kwargs.pop("model", client.config.MODEL)
|
|
223
223
|
callbacks = prepare_callbacks(client.config, kwargs, set_stream=False)
|
|
224
224
|
is_image = is_image_model(model_name)
|
|
225
|
+
stream = kwargs.pop("stream", False) or (callbacks and not is_image)
|
|
225
226
|
return _GenerationContext(
|
|
226
227
|
model_name=model_name,
|
|
227
228
|
save=kwargs.pop("save", True),
|
|
@@ -231,7 +232,7 @@ class _GenerationContext:
|
|
|
231
232
|
genai_client=client.genai_client,
|
|
232
233
|
config=client.config,
|
|
233
234
|
is_image_model=is_image,
|
|
234
|
-
stream=
|
|
235
|
+
stream=stream,
|
|
235
236
|
)
|
|
236
237
|
|
|
237
238
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import base64
|
|
3
|
+
from typing import Any
|
|
3
4
|
|
|
4
5
|
import openai
|
|
5
6
|
from openai.types import CompletionChoice, ImagesResponse
|
|
6
7
|
|
|
7
8
|
from ..lm_client import BaseAIChatClient, BaseAsyncAIClient
|
|
8
|
-
from ..message_types import TMsgContentPart
|
|
9
|
+
from ..message_types import TMsgContentPart, TMsgContent
|
|
9
10
|
from ..configuration import Config
|
|
10
11
|
from ..llm_backends import ApiPlatform
|
|
11
12
|
from .._prepare_llm_args import prepare_prompt
|
|
@@ -132,6 +133,18 @@ class OpenAIClient(BaseAIChatClient):
|
|
|
132
133
|
return image_to_oai(img)
|
|
133
134
|
return content_part
|
|
134
135
|
|
|
136
|
+
def _convert_message_content(self, message_content: TMsgContent) -> Any:
|
|
137
|
+
"""
|
|
138
|
+
Convert the message content into a format suitable for the LLM inference chat API.
|
|
139
|
+
"""
|
|
140
|
+
if isinstance(message_content, str):
|
|
141
|
+
# Prevent conversion of string content into dict(type=text, text=...)
|
|
142
|
+
# because Azure OpenAI fails with Error 400
|
|
143
|
+
# when passing "azure_search" data source like following:
|
|
144
|
+
# llm(..., extra_body={"data_sources"=[{"type": "azure_search",...}]})
|
|
145
|
+
return message_content
|
|
146
|
+
return super()._convert_message_content(message_content)
|
|
147
|
+
|
|
135
148
|
def load_models(self, **kwargs) -> dict:
|
|
136
149
|
models_iter = self.oai_client.models.list(**kwargs)
|
|
137
150
|
return {model.id: model for model in models_iter}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|