|
''' |
|
from transformers import pipeline |
|
import gradio as gr |
|
|
|
generator = pipeline("text-generation", model="sshleifer/tiny-gpt2") |
|
|
|
def generate_proposal(client_description): |
|
generated = generator(client_description, max_length=100, do_sample=True, temperature=0.7) |
|
return generated[0]["generated_text"] |
|
|
|
iface = gr.Interface( |
|
fn=generate_proposal, |
|
inputs=gr.Textbox(label="Client Requirement"), |
|
outputs=gr.Textbox(label="Generated Proposal"), |
|
title="Fast Proposal Generator", |
|
description="Lightweight and fast text generator using TinyGPT2" |
|
) |
|
|
|
iface.launch() |
|
|
|
''' |
|
|
|
|
|
|
|
import gradio as gr |
|
from transformers import pipeline |
|
from fpdf import FPDF |
|
import tempfile |
|
import os |
|
|
|
|
|
generator = pipeline("text-generation", model="gpt2") |
|
|
|
|
|
def generate_proposal(client_description): |
|
|
|
raw = generator(f"{client_description}", max_length=300, do_sample=True, temperature=0.7)[0]['generated_text'] |
|
|
|
|
|
generated_only = raw.replace(client_description, "").strip() |
|
|
|
|
|
formatted = f""" |
|
PROJECT PROPOSAL |
|
|
|
Client Requirement: |
|
{client_description} |
|
|
|
Proposed Solution: |
|
{generated_only} |
|
|
|
Sincerely, |
|
AI Proposal Generator |
|
""" |
|
|
|
|
|
pdf = FPDF() |
|
pdf.add_page() |
|
pdf.set_auto_page_break(auto=True, margin=15) |
|
pdf.set_font("Arial", size=12) |
|
for line in formatted.split("\n"): |
|
pdf.multi_cell(0, 10, line) |
|
|
|
|
|
pdf_file = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") |
|
pdf.output(pdf_file.name) |
|
|
|
|
|
email_body = f""" |
|
Subject: Business Proposal for Your Project |
|
|
|
Dear Client, |
|
|
|
Please find attached a professional proposal based on your provided requirements. We're confident this solution meets your needs and are open to feedback or further discussion. |
|
|
|
Best regards, |
|
Your Name |
|
AI Proposal Generator |
|
""" |
|
|
|
return formatted, email_body, pdf_file.name |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_proposal, |
|
inputs=gr.Textbox(label="Client Requirement", placeholder="Describe the project or client needs here...", lines=5), |
|
outputs=[ |
|
gr.Textbox(label="Formatted Proposal", lines=15), |
|
gr.Textbox(label="Email Template", lines=10), |
|
gr.File(label="Download Proposal as PDF") |
|
], |
|
title="AI Proposal Generator", |
|
description="Enter a client request and receive a professional proposal, an email draft, and a downloadable PDF." |
|
) |
|
|
|
iface.launch() |
|
|