prompture 0.0.33.dev2__py3-none-any.whl → 0.0.34.dev1__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 (55) hide show
  1. prompture/__init__.py +112 -54
  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 +41 -36
  14. prompture/driver.py +125 -5
  15. prompture/drivers/__init__.py +63 -57
  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 +80 -0
  30. prompture/drivers/azure_driver.py +36 -15
  31. prompture/drivers/claude_driver.py +86 -40
  32. prompture/drivers/google_driver.py +86 -58
  33. prompture/drivers/grok_driver.py +29 -38
  34. prompture/drivers/groq_driver.py +27 -32
  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 -15
  40. prompture/drivers/openrouter_driver.py +31 -31
  41. prompture/field_definitions.py +106 -96
  42. prompture/logging.py +80 -0
  43. prompture/model_rates.py +16 -15
  44. prompture/runner.py +49 -47
  45. prompture/session.py +117 -0
  46. prompture/settings.py +11 -1
  47. prompture/tools.py +172 -265
  48. prompture/validator.py +3 -3
  49. {prompture-0.0.33.dev2.dist-info → prompture-0.0.34.dev1.dist-info}/METADATA +18 -20
  50. prompture-0.0.34.dev1.dist-info/RECORD +54 -0
  51. prompture-0.0.33.dev2.dist-info/RECORD +0 -30
  52. {prompture-0.0.33.dev2.dist-info → prompture-0.0.34.dev1.dist-info}/WHEEL +0 -0
  53. {prompture-0.0.33.dev2.dist-info → prompture-0.0.34.dev1.dist-info}/entry_points.txt +0 -0
  54. {prompture-0.0.33.dev2.dist-info → prompture-0.0.34.dev1.dist-info}/licenses/LICENSE +0 -0
  55. {prompture-0.0.33.dev2.dist-info → prompture-0.0.34.dev1.dist-info}/top_level.txt +0 -0
prompture/__init__.py CHANGED
@@ -1,34 +1,85 @@
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,
15
45
  )
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
46
  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
47
+ FIELD_DEFINITIONS,
48
+ add_field_definition,
49
+ add_field_definitions,
50
+ clear_registry,
51
+ field_from_registry,
52
+ get_field_definition,
53
+ get_field_names,
54
+ get_registry_snapshot,
55
+ get_required_fields,
56
+ normalize_enum_value,
57
+ register_field,
58
+ reset_registry,
59
+ validate_enum_value,
23
60
  )
61
+ from .logging import JSONFormatter, configure_logging
62
+ from .model_rates import get_model_info, get_model_rates, refresh_rates_cache
24
63
  from .runner import run_suite_from_spec
64
+ from .session import UsageSession
65
+ from .settings import settings as _settings
66
+ from .tools import clean_json_text, clean_toon_text
25
67
  from .validator import validate_against_schema
26
- from .discovery import get_available_models
27
- from .model_rates import get_model_rates, get_model_info, refresh_rates_cache
28
68
 
29
69
  # Load environment variables from .env file
30
70
  load_dotenv()
31
71
 
72
+ # Auto-configure cache from settings if enabled
73
+ if _settings.cache_enabled:
74
+ configure_cache(
75
+ backend=_settings.cache_backend,
76
+ enabled=True,
77
+ ttl=_settings.cache_ttl_seconds,
78
+ maxsize=_settings.cache_memory_maxsize,
79
+ db_path=_settings.cache_sqlite_path,
80
+ redis_url=_settings.cache_redis_url,
81
+ )
82
+
32
83
  # runtime package version (from installed metadata)
33
84
  try:
34
85
  # Python 3.8+
@@ -44,55 +95,62 @@ except Exception:
44
95
  __version__ = "0.0.0"
45
96
 
46
97
  __all__ = [
47
- "ask_for_json",
48
- "extract_and_jsonify",
49
- "manual_extract_and_jsonify",
50
- "run_suite_from_spec",
51
- "validate_against_schema",
98
+ "FIELD_DEFINITIONS",
99
+ "AirLLMDriver",
100
+ "AsyncConversation",
101
+ "AsyncDriver",
102
+ "AzureDriver",
103
+ "CacheBackend",
104
+ "ClaudeDriver",
105
+ "Conversation",
52
106
  "Driver",
107
+ "DriverCallbacks",
108
+ "GoogleDriver",
109
+ "GrokDriver",
110
+ "GroqDriver",
111
+ "JSONFormatter",
112
+ "LMStudioDriver",
113
+ "LocalHTTPDriver",
114
+ "MemoryCacheBackend",
115
+ "OllamaDriver",
116
+ "OpenAIDriver",
117
+ "OpenRouterDriver",
118
+ "RedisCacheBackend",
119
+ "ResponseCache",
120
+ "SQLiteCacheBackend",
121
+ "UsageSession",
122
+ "add_field_definition",
123
+ "add_field_definitions",
124
+ "ask_for_json",
53
125
  "clean_json_text",
54
- "clean_toon_text",
55
126
  "clean_json_text_with_ai",
56
- "extract_with_model",
57
- "stepwise_extract_with_model",
58
- # TOON Data Extraction Functions
127
+ "clean_toon_text",
128
+ "clear_registry",
129
+ "configure_cache",
130
+ "configure_logging",
131
+ "extract_and_jsonify",
59
132
  "extract_from_data",
60
133
  "extract_from_pandas",
61
- "render_output",
62
- # Field Definitions
63
- "FIELD_DEFINITIONS",
64
- "get_field_definition",
65
- "get_required_fields",
66
- "get_field_names",
67
- # New Field Registry API
134
+ "extract_with_model",
68
135
  "field_from_registry",
69
- "register_field",
70
- "add_field_definition",
71
- "add_field_definitions",
72
- "get_registry_snapshot",
73
- "clear_registry",
74
- "reset_registry",
75
- # Enum Field Support
76
- "validate_enum_value",
77
- "normalize_enum_value",
78
- # Drivers
136
+ "get_available_models",
137
+ "get_cache",
79
138
  "get_driver",
80
139
  "get_driver_for_model",
81
- "OpenAIDriver",
82
- "LocalHTTPDriver",
83
- "OllamaDriver",
84
- "ClaudeDriver",
85
- "LMStudioDriver",
86
- "AzureDriver",
87
- "GoogleDriver",
88
- "GroqDriver",
89
- "OpenRouterDriver",
90
- "GrokDriver",
91
- "AirLLMDriver",
92
- # Discovery
93
- "get_available_models",
94
- # Model Rates
95
- "get_model_rates",
140
+ "get_field_definition",
141
+ "get_field_names",
96
142
  "get_model_info",
143
+ "get_model_rates",
144
+ "get_registry_snapshot",
145
+ "get_required_fields",
146
+ "manual_extract_and_jsonify",
147
+ "normalize_enum_value",
97
148
  "refresh_rates_cache",
149
+ "register_field",
150
+ "render_output",
151
+ "reset_registry",
152
+ "run_suite_from_spec",
153
+ "stepwise_extract_with_model",
154
+ "validate_against_schema",
155
+ "validate_enum_value",
98
156
  ]
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.dev1'
32
+ __version_tuple__ = version_tuple = (0, 0, 34, 'dev1')
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
+ ]