6.1 C
New York
Monday, April 7, 2025

A Step-by-Step Coding Information to Constructing a Gemini-Powered AI Startup Pitch Generator Utilizing LiteLLM Framework, Gradio, and FPDF in Google Colab with PDF Export Help


On this tutorial, we constructed a strong and interactive AI utility that generates startup pitch concepts utilizing Google’s Gemini Professional mannequin by the versatile LiteLLM framework. LiteLLM is the spine of this implementation, offering a unified interface to work together with over 100 LLM suppliers utilizing OpenAI-compatible APIs, eliminating the complexity of coping with particular person SDKs. By leveraging LiteLLM, we seamlessly related to Gemini’s capabilities for artistic ideation and wrapped the outputs right into a user-friendly Gradio interface. Additionally, we used FPDF to generate polished, Unicode-compatible PDFs containing the complete startup pitch deck. This tutorial demonstrates how trendy AI tooling, together with LiteLLM, Gradio, Google Generative AI, and FPDF, can construct an end-to-end answer for entrepreneurs, innovators, and builders.

!pip set up litellm gradio fpdf --quiet

!pip set up litellm gradio fpdf –quiet installs the core libraries wanted for this undertaking. It brings in LiteLLM for interacting with Gemini through a unified API, Gradio for making a easy net interface, and FPDF for exporting the AI-generated pitch right into a well-formatted PDF file—all whereas suppressing verbose set up logs with –quiet.

import os
import gradio as gr
import uuid
import urllib.request
from fpdf import FPDF
from litellm import completion


api_key = "Your API Key"

We import all of the important Python libraries used within the undertaking, together with os for file operations, uuid for producing distinctive filenames, and urllib for downloading fonts. We additionally initialize Gradio for the UI, FPDF for PDF creation, and LiteLLM’s completion operate to interface with Gemini. The api_key variable shops the consumer’s Gemini API key, which is required to authenticate requests.

import urllib.request
import zipfile
import os
import shutil


if not os.path.exists("DejaVuSans.ttf"):
    print("⏬ Downloading DejaVuSans.ttf...")
    font_zip_url = "https://downloads.sourceforge.internet/undertaking/dejavu/dejavu/2.37/dejavu-fonts-ttf-2.37.zip"
    font_zip_path = "dejavu-fonts.zip"


    urllib.request.urlretrieve(font_zip_url, font_zip_path)


    with zipfile.ZipFile(font_zip_path, 'r') as zip_ref:
        zip_ref.extractall("dejavu-extracted")


    for root, dirs, information in os.stroll("dejavu-extracted"):
        for file in information:
            if file == "DejaVuSans.ttf":
                ttf_path = os.path.be part of(root, file)
                shutil.copy(ttf_path, "DejaVuSans.ttf")
                print("✅ Font extracted and prepared.")
                break

Right here, we be certain that the DejaVuSans.ttf font is obtainable to create Unicode-compatible PDFs. It downloads the font zip file from SourceForge, extracts its contents, and copies the .ttf file to the working listing. This step is essential for dealing with particular characters from Gemini’s output when producing the ultimate pitch PDF utilizing FPDF.

def call_gemini(system_prompt, user_prompt):
    messages = [
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": user_prompt}
    ]
    response = completion(
        mannequin="gemini/gemini-2.0-flash-lite",
        messages=messages,
        api_key=api_key
    )
    return response["choices"][0]["message"]["content"]

This operate, call_gemini, is a wrapper that makes use of LiteLLM’s completion API to work together with the Gemini 2.0 Flash Lite mannequin. It accepts a system immediate and a consumer immediate, buildings them in OpenAI-compatible format, sends the request utilizing the supplied API key, and returns the generated response—making it simple to reuse throughout numerous utility components.

def generate_startup_pitch(theme):
    attempt:
        idea_prompt = f"Generate an progressive startup thought within the discipline of {theme}. Concentrate on fixing actual issues utilizing trendy know-how."
        tagline_prompt = "Based mostly on the thought you simply gave, generate a brief, catchy tagline for the startup."
        pitch_prompt = """
        Based mostly on the earlier startup thought, write a concise pitch deck masking:
        1. Drawback
        2. Resolution
        3. Market Alternative
        4. Crew Description
        5. Enterprise Mannequin
        6. Traction or Future Plan
        Format it in a manner that appears like slide notes for a VC pitch.
        """


        thought = call_gemini("You're an innovation strategist.", idea_prompt)
        tagline = call_gemini("You're a branding professional.", tagline_prompt)
        pitch = call_gemini("You're a startup mentor writing a pitch deck.", pitch_prompt)


        filename = f"startup_pitch_{uuid.uuid4().hex[:8]}.pdf"
        pdf = FPDF()
        pdf.add_page()
        pdf.add_font("DejaVu", "", font_path, uni=True)
        pdf.set_font("DejaVu", dimension=12)


        full_text = f"Startup Concept:n{thought}nnTagline:n{tagline}nnPitch Deck:n{pitch}"
        pdf.multi_cell(0, 10, full_text)
        pdf.output(filename)


        return thought, tagline, pitch, filename
    besides Exception as e:
        return f"⚠️ Error: {e}", "", "", None

The generate_startup_pitch operate orchestrates the whole startup era course of. It sends tailor-made prompts to Gemini through LiteLLM to provide a startup thought, a catchy tagline, and a structured pitch deck. The responses are then mixed right into a formatted PDF utilizing FPDF, with correct Unicode help through the DejaVu font. The PDF is saved with a novel filename, enabling customers to obtain their customized pitch. Error dealing with ensures clean execution and consumer suggestions in case of failures.

with gr.Blocks() as demo:
    gr.Markdown("# 🚀 AI Startup Pitch Generator (with PDF Export)")
    theme_input = gr.Textbox(label="Enter a theme or business", placeholder="e.g., psychological well being, fintech, local weather tech")


    generate_button = gr.Button("Generate Pitch")


    idea_output = gr.Textbox(label="Startup Concept")
    tagline_output = gr.Textbox(label="Tagline")
    pitch_output = gr.Textbox(label="Pitch Deck Abstract", traces=10)
    pdf_output = gr.File(label="Obtain Pitch as PDF")


    def wrapper(theme):
        thought, tagline, pitch, pdf_path = generate_startup_pitch(theme)
        return thought, tagline, pitch, pdf_path


    generate_button.click on(fn=wrapper, inputs=theme_input, outputs=[idea_output, tagline_output, pitch_output, pdf_output])


demo.launch(share=True)

We outlined the Gradio consumer interface for the AI Startup Pitch Generator. Utilizing gr.Blocks() creates a clear structure with an enter field for the consumer to enter a startup theme or business and a button to set off the pitch era. As soon as clicked, the wrapper operate calls generate_startup_pitch, returning a startup thought, tagline, pitch abstract, and a downloadable PDF. The share=True flag permits public entry to the app, making it simple to demo or share the instrument with others through a novel URL.

App Interface to Generate Concepts

Obtain the PDF Report

In conclusion, by combining the abstraction energy of LiteLLM with the artistic intelligence of Google’s Gemini Professional, this tutorial highlights how builders can quickly prototype clever, production-ready purposes. LiteLLM drastically simplifies working with numerous LLM APIs by sustaining a constant OpenAI-style calling interface throughout suppliers like Gemini, Claude, OpenAI, and extra. By Gradio, we added an intuitive entrance finish to just accept consumer enter and show outcomes, whereas FPDF allowed us to transform AI-generated content material into shareable, well-formatted PDF paperwork. This tutorial showcases find out how to construct a multi-component AI app in a Colab-friendly atmosphere and underlines LiteLLM’s position as a pivotal gateway to the increasing ecosystem of language fashions. Whether or not you’re constructing MVPs or manufacturing instruments, LiteLLM presents the pliability and scalability to maintain your LLM workflow quick and future-proof.


Right here is the Colab Pocket book. Additionally, don’t overlook to comply with us on Twitter and be part of our Telegram Channel and LinkedIn Group. Don’t Neglect to affix our 85k+ ML SubReddit.

🔥 [Register Now] miniCON Digital Convention on OPEN SOURCE AI: FREE REGISTRATION + Certificates of Attendance + 3 Hour Quick Occasion (April 12, 9 am- 12 pm PST) + Arms on Workshop [Sponsored]


Asif Razzaq is the CEO of Marktechpost Media Inc.. As a visionary entrepreneur and engineer, Asif is dedicated to harnessing the potential of Synthetic Intelligence for social good. His most up-to-date endeavor is the launch of an Synthetic Intelligence Media Platform, Marktechpost, which stands out for its in-depth protection of machine studying and deep studying information that’s each technically sound and simply comprehensible by a large viewers. The platform boasts of over 2 million month-to-month views, illustrating its recognition amongst audiences.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles