Skip to content

feat: add Flask microservice example#27

Open
MarceloAdan73 wants to merge 2 commits into
SantanderAI:mainfrom
MarceloAdan73:feat/flask-example
Open

feat: add Flask microservice example#27
MarceloAdan73 wants to merge 2 commits into
SantanderAI:mainfrom
MarceloAdan73:feat/flask-example

Conversation

@MarceloAdan73

@MarceloAdan73 MarceloAdan73 commented Jul 5, 2026

Copy link
Copy Markdown

Description

Adds examples/flask_microservice.py — a multi-provider LLM API built with
Flask and llm_bridge. Includes:

  • POST /chat — generic multi-provider chat (mock, callable, openai)
  • POST /summarize — structured summarisation with prompt engineering
  • GET /health — readiness check
  • Callable provider — local text analyser (word count, language detection,
    reading time) with zero network dependencies

This is the first example showing llm_bridge integrated in a web framework,
demonstrating real-world patterns like per-request provider selection and
structured prompt templates.

Checklist

  • ruff check . and black --check . pass
  • No secrets, API keys, internal URLs, or proprietary content are included

@MarceloAdan73
MarceloAdan73 requested review from a team as code owners July 5, 2026 01:57
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@MarceloAdan73

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Jul 5, 2026
@opensource-SantanderAI

Copy link
Copy Markdown
Contributor

Thanks for this — it's a genuinely useful addition and the first example that integrates llm_bridge into a web framework. The per-request provider selection and the zero-network callable text analyser are nice touches. ruff and black are clean.

One security change is required before we can merge, plus a couple of minor cleanups:

  1. Do not ship debug=True + host="0.0.0.0" (in main()). The Werkzeug debugger enables arbitrary code execution if the port is reachable, and 0.0.0.0 exposes it on all interfaces — an insecure default for an example that people copy-paste (CodeQL/bandit flag this as py/flask-debug / B201). Please default to:
    app.run(host="127.0.0.1", port=5000, debug=False)
    If you want debug to remain toggleable, gate it behind an env var, e.g. debug=os.environ.get("FLASK_DEBUG") == "1".
  2. Declare the example's dependency: the module needs Flask. The docstring mentions pip install flask, which is fine, but consider an examples/requirements.txt (or an [examples] extra) so it's reproducible.
  3. Minor: the PR description has some leftover tutorial text ("Luego clic en Create pull request.") — please remove it.

With the debug/host fix the example is good to go. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants