Brochure Generator

  • gradio
  • ollama
  • gemini
  • multi-model streaming

Brochure Generator turns a company name and landing page URL into a polished brochure draft — with one Gradio UI that streams from either a local Ollama model or Gemini’s free cloud models.

Brochure Generator project visual

The challenge

The hard part was not wiring two APIs — it was designing one interface where users can switch providers, submit or stop mid-stream, and watch markdown appear token by token. A shared stream_brochure generator keeps the UX identical while the backend routes to Ollama or Gemini.

One form, two providers

Inputs stay deliberately simple: company name, website URL, and a model dropdown. Example presets (Hugging Face on Ollama, Edward Donner on Gemini) make it easy to try both paths. Clear / Submit / Stop controls keep long generations under control.

Brochure Generator Gradio UI with model selector

Gradio interface

Gradio’s Interface becomes the shared contract. The front end never needs to know how each provider streams — only that the backend yields growing markdown.

import gradio as gr

def stream_brochure(company_name: str, url: str, model: str = "Ollama"):
    """Yield growing markdown so Gradio can stream the response."""
    prompt = build_brochure_prompt(company_name, url)

    if model == "Gemini":
        yield from stream_gemini(prompt)
    else:
        yield from stream_ollama(prompt)

demo = gr.Interface(
    fn=stream_brochure,
    inputs=[
        gr.Textbox(label="Company name:"),
        gr.Textbox(label="Landing page URL including http:// or https://"),
        gr.Dropdown(
            choices=["Ollama", "Gemini"],
            value="Ollama",
            label="Select model",
        ),
    ],
    outputs=gr.Markdown(label="Response:"),
    examples=[
        ["Hugging Face", "https://huggingface.co", "Ollama"],
        ["Edward Donner", "https://edwarddonner.com", "Gemini"],
    ],
    title="Brochure Generator",
)

demo.launch()

Multi-model streaming

Every provider speaks the same shape: a Python generator that yields partial strings. Gradio’s queue updates the Markdown panel over SSE as tokens arrive — whether the model runs locally or in the cloud.

def stream_ollama(prompt: str):
    accumulated = ""
    for chunk in ollama_chat_stream(prompt):
        accumulated += chunk
        yield accumulated

def stream_gemini(prompt: str):
    accumulated = ""
    for chunk in gemini_generate_stream(prompt):
        accumulated += chunk
        yield accumulated
Brochure response streaming in the Gradio UI

Generated brochure output

Submit a company and URL, pick Ollama or Gemini, and the response panel fills with structured brochure copy — overview, solutions, and enterprise messaging — ready to edit or ship.

Hugging Face brochure generated with Ollama

Why multi-model

  • Ollama — run offline or keep sensitive URLs on your machine.
  • Gemini free models — quick cloud inference when local hardware is busy.
  • One Gradio surface — compare outputs without rebuilding the UI twice.

Try the live demo

view project