FastFlowLM
A Python orchestration client and wrapper for the FastFlowLM (flm) NPU-accelerated local inference engine (optimized for AMD Ryzen AI / Strix NPU).
FastFlowServer provides seamless lifecycle management for the flm server, OpenAI-compatible chat and completions, real-time web search and scraping tool augmentation, self-healing JSON repair, and multimodal vision & audio querying.
Features
- Automated Lifecycle Management: Start, stop, monitor, and query
flm serveinstances directly from Python. - Search & Web Scraping Tools: Augment prompts with live internet search (DuckDuckGo) and headless browser scraping (Playwright or Selenium).
- Self-Healing JSON Generation: Extract and automatically repair malformed JSON outputs using LLM-assisted sanitization.
- Multimodal Support: Single/multi-image vision analysis and audio inference.
- OpenAI-Compatible API: Chat completions with custom conversation history.
Prerequisites
- FastFlowLM (
flm) CLI: Ensureflmis installed and available in your system'sPATH. - Python: Python 3.10+ (tested up to Python 3.14).
- Docker (Optional): Required only if using Selenium (
use_selenium=True) for scraping.
Installation
Using pip
pip install fastflowml
Or install dependencies manually:
pip install requests markdownify openai ddgs playwright beautifulsoup4 selenium
If using Playwright (Default Web Scraper)
Install the Chromium browser binary for Playwright:
playwright install chromium
Using uv
uv sync
Quick Start & Basic Samples
1. Basic Server Startup & Text Query
from FastFlowLM import FastFlowServer
# Initialize server wrapper with target model
ff = FastFlowServer(model="qwen3-it:4b", port=11435)
try:
# Start flm server (pulls model automatically if missing)
ff.start()
# Run a simple prompt
response = ff.query_plain("Explain quantum computing in 2 sentences.", use_search=False)
print("Response:\n", response)
finally:
# Stop flm server process
ff.stop()
2. Search-Augmented Querying (Live DuckDuckGo Search)
from src.FastFlowLM import FastFlowServer
ff = FastFlowServer(model="qwen3.5:9b")
try:
ff.start()
# Query with live web search enabled
answer = ff.query_plain(
"What are the latest tech headlines today?",
use_search=True,
max_search_results=5
)
print("Answer with live search:\n", answer)
finally:
ff.stop()
3. Structured JSON Output with Schema Sample
FastFlowServer can enforce structured JSON output and automatically repair invalid syntax.
from src.FastFlowLM import FastFlowServer
ff = FastFlowServer(model="qwen3-it:4b")
try:
ff.start()
schema = {
"city": "Amsterdam",
"temperature_celsius": 18,
"condition": "Partly Cloudy",
"highlights": ["rain possible in afternoon"]
}
result = ff.query_plain(
"Give me the current weather report for Paris",
is_json=True,
json_sample=schema,
use_search=True
)
print("Parsed JSON Result:", result)
print("City:", result.get("city"))
finally:
ff.stop()
4. Multi-Turn Conversation Chat
from src.FastFlowLM import FastFlowServer
ff = FastFlowServer(model="qwen3-it:4b")
try:
ff.start()
# Build conversation context
ff.addconvo_system("You are a helpful coding assistant specialized in Python.")
ff.addconvo_user("How do I reverse a list in Python?")
reply, _ = ff.query_chat(use_search=False)
print("Assistant:", reply)
ff.addconvo_assistant(reply)
# Follow-up question
ff.addconvo_user("What is the time and space complexity?")
reply2, _ = ff.query_chat(use_search=False)
print("Assistant:", reply2)
finally:
ff.stop()
5. Multimodal: Vision & Audio Analysis
Vision Analysis (Single or Multiple Images)
from src.FastFlowLM import FastFlowServer
ff = FastFlowServer(model="qwen3.5:9b")
try:
ff.start()
# Single image
_, description = ff.query_vision(
prompt="Describe what you see in this chart.",
image_path="chart.png"
)
print("Description:", description)
# Multiple images comparison
_, comparison = ff.query_vision_multiple(
prompt="Compare these two images and list differences.",
image_paths=["before.png", "after.png"]
)
print("Comparison:", comparison)
finally:
ff.stop()
Audio Analysis
from src.FastFlowLM import FastFlowServer
ff = FastFlowServer(model="gemma4-it:e4b")
try:
ff.start()
transcript = ff.audio(
prompt="Transcribe and summarize this audio recording.",
audio_path="recording.wav"
)
print("Transcript / Summary:", transcript)
finally:
ff.stop()
6. Model Management
from src.FastFlowLM import FastFlowServer
ff = FastFlowServer()
# List available & downloaded models
models = ff.list_models()
print("Models:", models)
# Pull a new model
ff.pull_model("qwen3-it:4b")
# Remove a model
# ff.remove_model("old-model:tag")
Detailed Documentation
For full API documentation, all constructor parameters, method signatures, error handling, and advanced configurations, refer to FastFlowLM.readme.
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 fastflowml-0.5.0.tar.gz.
File metadata
- Download URL: fastflowml-0.5.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5846b2260b87fc0214505d86c976356e64e9d163a4bafac45409599028229390
|
|
| MD5 |
6726f228d4b393627c7c2f9873ea542e
|
|
| BLAKE2b-256 |
4d6849db1e1960404be7a466b4d9c285b71d367ac006eec3e5363314b4846ae1
|
File details
Details for the file fastflowml-0.5.0-py3-none-any.whl.
File metadata
- Download URL: fastflowml-0.5.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86988133605f29e2aa3e32219b0ac99da7835a13188f19d3c1a40833157e955e
|
|
| MD5 |
fe8708160d8a0e1124e57e27e30e6315
|
|
| BLAKE2b-256 |
4a5e5761be97b73f114322bd8541fd38f24ccca74a7f58c1050247919eee2064
|