Skip to main content

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 serve instances 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

  1. FastFlowLM (flm) CLI: Ensure flm is installed and available in your system's PATH.
  2. Python: Python 3.10+ (tested up to Python 3.14).
  3. Docker (Optional): Required only if using Selenium (use_selenium=True) for scraping.

Installation

To get fastflowlm you need an AMD processor with NPU and you need to install it from https://github.com/ROCm/FastFlowLM

Using pip

pip install fastflowml

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 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 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 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 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 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 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

fastflowml-0.6.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

fastflowml-0.6.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file fastflowml-0.6.0.tar.gz.

File metadata

  • Download URL: fastflowml-0.6.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

Hashes for fastflowml-0.6.0.tar.gz
Algorithm Hash digest
SHA256 6a63a050531336351dcdb419dddc8ca74a3a8f1199a4c5c65060b4612aa46664
MD5 6db3803e2f6a7ecae1e41d4dc0ca444c
BLAKE2b-256 235deee53607b39f704b9521de32e9ea978030b26c1346fab0d5cec97b386667

See more details on using hashes here.

File details

Details for the file fastflowml-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: fastflowml-0.6.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

Hashes for fastflowml-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2007a5b8901cf22aac781184093c035840e2c5ccf6b1545248ab444f0a6a1058
MD5 353e56093256041bf4a12c1107b3edf1
BLAKE2b-256 49c2801aeb372a681737cba33a1aac74fe6972ff83eed3a5e5e9505a0b5e4658

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 Sentry Error logging StatusPage Status page