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.
- prompture/__init__.py +146 -23
- prompture/_version.py +34 -0
- prompture/aio/__init__.py +74 -0
- prompture/async_conversation.py +607 -0
- prompture/async_core.py +803 -0
- prompture/async_driver.py +169 -0
- prompture/cache.py +469 -0
- prompture/callbacks.py +55 -0
- prompture/cli.py +63 -4
- prompture/conversation.py +631 -0
- prompture/core.py +876 -263
- prompture/cost_mixin.py +51 -0
- prompture/discovery.py +164 -0
- prompture/driver.py +168 -5
- prompture/drivers/__init__.py +173 -69
- prompture/drivers/airllm_driver.py +109 -0
- prompture/drivers/async_airllm_driver.py +26 -0
- prompture/drivers/async_azure_driver.py +117 -0
- prompture/drivers/async_claude_driver.py +107 -0
- prompture/drivers/async_google_driver.py +132 -0
- prompture/drivers/async_grok_driver.py +91 -0
- prompture/drivers/async_groq_driver.py +84 -0
- prompture/drivers/async_hugging_driver.py +61 -0
- prompture/drivers/async_lmstudio_driver.py +79 -0
- prompture/drivers/async_local_http_driver.py +44 -0
- prompture/drivers/async_ollama_driver.py +125 -0
- prompture/drivers/async_openai_driver.py +96 -0
- prompture/drivers/async_openrouter_driver.py +96 -0
- prompture/drivers/async_registry.py +129 -0
- prompture/drivers/azure_driver.py +36 -9
- prompture/drivers/claude_driver.py +251 -34
- prompture/drivers/google_driver.py +107 -38
- prompture/drivers/grok_driver.py +29 -32
- prompture/drivers/groq_driver.py +27 -26
- prompture/drivers/hugging_driver.py +6 -6
- prompture/drivers/lmstudio_driver.py +26 -13
- prompture/drivers/local_http_driver.py +6 -6
- prompture/drivers/ollama_driver.py +157 -23
- prompture/drivers/openai_driver.py +178 -9
- prompture/drivers/openrouter_driver.py +31 -25
- prompture/drivers/registry.py +306 -0
- prompture/field_definitions.py +106 -96
- prompture/logging.py +80 -0
- prompture/model_rates.py +217 -0
- prompture/runner.py +49 -47
- prompture/scaffold/__init__.py +1 -0
- prompture/scaffold/generator.py +84 -0
- prompture/scaffold/templates/Dockerfile.j2 +12 -0
- prompture/scaffold/templates/README.md.j2 +41 -0
- prompture/scaffold/templates/config.py.j2 +21 -0
- prompture/scaffold/templates/env.example.j2 +8 -0
- prompture/scaffold/templates/main.py.j2 +86 -0
- prompture/scaffold/templates/models.py.j2 +40 -0
- prompture/scaffold/templates/requirements.txt.j2 +5 -0
- prompture/server.py +183 -0
- prompture/session.py +117 -0
- prompture/settings.py +18 -1
- prompture/tools.py +219 -267
- prompture/tools_schema.py +254 -0
- prompture/validator.py +3 -3
- {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/METADATA +117 -21
- prompture-0.0.35.dist-info/RECORD +66 -0
- {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/WHEEL +1 -1
- prompture-0.0.29.dev8.dist-info/RECORD +0 -27
- {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/entry_points.txt +0 -0
- {prompture-0.0.29.dev8.dist-info → prompture-0.0.35.dist-info}/licenses/LICENSE +0 -0
- {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
|
-
|
|
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
|
-
"""
|
|
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,
|
|
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}")
|