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/cli.py CHANGED
@@ -1,23 +1,82 @@
1
1
  import json
2
+
2
3
  import click
3
- from .runner import run_suite_from_spec
4
+
4
5
  from .drivers import OllamaDriver
6
+ from .runner import run_suite_from_spec
7
+
5
8
 
6
9
  @click.group()
7
10
  def cli():
8
- """Simple CLI to run JSON specs"""
11
+ """Prompture CLI -- structured LLM output toolkit."""
9
12
  pass
10
13
 
14
+
11
15
  @cli.command()
12
16
  @click.argument("specfile", type=click.Path(exists=True))
13
17
  @click.argument("outfile", type=click.Path())
14
18
  def run(specfile, outfile):
15
19
  """Run a spec JSON and save report."""
16
- with open(specfile, "r", encoding="utf-8") as fh:
20
+ with open(specfile, encoding="utf-8") as fh:
17
21
  spec = json.load(fh)
18
22
  # Use Ollama as default driver since it can run locally
19
23
  drivers = {"ollama": OllamaDriver(endpoint="http://localhost:11434", model="gemma:latest")}
20
24
  report = run_suite_from_spec(spec, drivers)
21
25
  with open(outfile, "w", encoding="utf-8") as fh:
22
26
  json.dump(report, fh, indent=2, ensure_ascii=False)
23
- click.echo(f"Report saved to {outfile}")
27
+ click.echo(f"Report saved to {outfile}")
28
+
29
+
30
+ @cli.command()
31
+ @click.option("--model", default="openai/gpt-4o-mini", help="Model string (provider/model).")
32
+ @click.option("--system-prompt", default=None, help="System prompt for conversations.")
33
+ @click.option("--host", default="0.0.0.0", help="Bind host.")
34
+ @click.option("--port", default=8000, type=int, help="Bind port.")
35
+ @click.option("--cors-origins", default=None, help="Comma-separated CORS origins (use * for all).")
36
+ def serve(model, system_prompt, host, port, cors_origins):
37
+ """Start an API server wrapping AsyncConversation.
38
+
39
+ Requires the 'serve' extra: pip install prompture[serve]
40
+ """
41
+ try:
42
+ import uvicorn
43
+ except ImportError:
44
+ click.echo("Error: uvicorn not installed. Run: pip install prompture[serve]", err=True)
45
+ raise SystemExit(1) from None
46
+
47
+ from .server import create_app
48
+
49
+ origins = [o.strip() for o in cors_origins.split(",")] if cors_origins else None
50
+ app = create_app(
51
+ model_name=model,
52
+ system_prompt=system_prompt,
53
+ cors_origins=origins,
54
+ )
55
+
56
+ click.echo(f"Starting Prompture server on {host}:{port} with model {model}")
57
+ uvicorn.run(app, host=host, port=port)
58
+
59
+
60
+ @cli.command()
61
+ @click.argument("output_dir", type=click.Path())
62
+ @click.option("--name", default="my_app", help="Project name.")
63
+ @click.option("--model", default="openai/gpt-4o-mini", help="Default model string.")
64
+ @click.option("--docker/--no-docker", default=True, help="Include Dockerfile.")
65
+ def scaffold(output_dir, name, model, docker):
66
+ """Generate a standalone FastAPI project using Prompture.
67
+
68
+ Requires the 'scaffold' extra: pip install prompture[scaffold]
69
+ """
70
+ try:
71
+ from .scaffold.generator import scaffold_project
72
+ except ImportError:
73
+ click.echo("Error: jinja2 not installed. Run: pip install prompture[scaffold]", err=True)
74
+ raise SystemExit(1) from None
75
+
76
+ scaffold_project(
77
+ output_dir=output_dir,
78
+ project_name=name,
79
+ model_name=model,
80
+ include_docker=docker,
81
+ )
82
+ click.echo(f"Project scaffolded at {output_dir}")