Documentation Index
Fetch the complete documentation index at: https://simplellmfunc.cn/llms.txt
Use this file to discover all available pages before exploring further.
Prompt as Code
The third design principle: your docstring IS the system prompt. Prompts live in code, version with code, and are maintained like code.The Problem with Separated Prompts
Common patterns in LLM applications:- Prompts in YAML/JSON files, loaded at runtime
- Prompt templates in a database, edited through a UI
- Prompts as string constants defined far from where they’re used
- Prompts managed by a “prompt engineering” tool separate from the codebase
Docstring as System Prompt
In SimpleLLMFunc, the function’s docstring IS the prompt:- Co-located — Right next to the function signature it describes
- Versioned — Changes tracked in git like any other code
- Type-aware — The framework adds parameter types and return schema automatically
- Refactorable — Rename a parameter, IDE updates the docstring reference
- Reviewable — PRs show prompt changes in the same diff as code changes
What the Framework Adds
Your docstring is the starting point, not the entire system prompt. The framework augments it with:- Parameter type descriptions — Generated from your type annotations
- Return type schema — Structured output format instructions
- Tool best practices — Injected from tool docstrings when tools are mounted
- Output constraints — XML/JSON formatting rules based on return type
Template Parameters for Dynamic Prompts
When you need runtime-variable content in the prompt:For llm_chat: Latest System Message Wins
In multi-turn agents, you can update the system prompt mid-conversation by placing asystem message in history. The framework uses the latest system message — or falls back to the docstring if none exists in history.
This enables:
- Dynamic system prompts that evolve based on conversation state
- SelfRef context injection (experiences, summaries) without docstring mutation
- Per-turn context customization while keeping the base prompt in code
The Implication for Prompt Engineering
Prompt engineering becomes software engineering:- Test prompts — Assert on function outputs with known inputs
- Review prompts — Prompt changes go through code review
- Version prompts — Git blame tells you when and why a prompt changed
- Profile prompts — Measure latency and token usage per function
- Compose prompts — Build complex behaviors from smaller, tested prompt-functions