prompture 0.0.33.dev1__py3-none-any.whl → 0.0.34__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.
Files changed (56) hide show
  1. prompture/__init__.py +133 -49
  2. prompture/_version.py +34 -0
  3. prompture/aio/__init__.py +74 -0
  4. prompture/async_conversation.py +484 -0
  5. prompture/async_core.py +803 -0
  6. prompture/async_driver.py +131 -0
  7. prompture/cache.py +469 -0
  8. prompture/callbacks.py +50 -0
  9. prompture/cli.py +7 -3
  10. prompture/conversation.py +504 -0
  11. prompture/core.py +475 -352
  12. prompture/cost_mixin.py +51 -0
  13. prompture/discovery.py +50 -35
  14. prompture/driver.py +125 -5
  15. prompture/drivers/__init__.py +171 -73
  16. prompture/drivers/airllm_driver.py +13 -20
  17. prompture/drivers/async_airllm_driver.py +26 -0
  18. prompture/drivers/async_azure_driver.py +117 -0
  19. prompture/drivers/async_claude_driver.py +107 -0
  20. prompture/drivers/async_google_driver.py +132 -0
  21. prompture/drivers/async_grok_driver.py +91 -0
  22. prompture/drivers/async_groq_driver.py +84 -0
  23. prompture/drivers/async_hugging_driver.py +61 -0
  24. prompture/drivers/async_lmstudio_driver.py +79 -0
  25. prompture/drivers/async_local_http_driver.py +44 -0
  26. prompture/drivers/async_ollama_driver.py +125 -0
  27. prompture/drivers/async_openai_driver.py +96 -0
  28. prompture/drivers/async_openrouter_driver.py +96 -0
  29. prompture/drivers/async_registry.py +129 -0
  30. prompture/drivers/azure_driver.py +36 -9
  31. prompture/drivers/claude_driver.py +86 -34
  32. prompture/drivers/google_driver.py +87 -51
  33. prompture/drivers/grok_driver.py +29 -32
  34. prompture/drivers/groq_driver.py +27 -26
  35. prompture/drivers/hugging_driver.py +6 -6
  36. prompture/drivers/lmstudio_driver.py +26 -13
  37. prompture/drivers/local_http_driver.py +6 -6
  38. prompture/drivers/ollama_driver.py +90 -23
  39. prompture/drivers/openai_driver.py +36 -9
  40. prompture/drivers/openrouter_driver.py +31 -25
  41. prompture/drivers/registry.py +306 -0
  42. prompture/field_definitions.py +106 -96
  43. prompture/logging.py +80 -0
  44. prompture/model_rates.py +217 -0
  45. prompture/runner.py +49 -47
  46. prompture/session.py +117 -0
  47. prompture/settings.py +14 -1
  48. prompture/tools.py +172 -265
  49. prompture/validator.py +3 -3
  50. {prompture-0.0.33.dev1.dist-info → prompture-0.0.34.dist-info}/METADATA +18 -20
  51. prompture-0.0.34.dist-info/RECORD +55 -0
  52. prompture-0.0.33.dev1.dist-info/RECORD +0 -29
  53. {prompture-0.0.33.dev1.dist-info → prompture-0.0.34.dist-info}/WHEEL +0 -0
  54. {prompture-0.0.33.dev1.dist-info → prompture-0.0.34.dist-info}/entry_points.txt +0 -0
  55. {prompture-0.0.33.dev1.dist-info → prompture-0.0.34.dist-info}/licenses/LICENSE +0 -0
  56. {prompture-0.0.33.dev1.dist-info → prompture-0.0.34.dist-info}/top_level.txt +0 -0
prompture/__init__.py CHANGED
@@ -1,33 +1,95 @@
1
1
  """prompture - API package to convert LLM outputs into JSON + test harness."""
2
2
 
3
3
  from dotenv import load_dotenv
4
+
5
+ from .async_conversation import AsyncConversation
6
+ from .async_driver import AsyncDriver
7
+ from .cache import (
8
+ CacheBackend,
9
+ MemoryCacheBackend,
10
+ RedisCacheBackend,
11
+ ResponseCache,
12
+ SQLiteCacheBackend,
13
+ configure_cache,
14
+ get_cache,
15
+ )
16
+ from .callbacks import DriverCallbacks
17
+ from .conversation import Conversation
4
18
  from .core import (
5
- ask_for_json,
6
- extract_and_jsonify,
7
- manual_extract_and_jsonify,
8
19
  Driver,
20
+ ask_for_json,
9
21
  clean_json_text_with_ai,
10
- extract_with_model,
11
- stepwise_extract_with_model,
22
+ extract_and_jsonify,
12
23
  extract_from_data,
13
24
  extract_from_pandas,
25
+ extract_with_model,
26
+ manual_extract_and_jsonify,
14
27
  render_output,
28
+ stepwise_extract_with_model,
29
+ )
30
+ from .discovery import get_available_models
31
+ from .drivers import (
32
+ AirLLMDriver,
33
+ AzureDriver,
34
+ ClaudeDriver,
35
+ GoogleDriver,
36
+ GrokDriver,
37
+ GroqDriver,
38
+ LMStudioDriver,
39
+ LocalHTTPDriver,
40
+ OllamaDriver,
41
+ OpenAIDriver,
42
+ OpenRouterDriver,
43
+ get_driver,
44
+ get_driver_for_model,
45
+ # Plugin registration API
46
+ is_async_driver_registered,
47
+ is_driver_registered,
48
+ list_registered_async_drivers,
49
+ list_registered_drivers,
50
+ load_entry_point_drivers,
51
+ register_async_driver,
52
+ register_driver,
53
+ unregister_async_driver,
54
+ unregister_driver,
15
55
  )
16
- from .drivers import get_driver, get_driver_for_model, OpenAIDriver, LocalHTTPDriver, OllamaDriver, ClaudeDriver, LMStudioDriver, AzureDriver, GoogleDriver, GroqDriver, OpenRouterDriver, GrokDriver, AirLLMDriver
17
- from .tools import clean_json_text, clean_toon_text
18
56
  from .field_definitions import (
19
- FIELD_DEFINITIONS, get_field_definition, get_required_fields, get_field_names,
20
- field_from_registry, register_field, add_field_definition, add_field_definitions,
21
- get_registry_snapshot, clear_registry, reset_registry, validate_enum_value,
22
- normalize_enum_value
57
+ FIELD_DEFINITIONS,
58
+ add_field_definition,
59
+ add_field_definitions,
60
+ clear_registry,
61
+ field_from_registry,
62
+ get_field_definition,
63
+ get_field_names,
64
+ get_registry_snapshot,
65
+ get_required_fields,
66
+ normalize_enum_value,
67
+ register_field,
68
+ reset_registry,
69
+ validate_enum_value,
23
70
  )
71
+ from .logging import JSONFormatter, configure_logging
72
+ from .model_rates import get_model_info, get_model_rates, refresh_rates_cache
24
73
  from .runner import run_suite_from_spec
74
+ from .session import UsageSession
75
+ from .settings import settings as _settings
76
+ from .tools import clean_json_text, clean_toon_text
25
77
  from .validator import validate_against_schema
26
- from .discovery import get_available_models
27
78
 
28
79
  # Load environment variables from .env file
29
80
  load_dotenv()
30
81
 
82
+ # Auto-configure cache from settings if enabled
83
+ if _settings.cache_enabled:
84
+ configure_cache(
85
+ backend=_settings.cache_backend,
86
+ enabled=True,
87
+ ttl=_settings.cache_ttl_seconds,
88
+ maxsize=_settings.cache_memory_maxsize,
89
+ db_path=_settings.cache_sqlite_path,
90
+ redis_url=_settings.cache_redis_url,
91
+ )
92
+
31
93
  # runtime package version (from installed metadata)
32
94
  try:
33
95
  # Python 3.8+
@@ -43,51 +105,73 @@ except Exception:
43
105
  __version__ = "0.0.0"
44
106
 
