smithery.ai

add-example

Create a new Prompture usage example script. Follows project conventions for file naming, section structure, docstrings, and output formatting. Use when demonstrating extraction use cases or provider integrations.

First seen Mar 30, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Skill metadata

Parsed from SKILL.md frontmatter.

Version1.1
More metadata
author
prompture
version
1.1

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 5,459 B
  • docs SUMMARY.md 232 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 2 installs

SKILL.md

Add an Example File

Creates a standalone runnable example in examples/.

Before Starting

Ask the user:

  • Topic / use case (e.g. "medical record extraction", "product review analysis")
  • Extraction methodextractwithmodel, stepwiseextractwithmodel, extractandjsonify, extractfromdata, or renderoutput
  • Provider/model — e.g. openai/gpt-4o, moonshot/kimi-k2-0905-preview, ollama/llama3.1:8b

Two Example Styles

Provider example (e.g. moonshotexample.py, grokexample.py)

Shows extractandjsonify with a specific provider. Two sections:

  1. Default instruction with the provider's primary model
  2. Custom instruction with the same or a different model

Use-case example (e.g. medicalrecordexample.py, resumecvexample.py)

Shows extraction for a specific domain using Pydantic models.

Conventions

  • File: examples/{descriptivename}example.py
  • Standalone — no test framework imports
  • Always print extracted result and usage metadata (prompttokens, completiontokens, totaltokens, cost, modelname)
  • Realistic sample text, not lorem ipsum
  • Under 100 lines when possible

Provider Example Template

"""
Example: Using extract_and_jsonify with {Provider}.

This script demonstrates:
1. Initializing the {Provider} driver manually (ignoring AI_PROVIDER).
2. Extracting structured information from text using a JSON schema.
3. Overriding the {Provider} model per call with `model_name`.
4. Running both a default extraction and a custom-instruction extraction.

Setup:
    export {PROVIDER}_API_KEY="your-key-here"
    # or add to .env file
"""

import json

from prompture import extract_and_jsonify

# 1. Define the raw text
text = "Maria is 32 years old and works as a software developer in New York. She loves hiking and photography."

# 2. Define the JSON schema
json_schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer"},
        "profession": {"type": "string"},
        "city": {"type": "string"},
        "hobbies": {"type": "array", "items": {"type": "string"}},
    },
}

# === FIRST EXAMPLE: Default instruction with {Model} ===
print("Extracting information into JSON with default instruction...")

result = extract_and_jsonify(
    text=text,
    json_schema=json_schema,
    model_name="{provider}/{model}",  # explicitly select model
)

json_output = result["json_string"]
json_object = result["json_object"]
usage = result["usage"]

print("\nRaw JSON output from model:")
print(json_output)

print("\nSuccessfully parsed JSON:")
print(json.dumps(json_object, indent=2))

print("\n=== TOKEN USAGE STATISTICS ===")
print(f"Prompt tokens: {usage['prompt_tokens']}")
print(f"Completion tokens: {usage['completion_tokens']}")
print(f"Total tokens: {usage['total_tokens']}")
print(f"Cost: ${usage['cost']:.6f}")
print(f"Model used: {usage['model_name']}")


# === SECOND EXAMPLE: Custom instruction with {Alt Model} ===
print("\n\n=== SECOND EXAMPLE - CUSTOM INSTRUCTION & DIFFERENT MODEL ===")
print("Extracting information with custom instruction...")

custom_result = extract_and_jsonify(
    text=text,
    json_schema=json_schema,
    instruction_template="Parse the biographical details from this text:",
    model_name="{provider}/{alt_model}",  # override model here
)

custom_json_output = custom_result["json_string"]
custom_json_object = custom_result["json_object"]
custom_usage = custom_result["usage"]

print("\nRaw JSON output with custom instruction:")
print(custom_json_output)

print("\nSuccessfully parsed JSON (custom instruction):")
print(json.dumps(custom_json_object, indent=2))

print("\n=== TOKEN USAGE STATISTICS (Custom Template) ===")
print(f"Prompt tokens: {custom_usage['prompt_tokens']}")
print(f"Completion tokens: {custom_usage['completion_tokens']}")
print(f"Total tokens: {custom_usage['total_tokens']}")
print(f"Cost: ${custom_usage['cost']:.6f}")
print(f"Model used: {custom_usage['model_name']}")

Use-Case Example Template

"""
Example: {Title}

This example demonstrates:
1. {Feature 1}
2. {Feature 2}

Requirements:
    pip install prompture
    # Set up provider credentials in .env
"""

import json

from pydantic import BaseModel, Field

from prompture import extract_with_model

# 1. Define the output model
class MyModel(BaseModel):
    field1: str = Field(description="...")
    field2: int = Field(description="...")

# 2. Input text
text = """
Realistic sample text here.
"""

# 3. Extract
MODEL = "openai/gpt-4o-mini"

result = extract_with_model(
    model_cls=MyModel,
    text=text,
    model_name=MODEL,
)

# 4. Results
print("Extracted model:")
print(result["model"])
print()
print("Usage metadata:")
print(json.dumps(result["usage"], indent=2))

Rules

  • Import only from prompture public API
  • Include docstring header listing features and setup requirements
  • If provider-specific, mention the env var in the docstring
  • Check available models for the provider: python -c "from prompture.modelrates import getallprovidermodels; print(getallprovidermodels('{modelsdev_name}')[:10])"