Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the model pipeline
|
| 5 |
+
generator = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1")
|
| 6 |
+
|
| 7 |
+
# Define the function to generate proposal text
|
| 8 |
+
def generate_proposal(client_description):
|
| 9 |
+
prompt = f"Generate a professional project proposal based on the following client request:\n\n{client_description}\n\nProposal:"
|
| 10 |
+
result = generator(prompt, max_length=512, do_sample=True, temperature=0.7)
|
| 11 |
+
return result[0]['generated_text']
|
| 12 |
+
|
| 13 |
+
# Build the Gradio interface
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=generate_proposal,
|
| 16 |
+
inputs=gr.Textbox(label="Client Requirement", placeholder="Describe the project or client needs here...", lines=5),
|
| 17 |
+
outputs=gr.Textbox(label="Generated Proposal", lines=15),
|
| 18 |
+
title="AI Proposal Generator",
|
| 19 |
+
description="This app uses Mistral-7B to generate business proposals based on client input."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Launch the app
|
| 23 |
+
iface.launch()
|