Skip to main content

Model-specific prompt optimization. Your prompts, upgraded.

Project description

Fwip

Your prompts, upgraded.

PyPI npm License: MIT Tests

Fwip optimizes your AI prompts for specific models using research-backed, model-specific formatting rules. No LLM required — it's deterministic and instant.

Why?

Most developers write one prompt and hope it works on every model. But models were trained on different data with different RLHF processes. Claude works best with XML tags. Qwen3 needs /think prefixes. Mistral's Magistral emits [TOOL_CALLS] markers that break JSON parsing. Fwip handles all of this automatically.

Quick Start

Python

pip install fwip
import fwip

result = fwip.adapt(
    "You are a helpful data analyst. Extract all key metrics from the report.",
    model="claude-sonnet",
    task="extraction",
)

print(result.system)
# <role>
# You are a helpful data analyst.
# </role>
#
# <instructions>
# Extract all key metrics from the report.
# </instructions>
#
# <output_format>
# Return structured output matching the schema.
# </output_format>

print(result.changes)
# [Change(rule='xml-structure', description='Restructured prompt with XML tags', ...)]

TypeScript

npm install fwip
import { adapt } from "fwip";

const result = adapt({
  prompt: "You are a helpful data analyst. Extract all key metrics.",
  model: "claude-sonnet",
  task: "extraction",
});

console.log(result.system);
console.log(result.changes);

Before / After

Model Before After
Claude Sonnet Plain text prompt XML-tagged <role>, <instructions>, <output_format>
Qwen3 32B No thinking directive /no_think prefix + Tier 3 JSON reinforcement + English enforcement
Magistral Standard prompt Suppressed [TOOL_CALLS] and [THINK] markers + ultra-strong JSON-only
GLM 4.7 Flash Verbose prompt Simplified + nested object fix + English enforcement
Nemotron 9B Full prompt /think prefix + simplified to 3 steps + Tier 3 JSON reinforcement

Supported Models

11 model families, 39+ model variants:

Family Models Key Adaptations
Claude Sonnet, Opus, Haiku XML tags, role extraction, Haiku simplification
OpenAI GPT-4o, o1, o3 Reasoning hints, grounding rules
Gemini Pro, Flash, Ultra Identity (baseline — no changes)
Qwen 235B, 32B, Coder Thinking mode, Tier 3 for 32B, English enforcement
DeepSeek V3, V3.1, V3.2 Self-verification, JSON reinforcement
Mistral Large, Magistral, Devstral, Ministral Marker suppression, type fixes, simplification
Llama 405B, 70B, 8B, 3B Grounding, small model simplification
Kimi K2, K2.5 Source grounding, English enforcement
GLM 4.7, 4.7 Flash Nested object fix, English, Flash simplification
Nemotron 30B, 12B, 9B Thinking mode, Tier 3 for small, simplification
MiniMax M2 Self-verification, contract-style

Task Types

Task When to Use
extraction Pulling structured data from documents
analysis Evaluating, comparing, or reasoning about data
generation Creating content, writing, summarizing
code Writing or reviewing code
general Everything else (default)

MCP Server

npm install -g @fwip/mcp-server

Add to your MCP config:

{
  "mcpServers": {
    "fwip": {
      "command": "fwip-mcp-server"
    }
  }
}

Adding New Model Adapters

See CONTRIBUTING.md for a 5-step guide to adding support for new models.

Research

Fwip's adaptation rules are derived from empirical testing across 46 model configurations on structured output tasks. Research paper coming soon.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fwip-0.1.0.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fwip-0.1.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file fwip-0.1.0.tar.gz.

File metadata

  • Download URL: fwip-0.1.0.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for fwip-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0bf4f37c16e777d34403412d9944d3a33c2aee99b9f8874adbe9374da8743c4f
MD5 3f03bc0612763862c75426ee3d6d2e89
BLAKE2b-256 7cc2d0fc8bccaf0a16fa0bb4d8976e5fa735bfcfb92a63acb849751f2e87effd

See more details on using hashes here.

File details

Details for the file fwip-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fwip-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for fwip-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66a43a9e1130843e649df56a3d4b70b02dd7bb562c5aef19de026754e778a759
MD5 dca4a63a45dc693528b9df4fadbf4861
BLAKE2b-256 a46ff52361acc54c1e7a7cf3f1dda41a4a91ea0ca1c233a6d7b328a20dde60ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page