prompture 0.0.29.dev8__py3-none-any.whl → 0.0.35__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 (67) hide show
  1. prompture/__init__.py +146 -23
  2. prompture/_version.py +34 -0
  3. prompture/aio/__init__.py +74 -0
  4. prompture/async_conversation.py +607 -0
  5. prompture/async_core.py +803 -0
  6. prompture/async_driver.py +169 -0
  7. prompture/cache.py +469 -0
  8. prompture/callbacks.py +55 -0
  9. prompture/cli.py +63 -4
  10. prompture/conversation.py +631 -0
  11. prompture/core.py +876 -263
  12. prompture/cost_mixin.py +51 -0
  13. prompture/discovery.py +164 -0
  14. prompture/driver.py +168 -5
  15. prompture/drivers/__init__.py +173 -69
  16. prompture/drivers/airllm_driver.py +109 -0
  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 +251 -34
  32. prompture/drivers/google_driver.py +107 -38
  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 +157 -23
  39. prompture/drivers/openai_driver.py +178 -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/scaffold/__init__.py +1 -0
  47. prompture/scaffold/generator.py +84 -0
  48. prompture/scaffold/templates/Dockerfile.j2 +12 -0
  49. prompture/scaffold/templates/README.md.j2 +41 -0
  50. prompture/scaffold/templates/config.py.j2 +21 -0
  51. prompture/scaffold/templates/env.example.j2 +8 -0
  52. prompture/scaffold/templates/main.py.j2 +86 -0
  53. prompture/scaffold/templates/models.py.j2 +40 -0
  54. prompture/scaffold/templates/requirements.txt.j2 +5 -0
  55. prompture/server.py +183 -0
  56. prompture/session.py +117 -0
  57. prompture/settings.py +18 -1
  58. prompture/tools.py +219 -267
  59. prompture/tools_schema.py +254 -0
  60. prompture/validator.py +3 -3
  61. {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/METADATA +117 -21
  62. prompture-0.0.35.dist-info/RECORD +66 -0
  63. {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/WHEEL +1 -1
  64. prompture-0.0.29.dev8.dist-info/RECORD +0 -27
  65. {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/entry_points.txt +0 -0
  66. {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/licenses/LICENSE +0 -0
  67. {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/top_level.txt +0 -0
prompture/__init__.py CHANGED
@@ -1,19 +1,96 @@
1
1
  """prompture - API package to convert LLM outputs into JSON + test harness."""
2
2
 
3
3
  from dotenv import load_dotenv
4
- from .core import ask_for_json, extract_and_jsonify, manual_extract_and_jsonify, Driver, clean_json_text, clean_json_text_with_ai, extract_with_model, stepwise_extract_with_model
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
18
+ from .core import (
19
+ Driver,
20
+ ask_for_json,
21
+ clean_json_text_with_ai,
22
+ extract_and_jsonify,
23
+ extract_from_data,
24
+ extract_from_pandas,
25
+ extract_with_model,
26
+ manual_extract_and_jsonify,
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,
55
+ )
5
56
  from .field_definitions import (
6
- FIELD_DEFINITIONS, get_field_definition, get_required_fields, get_field_names,
7
- field_from_registry, register_field, add_field_definition, add_field_definitions,
8
- get_registry_snapshot, clear_registry, reset_registry, validate_enum_value,
9
- 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,
10
70
  )
71
+ from .logging import JSONFormatter, configure_logging
72
+ from .model_rates import get_model_info, get_model_rates, refresh_rates_cache
11
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
77
+ from .tools_schema import ToolDefinition, ToolRegistry, tool_from_function
12
78
  from .validator import validate_against_schema
13
79
 
14
80
  # Load environment variables from .env file
15
81
  load_dotenv()
16
82
 
83
+ # Auto-configure cache from settings if enabled
84
+ if _settings.cache_enabled:
85
+ configure_cache(
86
+ backend=_settings.cache_backend,
87
+ enabled=True,
88
+ ttl=_settings.cache_ttl_seconds,
89
+ maxsize=_settings.cache_memory_maxsize,
90
+ db_path=_settings.cache_sqlite_path,
91
+ redis_url=_settings.cache_redis_url,
92
+ )
93
+
17
94
  # runtime package version (from installed metadata)
18
95
  try:
19
96
  # Python 3.8+
@@ -29,30 +106,76 @@ except Exception:
29
106
  __version__ = "0.0.0"
30
107
 
31
108
  __all__ = [
32
- "ask_for_json",
33
- "extract_and_jsonify",
34
- "manual_extract_and_jsonify",
35
- "run_suite_from_spec",
36
- "validate_against_schema",
109
+ "FIELD_DEFINITIONS",
110
+ "AirLLMDriver",
111
+ "AsyncConversation",
112
+ "AsyncDriver",
113
+ "AzureDriver",
114
+ "CacheBackend",
115
+ "ClaudeDriver",
116
+ "Conversation",
37
117
  "Driver",
118
+ "DriverCallbacks",
119
+ "GoogleDriver",
120
+ "GrokDriver",
121
+ "GroqDriver",
122
+ "JSONFormatter",
123
+ "LMStudioDriver",
124
+ "LocalHTTPDriver",
125
+ "MemoryCacheBackend",
126
+ "OllamaDriver",
127
+ "OpenAIDriver",
128
+ "OpenRouterDriver",
129
+ "RedisCacheBackend",
130
+ "ResponseCache",
131
+ "SQLiteCacheBackend",
132
+ "ToolDefinition",
133
+ "ToolRegistry",
134
+ "UsageSession",
135
+ "add_field_definition",
136
+ "add_field_definitions",
137
+ "ask_for_json",
38
138
  "clean_json_text",
39
139
  "clean_json_text_with_ai",
140
+ "clean_toon_text",
141
+ "clear_registry",
142
+ "configure_cache",
143
+ "configure_logging",
144
+ "extract_and_jsonify",
145
+ "extract_from_data",
146
+ "extract_from_pandas",
40
147
  "extract_with_model",
41
- "stepwise_extract_with_model",
42
- # Field Definitions
43
- "FIELD_DEFINITIONS",
148
+ "field_from_registry",
149
+ "get_available_models",
150
+ "get_cache",
151
+ "get_driver",
152
+ "get_driver_for_model",
44
153
  "get_field_definition",
45
- "get_required_fields",
46
154
  "get_field_names",
47
- # New Field Registry API
48
- "field_from_registry",
49
- "register_field",
50
- "add_field_definition",
51
- "add_field_definitions",
155
+ "get_model_info",
156
+ "get_model_rates",
52
157
  "get_registry_snapshot",
53
- "clear_registry",
158
+ "get_required_fields",
159
+ # Plugin registration API
160
+ "is_async_driver_registered",
161
+ "is_driver_registered",
162
+ "list_registered_async_drivers",
163
+ "list_registered_drivers",
164
+ "load_entry_point_drivers",
165
+ # Other exports
166
+ "manual_extract_and_jsonify",
167
+ "normalize_enum_value",
168
+ "refresh_rates_cache",
169
+ "register_async_driver",
170
+ "register_driver",
171
+ "register_field",
172
+ "render_output",
54
173
  "reset_registry",
55
- # Enum Field Support
174
+ "run_suite_from_spec",
175
+ "stepwise_extract_with_model",
176
+ "tool_from_function",
177
+ "unregister_async_driver",
178
+ "unregister_driver",
179
+ "validate_against_schema",
56
180
  "validate_enum_value",
57
- "normalize_enum_value",
58
- ]
181
+ ]
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.35'
32
+ __version_tuple__ = version_tuple = (0, 0, 35)
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
+ ]