prompture 0.0.29.dev8__py3-none-any.whl → 0.0.38.dev2__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 (79) hide show
  1. prompture/__init__.py +264 -23
  2. prompture/_version.py +34 -0
  3. prompture/agent.py +924 -0
  4. prompture/agent_types.py +156 -0
  5. prompture/aio/__init__.py +74 -0
  6. prompture/async_agent.py +880 -0
  7. prompture/async_conversation.py +789 -0
  8. prompture/async_core.py +803 -0
  9. prompture/async_driver.py +193 -0
  10. prompture/async_groups.py +551 -0
  11. prompture/cache.py +469 -0
  12. prompture/callbacks.py +55 -0
  13. prompture/cli.py +63 -4
  14. prompture/conversation.py +826 -0
  15. prompture/core.py +894 -263
  16. prompture/cost_mixin.py +51 -0
  17. prompture/discovery.py +187 -0
  18. prompture/driver.py +206 -5
  19. prompture/drivers/__init__.py +175 -67
  20. prompture/drivers/airllm_driver.py +109 -0
  21. prompture/drivers/async_airllm_driver.py +26 -0
  22. prompture/drivers/async_azure_driver.py +123 -0
  23. prompture/drivers/async_claude_driver.py +113 -0
  24. prompture/drivers/async_google_driver.py +316 -0
  25. prompture/drivers/async_grok_driver.py +97 -0
  26. prompture/drivers/async_groq_driver.py +90 -0
  27. prompture/drivers/async_hugging_driver.py +61 -0
  28. prompture/drivers/async_lmstudio_driver.py +148 -0
  29. prompture/drivers/async_local_http_driver.py +44 -0
  30. prompture/drivers/async_ollama_driver.py +135 -0
  31. prompture/drivers/async_openai_driver.py +102 -0
  32. prompture/drivers/async_openrouter_driver.py +102 -0
  33. prompture/drivers/async_registry.py +133 -0
  34. prompture/drivers/azure_driver.py +42 -9
  35. prompture/drivers/claude_driver.py +257 -34
  36. prompture/drivers/google_driver.py +295 -42
  37. prompture/drivers/grok_driver.py +35 -32
  38. prompture/drivers/groq_driver.py +33 -26
  39. prompture/drivers/hugging_driver.py +6 -6
  40. prompture/drivers/lmstudio_driver.py +97 -19
  41. prompture/drivers/local_http_driver.py +6 -6
  42. prompture/drivers/ollama_driver.py +168 -23
  43. prompture/drivers/openai_driver.py +184 -9
  44. prompture/drivers/openrouter_driver.py +37 -25
  45. prompture/drivers/registry.py +306 -0
  46. prompture/drivers/vision_helpers.py +153 -0
  47. prompture/field_definitions.py +106 -96
  48. prompture/group_types.py +147 -0
  49. prompture/groups.py +530 -0
  50. prompture/image.py +180 -0
  51. prompture/logging.py +80 -0
  52. prompture/model_rates.py +217 -0
  53. prompture/persistence.py +254 -0
  54. prompture/persona.py +482 -0
  55. prompture/runner.py +49 -47
  56. prompture/scaffold/__init__.py +1 -0
  57. prompture/scaffold/generator.py +84 -0
  58. prompture/scaffold/templates/Dockerfile.j2 +12 -0
  59. prompture/scaffold/templates/README.md.j2 +41 -0
  60. prompture/scaffold/templates/config.py.j2 +21 -0
  61. prompture/scaffold/templates/env.example.j2 +8 -0
  62. prompture/scaffold/templates/main.py.j2 +86 -0
  63. prompture/scaffold/templates/models.py.j2 +40 -0
  64. prompture/scaffold/templates/requirements.txt.j2 +5 -0
  65. prompture/serialization.py +218 -0
  66. prompture/server.py +183 -0
  67. prompture/session.py +117 -0
  68. prompture/settings.py +19 -1
  69. prompture/tools.py +219 -267
  70. prompture/tools_schema.py +254 -0
  71. prompture/validator.py +3 -3
  72. prompture-0.0.38.dev2.dist-info/METADATA +369 -0
  73. prompture-0.0.38.dev2.dist-info/RECORD +77 -0
  74. {prompture-0.0.29.dev8.dist-info → prompture-0.0.38.dev2.dist-info}/WHEEL +1 -1
  75. prompture-0.0.29.dev8.dist-info/METADATA +0 -368
  76. prompture-0.0.29.dev8.dist-info/RECORD +0 -27
  77. {prompture-0.0.29.dev8.dist-info → prompture-0.0.38.dev2.dist-info}/entry_points.txt +0 -0
  78. {prompture-0.0.29.dev8.dist-info → prompture-0.0.38.dev2.dist-info}/licenses/LICENSE +0 -0
  79. {prompture-0.0.29.dev8.dist-info → prompture-0.0.38.dev2.dist-info}/top_level.txt +0 -0
prompture/__init__.py CHANGED
@@ -1,19 +1,161 @@
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 .agent import Agent, AgentIterator, StreamedAgentResult
6
+ from .agent_types import (
7
+ AgentCallbacks,
8
+ AgentResult,
9
+ AgentState,
10
+ AgentStep,
11
+ GuardrailError,
12
+ ModelRetry,
13
+ RunContext,
14
+ StepType,
15
+ StreamEvent,
16
+ StreamEventType,
17
+ )
18
+ from .async_agent import AsyncAgent, AsyncAgentIterator, AsyncStreamedAgentResult
19
+ from .async_conversation import AsyncConversation
20
+ from .async_driver import AsyncDriver
21
+ from .async_groups import (
22
+ AsyncLoopGroup,
23
+ AsyncRouterAgent,
24
+ AsyncSequentialGroup,
25
+ ParallelGroup,
26
+ )
27
+ from .cache import (
28
+ CacheBackend,
29
+ MemoryCacheBackend,
30
+ RedisCacheBackend,
31
+ ResponseCache,
32
+ SQLiteCacheBackend,
33
+ configure_cache,
34
+ get_cache,
35
+ )
36
+ from .callbacks import DriverCallbacks
37
+ from .conversation import Conversation
38
+ from .core import (
39
+ Driver,
40
+ ask_for_json,
41
+ clean_json_text_with_ai,
42
+ extract_and_jsonify,
43
+ extract_from_data,
44
+ extract_from_pandas,
45
+ extract_with_model,
46
+ manual_extract_and_jsonify,
47
+ render_output,
48
+ stepwise_extract_with_model,
49
+ )
50
+ from .discovery import get_available_models
51
+ from .drivers import (
52
+ AirLLMDriver,
53
+ AzureDriver,
54
+ ClaudeDriver,
55
+ GoogleDriver,
56
+ GrokDriver,
57
+ GroqDriver,
58
+ LMStudioDriver,
59
+ LocalHTTPDriver,
60
+ OllamaDriver,
61
+ OpenAIDriver,
62
+ OpenRouterDriver,
63
+ get_driver,
64
+ get_driver_for_model,
65
+ # Plugin registration API
66
+ is_async_driver_registered,
67
+ is_driver_registered,
68
+ list_registered_async_drivers,
69
+ list_registered_drivers,
70
+ load_entry_point_drivers,
71
+ register_async_driver,
72
+ register_driver,
73
+ unregister_async_driver,
74
+ unregister_driver,
75
+ )
5
76
  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
77
+ FIELD_DEFINITIONS,
78
+ add_field_definition,
79
+ add_field_definitions,
80
+ clear_registry,
81
+ field_from_registry,
82
+ get_field_definition,
83
+ get_field_names,
84
+ get_registry_snapshot,
85
+ get_required_fields,
86
+ normalize_enum_value,
87
+ register_field,
88
+ reset_registry,
89
+ validate_enum_value,
90
+ )
91
+ from .group_types import (
92
+ AgentError,
93
+ ErrorPolicy,
94
+ GroupCallbacks,
95
+ GroupResult,
96
+ GroupStep,
97
+ )
98
+ from .groups import (
99
+ GroupAsAgent,
100
+ LoopGroup,
101
+ RouterAgent,
102
+ SequentialGroup,
103
+ )
104
+ from .image import (
105
+ ImageContent,
106
+ ImageInput,
107
+ image_from_base64,
108
+ image_from_bytes,
109
+ image_from_file,
110
+ image_from_url,
111
+ make_image,
112
+ )
113
+ from .logging import JSONFormatter, configure_logging
114
+ from .model_rates import get_model_info, get_model_rates, refresh_rates_cache
115
+ from .persistence import ConversationStore
116
+ from .persona import (
117
+ PERSONAS,
118
+ Persona,
119
+ clear_persona_registry,
120
+ get_persona,
121
+ get_persona_names,
122
+ get_persona_registry_snapshot,
123
+ get_trait,
124
+ get_trait_names,
125
+ load_personas_from_directory,
126
+ register_persona,
127
+ register_trait,
128
+ reset_persona_registry,
129
+ reset_trait_registry,
10
130
  )
11
131
  from .runner import run_suite_from_spec
132
+ from .serialization import (
133
+ EXPORT_VERSION,
134
+ export_conversation,
135
+ export_usage_session,
136
+ import_conversation,
137
+ import_usage_session,
138
+ )
139
+ from .session import UsageSession
140
+ from .settings import settings as _settings
141
+ from .tools import clean_json_text, clean_toon_text
142
+ from .tools_schema import ToolDefinition, ToolRegistry, tool_from_function
12
143
  from .validator import validate_against_schema
13
144
 
14
145
  # Load environment variables from .env file
15
146
  load_dotenv()
16
147
 
148
+ # Auto-configure cache from settings if enabled
149
+ if _settings.cache_enabled:
150
+ configure_cache(
151
+ backend=_settings.cache_backend,
152
+ enabled=True,
153
+ ttl=_settings.cache_ttl_seconds,
154
+ maxsize=_settings.cache_memory_maxsize,
155
+ db_path=_settings.cache_sqlite_path,
156
+ redis_url=_settings.cache_redis_url,
157
+ )
158
+
17
159
  # runtime package version (from installed metadata)
18
160
  try:
19
161
  # Python 3.8+
@@ -29,30 +171,129 @@ except Exception:
29
171
  __version__ = "0.0.0"
30
172
 
31
173
  __all__ = [
32
- "ask_for_json",
33
- "extract_and_jsonify",
34
- "manual_extract_and_jsonify",
35
- "run_suite_from_spec",
36
- "validate_against_schema",
174
+ "EXPORT_VERSION",
175
+ "FIELD_DEFINITIONS",
176
+ "PERSONAS",
177
+ "Agent",
178
+ "AgentCallbacks",
179
+ "AgentError",
180
+ "AgentIterator",
181
+ "AgentResult",
182
+ "AgentState",
183
+ "AgentStep",
184
+ "AirLLMDriver",
185
+ "AsyncAgent",
186
+ "AsyncAgentIterator",
187
+ "AsyncConversation",
188
+ "AsyncDriver",
189
+ "AsyncLoopGroup",
190
+ "AsyncRouterAgent",
191
+ "AsyncSequentialGroup",
192
+ "AsyncStreamedAgentResult",
193
+ "AzureDriver",
194
+ "CacheBackend",
195
+ "ClaudeDriver",
196
+ "Conversation",
197
+ "ConversationStore",
37
198
  "Driver",
199
+ "DriverCallbacks",
200
+ "ErrorPolicy",
201
+ "GoogleDriver",
202
+ "GrokDriver",
203
+ "GroqDriver",
204
+ "GroupAsAgent",
205
+ "GroupCallbacks",
206
+ "GroupResult",
207
+ "GroupStep",
208
+ "GuardrailError",
209
+ "ImageContent",
210
+ "ImageInput",
211
+ "JSONFormatter",
212
+ "LMStudioDriver",
213
+ "LocalHTTPDriver",
214
+ "LoopGroup",
215
+ "MemoryCacheBackend",
216
+ "ModelRetry",
217
+ "OllamaDriver",
218
+ "OpenAIDriver",
219
+ "OpenRouterDriver",
220
+ "ParallelGroup",
221
+ "Persona",
222
+ "RedisCacheBackend",
223
+ "ResponseCache",
224
+ "RouterAgent",
225
+ "RunContext",
226
+ "SQLiteCacheBackend",
227
+ "SequentialGroup",
228
+ "StepType",
229
+ "StreamEvent",
230
+ "StreamEventType",
231
+ "StreamedAgentResult",
232
+ "ToolDefinition",
233
+ "ToolRegistry",
234
+ "UsageSession",
235
+ "add_field_definition",
236
+ "add_field_definitions",
237
+ "ask_for_json",
38
238
  "clean_json_text",
39
239
  "clean_json_text_with_ai",
240
+ "clean_toon_text",
241
+ "clear_persona_registry",
242
+ "clear_registry",
243
+ "configure_cache",
244
+ "configure_logging",
245
+ "export_conversation",
246
+ "export_usage_session",
247
+ "extract_and_jsonify",
248
+ "extract_from_data",
249
+ "extract_from_pandas",
40
250
  "extract_with_model",
41
- "stepwise_extract_with_model",
42
- # Field Definitions
43
- "FIELD_DEFINITIONS",
251
+ "field_from_registry",
252
+ "get_available_models",
253
+ "get_cache",
254
+ "get_driver",
255
+ "get_driver_for_model",
44
256
  "get_field_definition",
45
- "get_required_fields",
46
257
  "get_field_names",
47
- # New Field Registry API
48
- "field_from_registry",
49
- "register_field",
50
- "add_field_definition",
51
- "add_field_definitions",
258
+ "get_model_info",
259
+ "get_model_rates",
260
+ "get_persona",
261
+ "get_persona_names",
262
+ "get_persona_registry_snapshot",
52
263
  "get_registry_snapshot",
53
- "clear_registry",
264
+ "get_required_fields",
265
+ "get_trait",
266
+ "get_trait_names",
267
+ "image_from_base64",
268
+ "image_from_bytes",
269
+ "image_from_file",
270
+ "image_from_url",
271
+ "import_conversation",
272
+ "import_usage_session",
273
+ "is_async_driver_registered",
274
+ "is_driver_registered",
275
+ "list_registered_async_drivers",
276
+ "list_registered_drivers",
277
+ "load_entry_point_drivers",
278
+ "load_personas_from_directory",
279
+ "make_image",
280
+ "manual_extract_and_jsonify",
281
+ "normalize_enum_value",
282
+ "refresh_rates_cache",
283
+ "register_async_driver",
284
+ "register_driver",
285
+ "register_field",
286
+ "register_persona",
287
+ "register_trait",
288
+ "render_output",
289
+ "reset_persona_registry",
54
290
  "reset_registry",
55
- # Enum Field Support
291
+ "reset_trait_registry",
292
+ "run_suite_from_spec",
293
+ "stepwise_extract_with_model",
294
+ "tool_from_function",
295
+ "unregister_async_driver",
296
+ "unregister_driver",
297
+ "validate_against_schema",
56
298
  "validate_enum_value",
57
- "normalize_enum_value",
58
- ]
299
+ ]
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.38.dev2'
32
+ __version_tuple__ = version_tuple = (0, 0, 38, 'dev2')
33
+
34
+ __commit_id__ = commit_id = None