45
107
  __all__ = [
46
- "ask_for_json",
47
- "extract_and_jsonify",
48
- "manual_extract_and_jsonify",
49
- "run_suite_from_spec",
50
- "validate_against_schema",
108
+ "FIELD_DEFINITIONS",
109
+ "AirLLMDriver",
110
+ "AsyncConversation",
111
+ "AsyncDriver",
112
+ "AzureDriver",
113
+ "CacheBackend",
114
+ "ClaudeDriver",
115
+ "Conversation",
51
116
  "Driver",
117
+ "DriverCallbacks",
118
+ "GoogleDriver",
119
+ "GrokDriver",
120
+ "GroqDriver",
121
+ "JSONFormatter",
122
+ "LMStudioDriver",
123
+ "LocalHTTPDriver",
124
+ "MemoryCacheBackend",
125
+ "OllamaDriver",
126
+ "OpenAIDriver",
127
+ "OpenRouterDriver",
128
+ "RedisCacheBackend",
129
+ "ResponseCache",
130
+ "SQLiteCacheBackend",
131
+ "UsageSession",
132
+ "add_field_definition",
133
+ "add_field_definitions",
134
+ "ask_for_json",
52
135
  "clean_json_text",
53
- "clean_toon_text",
54
136
  "clean_json_text_with_ai",
55
- "extract_with_model",
56
- "stepwise_extract_with_model",
57
- # TOON Data Extraction Functions
137
+ "clean_toon_text",
138
+ "clear_registry",
139
+ "configure_cache",
140
+ "configure_logging",
141
+ "extract_and_jsonify",
58
142
  "extract_from_data",
59
143
  "extract_from_pandas",
60
- "render_output",
61
- # Field Definitions
62
- "FIELD_DEFINITIONS",
144
+ "extract_with_model",
145
+ "field_from_registry",
146
+ "get_available_models",
147
+ "get_cache",
148
+ "get_driver",
149
+ "get_driver_for_model",
63
150
  "get_field_definition",
64
- "get_required_fields",
65
151
  "get_field_names",
66
- # New Field Registry API
67
- "field_from_registry",
68
- "register_field",
69
- "add_field_definition",
70
- "add_field_definitions",
152
+ "get_model_info",
153
+ "get_model_rates",
71
154
  "get_registry_snapshot",
72
- "clear_registry",
155
+ "get_required_fields",
156
+ # Plugin registration API
157
+ "is_async_driver_registered",
158
+ "is_driver_registered",
159
+ "list_registered_async_drivers",
160
+ "list_registered_drivers",
161
+ "load_entry_point_drivers",
162
+ # Other exports
163
+ "manual_extract_and_jsonify",
164
+ "normalize_enum_value",
165
+ "refresh_rates_cache",
166
+ "register_async_driver",
167
+ "register_driver",
168
+ "register_field",
169
+ "render_output",
73
170
  "reset_registry",
74
- # Enum Field Support
171
+ "run_suite_from_spec",
172
+ "stepwise_extract_with_model",
173
+ "unregister_async_driver",
174
+ "unregister_driver",
175
+ "validate_against_schema",
75
176
  "validate_enum_value",
76
- "normalize_enum_value",
77
- # Drivers
78
- "get_driver",
79
- "get_driver_for_model",
80
- "OpenAIDriver",
81
- "LocalHTTPDriver",
82
- "OllamaDriver",
83
- "ClaudeDriver",
84
- "LMStudioDriver",
85
- "AzureDriver",
86
- "GoogleDriver",
87
- "GroqDriver",
88
- "OpenRouterDriver",
89
- "GrokDriver",
90
- "AirLLMDriver",
91
- # Discovery
92
- "get_available_models",
93
177
  ]
prompture/_version.py ADDED
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.0.34'
32
+ __version_tuple__ = version_tuple = (0, 0, 34)
33
+
34
+ __commit_id__ = commit_id = None
@@ -0,0 +1,74 @@
1
+ """prompture.aio — Async public API for Prompture.
2
+
3
+ Usage::
4
+
5
+ from prompture.aio import extract_with_model, AsyncDriver
6
+
7
+ All functions mirror their synchronous counterparts in ``prompture.core``
8
+ but are ``async def`` and must be ``await``-ed.
9
+ """
10
+
11
+ from ..async_conversation import AsyncConversation
12
+ from ..async_core import (
13
+ ask_for_json,
14
+ clean_json_text_with_ai,
15
+ extract_and_jsonify,
16
+ extract_from_data,
17
+ extract_from_pandas,
18
+ extract_with_model,
19
+ gather_extract,
20
+ manual_extract_and_jsonify,
21
+ render_output,
22
+ stepwise_extract_with_model,
23
+ )
24
+ from ..async_driver import AsyncDriver
25
+ from ..drivers import (
26
+ AsyncAirLLMDriver,
27
+ AsyncAzureDriver,
28
+ AsyncClaudeDriver,
29
+ AsyncGoogleDriver,
30
+ AsyncGrokDriver,
31
+ AsyncGroqDriver,
32
+ AsyncHuggingFaceDriver,
33
+ AsyncLMStudioDriver,
34
+ AsyncLocalHTTPDriver,
35
+ AsyncOllamaDriver,
36
+ AsyncOpenAIDriver,
37
+ AsyncOpenRouterDriver,
38
+ get_async_driver,
39
+ get_async_driver_for_model,
40
+ )
41
+
42
+ __all__ = [
43
+ # Async driver classes
44
+ "AsyncAirLLMDriver",
45
+ "AsyncAzureDriver",
46
+ "AsyncClaudeDriver",
47
+ # Async conversation
48
+ "AsyncConversation",
49
+ # Async base class
50
+ "AsyncDriver",
51
+ "AsyncGoogleDriver",
52
+ "AsyncGrokDriver",
53
+ "AsyncGroqDriver",
54
+ "AsyncHuggingFaceDriver",
55
+ "AsyncLMStudioDriver",
56
+ "AsyncLocalHTTPDriver",
57
+ "AsyncOllamaDriver",
58
+ "AsyncOpenAIDriver",
59
+ "AsyncOpenRouterDriver",
60
+ # Async core functions
61
+ "ask_for_json",
62
+ "clean_json_text_with_ai",
63
+ "extract_and_jsonify",
64
+ "extract_from_data",
65
+ "extract_from_pandas",
66
+ "extract_with_model",
67
+ "gather_extract",
68
+ # Async driver factories
69
+ "get_async_driver",
70
+ "get_async_driver_for_model",
71
+ "manual_extract_and_jsonify",
72
+ "render_output",
73
+ "stepwise_extract_with_model",
74
+ ]