abstractcore 2.4.5__py3-none-any.whl → 2.4.7__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: abstractcore
3
- Version: 2.4.5
3
+ Version: 2.4.7
4
4
  Summary: Unified interface to all LLM providers with essential infrastructure for tool calling, streaming, and model management
5
5
  Author-email: Laurent-Philippe Albou <contact@abstractcore.ai>
6
6
  Maintainer-email: Laurent-Philippe Albou <contact@abstractcore.ai>
@@ -29,6 +29,7 @@ License-File: LICENSE
29
29
  Requires-Dist: pydantic<3.0.0,>=2.0.0
30
30
  Requires-Dist: httpx<1.0.0,>=0.24.0
31
31
  Requires-Dist: tiktoken<1.0.0,>=0.5.0
32
+ Requires-Dist: requests<3.0.0,>=2.25.0
32
33
  Provides-Extra: openai
33
34
  Requires-Dist: openai<2.0.0,>=1.0.0; extra == "openai"
34
35
  Provides-Extra: anthropic
@@ -46,6 +47,11 @@ Provides-Extra: embeddings
46
47
  Requires-Dist: sentence-transformers<4.0.0,>=2.7.0; extra == "embeddings"
47
48
  Requires-Dist: numpy<2.0.0,>=1.20.0; extra == "embeddings"
48
49
  Provides-Extra: processing
50
+ Provides-Extra: tools
51
+ Requires-Dist: beautifulsoup4<5.0.0,>=4.12.0; extra == "tools"
52
+ Requires-Dist: lxml<6.0.0,>=4.9.0; extra == "tools"
53
+ Requires-Dist: duckduckgo-search<4.0.0,>=3.8.0; extra == "tools"
54
+ Requires-Dist: psutil<6.0.0,>=5.9.0; extra == "tools"
49
55
  Provides-Extra: media
50
56
  Requires-Dist: Pillow<12.0.0,>=10.0.0; extra == "media"
51
57
  Requires-Dist: pymupdf4llm<1.0.0,>=0.0.20; extra == "media"
@@ -60,9 +66,9 @@ Requires-Dist: abstractcore[huggingface]; extra == "heavy-providers"
60
66
  Provides-Extra: all-providers
61
67
  Requires-Dist: abstractcore[anthropic,embeddings,huggingface,lmstudio,mlx,ollama,openai]; extra == "all-providers"
62
68
  Provides-Extra: all
63
- Requires-Dist: abstractcore[anthropic,dev,docs,embeddings,huggingface,lmstudio,media,mlx,ollama,openai,processing,server,test]; extra == "all"
69
+ Requires-Dist: abstractcore[anthropic,dev,docs,embeddings,huggingface,lmstudio,media,mlx,ollama,openai,processing,server,test,tools]; extra == "all"
64
70
  Provides-Extra: lightweight
65
- Requires-Dist: abstractcore[anthropic,embeddings,lmstudio,media,ollama,openai,processing,server]; extra == "lightweight"
71
+ Requires-Dist: abstractcore[anthropic,embeddings,lmstudio,media,ollama,openai,processing,server,tools]; extra == "lightweight"
66
72
  Provides-Extra: dev
67
73
  Requires-Dist: pytest>=7.0.0; extra == "dev"
68
74
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
@@ -89,7 +95,7 @@ Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
89
95
  Requires-Dist: mkdocstrings[python]>=0.22.0; extra == "docs"
90
96
  Requires-Dist: mkdocs-autorefs>=0.4.0; extra == "docs"
91
97
  Provides-Extra: full-dev
92
- Requires-Dist: abstractcore[all-providers,dev,docs,test]; extra == "full-dev"
98
+ Requires-Dist: abstractcore[all-providers,dev,docs,test,tools]; extra == "full-dev"
93
99
  Dynamic: license-file
94
100
 
95
101
  # AbstractCore
@@ -122,6 +128,21 @@ response = llm.generate("What is the capital of France?")
122
128
  print(response.content)
123
129
  ```
124
130
 
131
+ ### Deterministic Generation
132
+
133
+ ```python
134
+ from abstractcore import create_llm
135
+
136
+ # Deterministic outputs with seed + temperature=0
137
+ llm = create_llm("openai", model="gpt-3.5-turbo", seed=42, temperature=0.0)
138
+
139
+ # These will produce identical outputs
140
+ response1 = llm.generate("Write exactly 3 words about coding")
141
+ response2 = llm.generate("Write exactly 3 words about coding")
142
+ print(f"Response 1: {response1.content}") # "Innovative, challenging, rewarding."
143
+ print(f"Response 2: {response2.content}") # "Innovative, challenging, rewarding."
144
+ ```
145
+
125
146
  ### Tool Calling
126
147
 
127
148
  ```python
@@ -140,6 +161,78 @@ response = llm.generate(
140
161
  print(response.content)
141
162
  ```
142
163
 
164
+ ### Response Object (GenerateResponse)
165
+
166
+ Every LLM generation returns a **GenerateResponse** object with consistent structure across all providers:
167
+
168
+ ```python
169
+ from abstractcore import create_llm
170
+
171
+ llm = create_llm("openai", model="gpt-4o-mini")
172
+ response = llm.generate("Explain quantum computing in simple terms")
173
+
174
+ # Core response data
175
+ print(f"Content: {response.content}") # Generated text
176
+ print(f"Model: {response.model}") # Model used
177
+ print(f"Finish reason: {response.finish_reason}") # Why generation stopped
178
+
179
+ # Consistent token access across ALL providers (NEW in v2.4.7)
180
+ print(f"Input tokens: {response.input_tokens}") # Always available
181
+ print(f"Output tokens: {response.output_tokens}") # Always available
182
+ print(f"Total tokens: {response.total_tokens}") # Always available
183
+
184
+ # Generation time tracking (NEW in v2.4.7)
185
+ print(f"Generation time: {response.gen_time}ms") # Always available (rounded to 1 decimal)
186
+
187
+ # Advanced access
188
+ print(f"Tool calls: {response.tool_calls}") # Tools executed (if any)
189
+ print(f"Raw usage: {response.usage}") # Provider-specific token data
190
+ print(f"Metadata: {response.metadata}") # Additional context
191
+
192
+ # Comprehensive summary
193
+ print(f"Summary: {response.get_summary()}") # "Model: gpt-4o-mini | Tokens: 117 | Time: 1234.5ms"
194
+ ```
195
+
196
+ **Token Count Sources:**
197
+ - **Provider APIs**: OpenAI, Anthropic, LMStudio (native API token counts)
198
+ - **AbstractCore Calculation**: MLX, HuggingFace, Mock (using `token_utils.py`)
199
+ - **Mixed Sources**: Ollama (combination of provider and calculated tokens)
200
+
201
+ **Backward Compatibility**: Legacy `prompt_tokens` and `completion_tokens` keys remain available in `response.usage` dictionary.
202
+
203
+ ### Built-in Tools
204
+
205
+ AbstractCore includes a comprehensive set of ready-to-use tools for common tasks:
206
+
207
+ ```python
208
+ from abstractcore.tools.common_tools import fetch_url, search_files, read_file
209
+
210
+ # Intelligent web content fetching with automatic parsing
211
+ result = fetch_url("https://api.github.com/repos/python/cpython")
212
+ # Automatically detects JSON, HTML, images, PDFs, etc. and provides structured analysis
213
+
214
+ # File system operations
215
+ files = search_files("def.*fetch", ".", file_pattern="*.py") # Find function definitions
216
+ content = read_file("config.json") # Read file contents
217
+
218
+ # Use with any LLM
219
+ llm = create_llm("anthropic", model="claude-3-5-haiku-latest")
220
+ response = llm.generate(
221
+ "Analyze this API response and summarize the key information",
222
+ tools=[fetch_url]
223
+ )
224
+ ```
225
+
226
+ **Available Tools:**
227
+ - `fetch_url` - Intelligent web content fetching with automatic content type detection and parsing
228
+ - `search_files` - Search for text patterns inside files using regex
229
+ - `list_files` - Find and list files by names/paths using glob patterns
230
+ - `read_file` - Read file contents with optional line range selection
231
+ - `write_file` - Write content to files with directory creation
232
+ - `edit_file` - Edit files using pattern matching and replacement
233
+ - `web_search` - Search the web using DuckDuckGo
234
+ - `execute_command` - Execute shell commands safely with security controls
235
+
143
236
  ### Session Management
144
237
 
145
238
  ```python
@@ -223,19 +316,22 @@ response = llm.generate(
223
316
  - **Session Management**: Persistent conversations with metadata, analytics, and complete serialization
224
317
  - **Structured Responses**: Clean, predictable output formats with Pydantic
225
318
  - **Streaming Support**: Real-time token generation for interactive experiences
319
+ - **Consistent Token Terminology**: Unified `input_tokens`, `output_tokens`, `total_tokens` across all providers
226
320
  - **Embeddings**: Built-in support for semantic search and RAG applications
227
321
  - **Universal Server**: Optional OpenAI-compatible API server with `/v1/responses` endpoint
228
322
 
229
323
  ## Supported Providers
230
324
 
231
- | Provider | Status | Setup |
232
- |----------|--------|-------|
233
- | **OpenAI** | Full | [Get API key](docs/prerequisites.md#openai-setup) |
234
- | **Anthropic** | Full | [Get API key](docs/prerequisites.md#anthropic-setup) |
235
- | **Ollama** | Full | [Install guide](docs/prerequisites.md#ollama-setup) |
236
- | **LMStudio** | Full | [Install guide](docs/prerequisites.md#lmstudio-setup) |
237
- | **MLX** | Full | [Setup guide](docs/prerequisites.md#mlx-setup) |
238
- | **HuggingFace** | Full | [Setup guide](docs/prerequisites.md#huggingface-setup) |
325
+ | Provider | Status | SEED Support | Setup |
326
+ |----------|--------|-------------|-------|
327
+ | **OpenAI** | Full | ✅ Native | [Get API key](docs/prerequisites.md#openai-setup) |
328
+ | **Anthropic** | Full | ⚠️ Warning* | [Get API key](docs/prerequisites.md#anthropic-setup) |
329
+ | **Ollama** | Full | ✅ Native | [Install guide](docs/prerequisites.md#ollama-setup) |
330
+ | **LMStudio** | Full | ✅ Native | [Install guide](docs/prerequisites.md#lmstudio-setup) |
331
+ | **MLX** | Full | ✅ Native | [Setup guide](docs/prerequisites.md#mlx-setup) |
332
+ | **HuggingFace** | Full | ✅ Native | [Setup guide](docs/prerequisites.md#huggingface-setup) |
333
+
334
+ *Anthropic doesn't support seed parameters but issues a warning when provided. Use `temperature=0.0` for more consistent outputs.
239
335
 
240
336
  ## Server Mode (Optional HTTP REST API)
241
337
 
@@ -1,4 +1,4 @@
1
- abstractcore/__init__.py,sha256=7ucTDQXINslx23n-vaFOeFzRAYi76Enqak2S3rjaZLU,1861
1
+ abstractcore/__init__.py,sha256=A7Gbn_C-robdWLLQXjtTyWsoaXDGIblSFmLRV_ni6O8,1934
2
2
  abstractcore/apps/__init__.py,sha256=sgNOv3lYyOWNBC-w6GnRN6aILGCbdkQtNcuQdJz5ghE,31
3
3
  abstractcore/apps/__main__.py,sha256=041daYkoIE1VLEO19IZC5nNIDOQZWNgpB7ogJ3SOlsE,1585
4
4
  abstractcore/apps/app_config_utils.py,sha256=GygjtkianBktRvirHya1KbXuB2r5OUDJM6ilvybQWvk,875
@@ -10,17 +10,17 @@ abstractcore/architectures/detection.py,sha256=Cxap1pL6qOJjyY22Vc4hzbLALTuuBisPT
10
10
  abstractcore/architectures/enums.py,sha256=9vIv2vDBEKhxwzwH9iaSAyf-iVj3p8y9loMeN_mYTJ8,3821
11
11
  abstractcore/assets/architecture_formats.json,sha256=CIf6SaR_IJs1D7Uvd1K3zWngIXJ_yq3DM_IE3wnpCHY,16076
12
12
  abstractcore/assets/model_capabilities.json,sha256=iUkDiljyZUZzPlpYCOFgStXyc6e7dvOfReYQ0HFrX9Q,49703
13
- abstractcore/assets/session_schema.json,sha256=b6HTAWxRVlVhAzA7FqaKpunK1yO6jilBOsD5sQkqJTo,10580
13
+ abstractcore/assets/session_schema.json,sha256=hMCVrq3KSyVExrMGzuykf7bU-z6WyIVuEGU8du9_zUY,10570
14
14
  abstractcore/cli/__init__.py,sha256=rUjLjZSK3wENSw4g_iN43Bc2i5cggcEmj4NPXBMohdc,241
15
15
  abstractcore/cli/main.py,sha256=QD38nnfrInavO452WbkXCI37SVsdIu9VhvjEOojXBGY,31834
16
16
  abstractcore/cli/vision_config.py,sha256=jJzO4zBexh8SqSKp6YKOXdMDSv4AL4Ztl5Xi-5c4KyY,17869
17
17
  abstractcore/core/__init__.py,sha256=2h-86U4QkCQ4gzZ4iRusSTMlkODiUS6tKjZHiEXz6rM,684
18
18
  abstractcore/core/enums.py,sha256=BhkVnHC-X1_377JDmqd-2mnem9GdBLqixWlYzlP_FJU,695
19
19
  abstractcore/core/factory.py,sha256=UdrNwQAvifvFS3LMjF5KO87m-2n1bJBryTs9pvesYcI,2804
20
- abstractcore/core/interface.py,sha256=XTvtP1YY_2dSlSdKWkkDK54VtEeUt97zIDR1tXTtn8Q,13876
20
+ abstractcore/core/interface.py,sha256=-VAY0nlsTnWN_WghiuMC7iE7xUdZfYOg6KlgrAPi14Y,14086
21
21
  abstractcore/core/retry.py,sha256=wNlUAxfmvdO_uVWb4iqkhTqd7O1oRwXxqvVQaLXQOw0,14538
22
- abstractcore/core/session.py,sha256=iU_fU7f7E6HxwkV97QnSMJSF6rOIuJyT6sQGf547S6s,35347
23
- abstractcore/core/types.py,sha256=KT9Gf9ei4t0QnWBH72fFa8vR7UZSKI-CJyQjU9ynE8g,3642
22
+ abstractcore/core/session.py,sha256=fdqhnufCWrV022RjQ-Xfb1KFv_s9-GzetSSR-QuXv-Q,36452
23
+ abstractcore/core/types.py,sha256=jj44i07kMjdg9FQ3mA_fK6r_M0Lcgt1RQpy1Ra5w-eI,4578
24
24
  abstractcore/embeddings/__init__.py,sha256=hR3xZyqcRm4c2pq1dIa5lxj_-Bk70Zad802JQN4joWo,637
25
25
  abstractcore/embeddings/manager.py,sha256=uFVbRPHx_R-kVMVA7N7_7EzeUmCJCeN9Dv0EV8Jko24,52245
26
26
  abstractcore/embeddings/models.py,sha256=bsPAzL6gv57AVii8O15PT0kxfwRkOml3f3njJN4UDi4,4874
@@ -48,14 +48,14 @@ abstractcore/processing/basic_extractor.py,sha256=3x-3BdIHgLvqLnLF6K1-P4qVaLIpAn
48
48
  abstractcore/processing/basic_judge.py,sha256=tKWJrg_tY4vCHzWgXxz0ZjgLXBYYfpMcpG7vl03hJcM,32218
49
49
  abstractcore/processing/basic_summarizer.py,sha256=XHNxMQ_8aLStTeUo6_2JaThlct12Htpz7ORmm0iuJsg,25495
50
50
  abstractcore/providers/__init__.py,sha256=t8Kp4flH5GvZEC6dx-iYJSPeSxMODa2spXb8MqtlPy4,1282
51
- abstractcore/providers/anthropic_provider.py,sha256=tcOrARLd1kA4vRkH7MCgy99YIGVaegdCd3-Z8UaKP3Q,20705
52
- abstractcore/providers/base.py,sha256=5YR64kqTYiCvWtIUBul5QfO0XRZr6_Aiho4atpDOh0o,50579
53
- abstractcore/providers/huggingface_provider.py,sha256=mJGfi1lgsvjV3Lj4q7KCQZhQqw_o23af40i5WLg150o,47789
54
- abstractcore/providers/lmstudio_provider.py,sha256=oPL_Y4gkJMAniecdWQVaDi7WozCZumSRs0lE7uFgvQk,20406
55
- abstractcore/providers/mlx_provider.py,sha256=61i5VhpNw_QlhOwPcEcryaGbI45aYyL9q15TrpinIgs,17427
56
- abstractcore/providers/mock_provider.py,sha256=tIjA57Hlwu3vNODOZShNn0tY9HWvz1p4z-HyD_bsvbo,5741
57
- abstractcore/providers/ollama_provider.py,sha256=O77Nzx0erQw8D5TlyVaunIOjluaRwi8bgYVO95qK0L4,21129
58
- abstractcore/providers/openai_provider.py,sha256=gHurjXwwKvKQtkK5cqwokW_DUTY9_bsfNm06RPvQ39g,22683
51
+ abstractcore/providers/anthropic_provider.py,sha256=R87Z_DNNdeA4LMSxx84pqo8saKFz38dHCJMBpc-rL70,21552
52
+ abstractcore/providers/base.py,sha256=YfrqM3c7wLT19vspL7goUO6Bv-z1691ZkCM2wxvQX4s,51501
53
+ abstractcore/providers/huggingface_provider.py,sha256=pgpeSwpwyNB_5GDyLEz2OSTu9me-GAJzQ116dGtpCvQ,49012
54
+ abstractcore/providers/lmstudio_provider.py,sha256=odT6luVR3POVcq2ZqkINLyLoCAu_YGpLLj3fEddNliU,21021
55
+ abstractcore/providers/mlx_provider.py,sha256=sDgxf_kVJJwxprQWVef9w2CLOu2dLES8D0Vf5tY6PzE,18463
56
+ abstractcore/providers/mock_provider.py,sha256=x-frlBLxlqx6jlMoPnZN4aNv1pHacRYW_jlp0peI9FA,6168
57
+ abstractcore/providers/ollama_provider.py,sha256=1bE80NCj_TQADxRCiu9luyLuI_gZe2EO5pCKoC4VhQM,21740
58
+ abstractcore/providers/openai_provider.py,sha256=1s7JJalyIBOvLB7UAUwXbTc2aYrYSWg7hJjKGnCX1qU,23313
59
59
  abstractcore/providers/registry.py,sha256=c0hxp9RRa-uipGotaAu48fHXc_HGlLcOxC1k763mzhU,16596
60
60
  abstractcore/providers/streaming.py,sha256=VnffBV_CU9SAKzghL154OoFyEdDsiLwUNXPahyU41Bw,31342
61
61
  abstractcore/server/__init__.py,sha256=1DSAz_YhQtnKv7sNi5TMQV8GFujctDOabgvAdilQE0o,249
@@ -64,7 +64,7 @@ abstractcore/structured/__init__.py,sha256=VXRQHGcm-iaYnLOBPin2kyhvhhQA0kaGt_pcN
64
64
  abstractcore/structured/handler.py,sha256=Vb15smiR81JGDXX2RLkY2Exuj67J7a6C-xwVrZoXp0I,17134
65
65
  abstractcore/structured/retry.py,sha256=BN_PvrWybyU1clMy2cult1-TVxFSMaVqiCPmmXvA5aI,3805
66
66
  abstractcore/tools/__init__.py,sha256=oh6vG0RdM1lqUtOp95mLrTsWLh9VmhJf5_FVjGIP5_M,2259
67
- abstractcore/tools/common_tools.py,sha256=jRVvu-TQbmXBOZHn00zEZb44nenaXVtdemhKmRmt1YY,64496
67
+ abstractcore/tools/common_tools.py,sha256=GkUSnBum3zMm9M-Zd9LlJQmlDp1XDssC7z8ItUcbloc,91692
68
68
  abstractcore/tools/core.py,sha256=lUUGihyceiRYlKUFvEMig9jWFF563d574mSDbYYD3fM,4777
69
69
  abstractcore/tools/handler.py,sha256=GmDenXAJkhceWSGlhvuF90aMb2301tRTh6WxGwBQifc,12022
70
70
  abstractcore/tools/parser.py,sha256=1r5nmEEp1Rid3JU6ct-s3lP-eCln67fvXG5HCjqiRew,27740
@@ -77,10 +77,10 @@ abstractcore/utils/message_preprocessor.py,sha256=GdHkm6tmrgjm3PwHRSCjIsq1XLkbhy
77
77
  abstractcore/utils/self_fixes.py,sha256=QEDwNTW80iQM4ftfEY3Ghz69F018oKwLM9yeRCYZOvw,5886
78
78
  abstractcore/utils/structured_logging.py,sha256=Vm-HviSa42G9DJCWmaEv4a0QG3NMsADD3ictLOs4En0,19952
79
79
  abstractcore/utils/token_utils.py,sha256=eLwFmJ68p9WMFD_MHLMmeJRW6Oqx_4hKELB8FNQ2Mnk,21097
80
- abstractcore/utils/version.py,sha256=WKRMOS_TRIxsNu-vJqfCYHA335-rya9xBBMzhx_S-Z8,605
81
- abstractcore-2.4.5.dist-info/licenses/LICENSE,sha256=PI2v_4HMvd6050uDD_4AY_8PzBnu2asa3RKbdDjowTA,1078
82
- abstractcore-2.4.5.dist-info/METADATA,sha256=9w6Q7NZXePxhRYnmloyJ6Nd2DFQ7YY4294OMF-6QYuY,27596
83
- abstractcore-2.4.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
- abstractcore-2.4.5.dist-info/entry_points.txt,sha256=UdVmchBC_Lt3H4Vlkt5js-QDAkVlBbkCu1yCsswk-KE,454
85
- abstractcore-2.4.5.dist-info/top_level.txt,sha256=DiNHBI35SIawW3N9Z-z0y6cQYNbXd32pvBkW0RLfScs,13
86
- abstractcore-2.4.5.dist-info/RECORD,,
80
+ abstractcore/utils/version.py,sha256=ktMUN5ql9UjgEbvyoT7ilNbOyvAiVtrcRN8hl3eQSvc,605
81
+ abstractcore-2.4.7.dist-info/licenses/LICENSE,sha256=PI2v_4HMvd6050uDD_4AY_8PzBnu2asa3RKbdDjowTA,1078
82
+ abstractcore-2.4.7.dist-info/METADATA,sha256=NZiFyhk87Pq3Pe-L7E0xo37RawH6YlFhhBiYp26Ocmc,31913
83
+ abstractcore-2.4.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
+ abstractcore-2.4.7.dist-info/entry_points.txt,sha256=UdVmchBC_Lt3H4Vlkt5js-QDAkVlBbkCu1yCsswk-KE,454
85
+ abstractcore-2.4.7.dist-info/top_level.txt,sha256=DiNHBI35SIawW3N9Z-z0y6cQYNbXd32pvBkW0RLfScs,13
86
+ abstractcore-2.4.7.dist-info/RECORD,,