Extensible LLM provider system
Project description
Prompter: Extensible LLM Provider System
→ Community Packs: Domain-Specific Templates & Schemas
→ Contributor Guide
Installation
Install from PyPI:
pip install falat-prompter
Prompter is a flexible, plugin-style Python framework for working with multiple Large Language Model (LLM) providers. It supports dynamic provider loading, robust error handling, and unified response parsing, making it easy to integrate, extend, and use in any open source or production environment.
Purpose
Prompter aims to make prompt engineering and LLM integration easy, robust, and provider-agnostic. It lets you:
- Build prompts using templates or code
- Swap LLM providers with a single line change
- Get structured, type-safe responses from any provider
- Focus on your application logic, not SDK quirks
Features
- Plugin-style LLM providers: Easily add or swap providers (OpenAI, Cohere, Anthropic, local, etc.)
- Optional SDKs: Only install what you need; clear errors if a provider's SDK is missing
- Unified response handling: Consistent, type-safe output from all providers
- Prompting flexibility: Use prompt templates or build prompts programmatically
- Extensible and testable: Add new providers or prompt strategies with minimal code
How to Build Prompts
1. Using Template Files
Define prompts in external files (e.g., plain text, Jinja2) and load them at runtime. This enables easy prompt management and reuse.
Example:
File: prompter/templates/qa/qa.prompt
Background:
{{context}}
Question: {{question}}
Answer:
Python usage:
from prompter.prompt_template_processor import PromptTemplateProcessor
template = PromptTemplateProcessor("qa/qa.prompt")
prompt = template.render(context="France is a country in Europe.", question="What is the capital of France?")
2. Programmatic Prompt Building
Build prompts dynamically in code using f-strings or other logic. Useful for advanced or highly dynamic use cases.
Example:
context = "France is a country in Europe."
question = "What is the capital of France?"
prompt = f"Background:\n{context}\nQuestion: {question}\nAnswer:"
How to Run and Choose a Provider
Prompter makes it easy to switch between LLM providers. All providers have a unified interface:
from prompter.providers import OpenAIService, LocalLLMService
# Choose a provider (just change the class to switch)
service = OpenAIService(api_key="sk-...", model="gpt-4")
# or
# service = LocalLLMService(endpoint_url="http://localhost:8000/generate", model="llama-3")
response = service.generate(prompt)
print(response)
Defining Output Python Objects (Structured Output)
You can ask any provider to return a structured response matching a Python dataclass or Pydantic model. Just pass the result_object parameter:
With a dataclass:
from dataclasses import dataclass
@dataclass
class Answer:
answer: str
confidence: float
response = service.generate(prompt, result_object=Answer)
print(response.answer, response.confidence)
With a Pydantic model:
from pydantic import BaseModel
class Answer(BaseModel):
answer: str
confidence: float
response = service.generate(prompt, result_object=Answer)
print(response.answer, response.confidence)
Extending
- Add new providers by subclassing and implementing the
generatemethod. - Add new prompt strategies by creating new template loaders or programmatic builders.
License
MIT
Contributing
Pull requests and issues are welcome! Please see CONTRIBUTING.md for guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file falat_prompter-0.1.1.tar.gz.
File metadata
- Download URL: falat_prompter-0.1.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07907c1f80299a7efaaef1740c1a512332909b82bcba2324a2b72b899142d75c
|
|
| MD5 |
232c2fa19453f26fb1dc55d217234aa5
|
|
| BLAKE2b-256 |
d0ec0ff3f06fc5c29d9ccb01236c745bf47cbbd0960c2aaffe22f79ba841b539
|
Provenance
The following attestation bundles were made for falat_prompter-0.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on falatform/prompter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
falat_prompter-0.1.1.tar.gz -
Subject digest:
07907c1f80299a7efaaef1740c1a512332909b82bcba2324a2b72b899142d75c - Sigstore transparency entry: 316884398
- Sigstore integration time:
-
Permalink:
falatform/prompter@eeba07315715a2c82b3717ac6567eb107b3575cc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/falatform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@eeba07315715a2c82b3717ac6567eb107b3575cc -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file falat_prompter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: falat_prompter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd21598eb20ea99527bc66c59308339d897c276ced64d20c7a20a45b609b4fb0
|
|
| MD5 |
a5c7dfaf1c8aa4e153e9e0ff5ecc6926
|
|
| BLAKE2b-256 |
837cb1c593812267588cde92844469d37cf750f6f456f24d6fe3ffb219f75ab4
|
Provenance
The following attestation bundles were made for falat_prompter-0.1.1-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on falatform/prompter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
falat_prompter-0.1.1-py3-none-any.whl -
Subject digest:
cd21598eb20ea99527bc66c59308339d897c276ced64d20c7a20a45b609b4fb0 - Sigstore transparency entry: 316884409
- Sigstore integration time:
-
Permalink:
falatform/prompter@eeba07315715a2c82b3717ac6567eb107b3575cc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/falatform
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@eeba07315715a2c82b3717ac6567eb107b3575cc -
Trigger Event:
workflow_dispatch
-
Statement type: