WWW.MARKTECHPOST.COM
A Step-by-Step Coding Guide to Building a Gemini-Powered AI Startup Pitch Generator Using LiteLLM Framework, Gradio, and FPDF in Google Colab with PDF Export Support
In this tutorial, we built a powerful and interactive AI application that generates startup pitch ideas using Googles Gemini Pro model through the versatile LiteLLM framework. LiteLLM!pip install litellm gradio fpdf --quiet!pip install litellm gradio fpdf quiet installs the core libraries needed for this project. It brings in LiteLLM for interacting with Gemini via a unified API, Gradio for creating a simple web interface, and FPDF for exporting the AI-generated pitch into a well-formatted PDF fileall while suppressing verbose installation logs with quiet.import osimport gradio as grimport uuidimport urllib.requestfrom fpdf import FPDFfrom litellm import completionapi_key = "Your API Key"We import all the essential Python libraries used in the project, including os for file operations, uuid for generating unique filenames, and urllib for downloading fonts. We also initialize Gradio for the UI, FPDF for PDF creation, and LiteLLMs completion function to interface with Gemini. The api_key variable stores the users Gemini API key, which is required to authenticate requests.import urllib.requestimport zipfileimport osimport shutilif not os.path.exists("DejaVuSans.ttf"): print(" Downloading DejaVuSans.ttf...") font_zip_url = "https://downloads.sourceforge.net/project/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, files in os.walk("dejavu-extracted"): for file in files: if file == "DejaVuSans.ttf": ttf_path = os.path.join(root, file) shutil.copy(ttf_path, "DejaVuSans.ttf") print(" Font extracted and ready.") breakHere, we ensure that the DejaVuSans.ttf font is available to create Unicode-compatible PDFs. It downloads the font zip file from SourceForge, extracts its contents, and copies the .ttf file to the working directory. This step is crucial for handling special characters from Geminis output when generating the final pitch PDF using FPDF.def call_gemini(system_prompt, user_prompt): messages = [ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt} ] response = completion( model="gemini/gemini-2.0-flash-lite", messages=messages, api_key=api_key ) return response["choices"][0]["message"]["content"]This function, call_gemini, is a wrapper that uses LiteLLMs completion API to interact with the Gemini 2.0 Flash Lite model. It accepts a system prompt and a user prompt, structures them in OpenAI-compatible format, sends the request using the provided API key, and returns the generated responsemaking it easy to reuse across various application parts.def generate_startup_pitch(theme): try: idea_prompt = f"Generate an innovative startup idea in the field of {theme}. Focus on solving real problems using modern technology." tagline_prompt = "Based on the idea you just gave, generate a short, catchy tagline for the startup." pitch_prompt = """ Based on the previous startup idea, write a concise pitch deck covering: 1. Problem 2. Solution 3. Market Opportunity 4. Team Description 5. Business Model 6. Traction or Future Plan Format it in a way that looks like slide notes for a VC pitch. """ idea = call_gemini("You are an innovation strategist.", idea_prompt) tagline = call_gemini("You are a branding expert.", tagline_prompt) pitch = call_gemini("You are 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", size=12) full_text = f"Startup Idea:\n{idea}\n\nTagline:\n{tagline}\n\nPitch Deck:\n{pitch}" pdf.multi_cell(0, 10, full_text) pdf.output(filename) return idea, tagline, pitch, filename except Exception as e: return f" Error: {e}", "", "", NoneThe generate_startup_pitch function orchestrates the entire startup generation process. It sends tailored prompts to Gemini via LiteLLM to produce a startup idea, a catchy tagline, and a structured pitch deck. The responses are then combined into a formatted PDF using FPDF, with proper Unicode support via the DejaVu font. The PDF is saved with a unique filename, enabling users to download their personalized pitch. Error handling ensures smooth execution and user feedback 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 industry", placeholder="e.g., mental health, fintech, climate tech") generate_button = gr.Button("Generate Pitch") idea_output = gr.Textbox(label="Startup Idea") tagline_output = gr.Textbox(label="Tagline") pitch_output = gr.Textbox(label="Pitch Deck Summary", lines=10) pdf_output = gr.File(label="Download Pitch as PDF") def wrapper(theme): idea, tagline, pitch, pdf_path = generate_startup_pitch(theme) return idea, tagline, pitch, pdf_path generate_button.click(fn=wrapper, inputs=theme_input, outputs=[idea_output, tagline_output, pitch_output, pdf_output])demo.launch(share=True)We defined the Gradio user interface for the AI Startup Pitch Generator. Using gr.Blocks() creates a clean layout with an input box for the user to enter a startup theme or industry and a button to trigger the pitch generation. Once clicked, the wrapper function calls generate_startup_pitch, returning a startup idea, tagline, pitch summary, and a downloadable PDF. The share=True flag enables public access to the app, making it easy to demo or share the tool with others via a unique URL.App Interface to Generate IdeasDownload the PDF ReportIn conclusion, by combining the abstraction power of LiteLLM with the creative intelligence of Googles Gemini Pro, this tutorial highlights how developers can rapidly prototype intelligent, production-ready applications. LiteLLM drastically simplifies working with diverse LLM APIs by maintaining a consistent OpenAI-style calling interface across providers like Gemini, Claude, OpenAI, and more. Through Gradio, we added an intuitive front end to accept user input and display results, while FPDF allowed us to convert AI-generated content into shareable, well-formatted PDF documents. This tutorial showcases how to build a multi-component AI app in a Colab-friendly environment and underlines LiteLLMs role as a pivotal gateway to the expanding ecosystem of language models. Whether youre building MVPs or production tools, LiteLLM offers the flexibility and scalability to keep your LLM workflow fast and future-proof.Here is the Colab Notebook. Also,dont forget to follow us onTwitterand join ourTelegram ChannelandLinkedIn Group. Dont Forget to join our85k+ ML SubReddit. Asif RazzaqWebsite| + postsBioAsif Razzaq is the CEO of Marktechpost Media Inc.. As a visionary entrepreneur and engineer, Asif is committed to harnessing the potential of Artificial Intelligence for social good. His most recent endeavor is the launch of an Artificial Intelligence Media Platform, Marktechpost, which stands out for its in-depth coverage of machine learning and deep learning news that is both technically sound and easily understandable by a wide audience. The platform boasts of over 2 million monthly views, illustrating its popularity among audiences.Asif Razzaqhttps://www.marktechpost.com/author/6flvq/Transformer Meets Diffusion: How the Transfusion Architecture Empowers GPT-4os CreativityAsif Razzaqhttps://www.marktechpost.com/author/6flvq/Meta AI Just Released Llama 4 Scout and Llama 4 Maverick: The First Set of Llama 4 ModelsAsif Razzaqhttps://www.marktechpost.com/author/6flvq/NVIDIA AI Released AgentIQ: An Open-Source Library for Efficiently Connecting and Optimizing Teams of AI AgentsAsif Razzaqhttps://www.marktechpost.com/author/6flvq/A Code Implementation to Building a Context-Aware AI Assistant in Google Colab Using LangChain, LangGraph, Gemini Pro, and Model Context Protocol (MCP) Principles with Tool Integration Support
0 Comments
0 Shares
82 Views