|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
|
|
strategy_generator = pipeline("text2text-generation", model="google/flan-t5-small") |
|
|
|
|
|
def generate_strategy(industry, challenge, goals): |
|
prompt = f""" |
|
Create a detailed business strategy for the following: |
|
Industry: {industry} |
|
Challenge: {challenge} |
|
Goals: {goals} |
|
""" |
|
response = strategy_generator(prompt, max_length=200, num_return_sequences=1) |
|
return response[0]['generated_text'] |
|
|
|
|
|
def swot_analysis(strengths, weaknesses, opportunities, threats): |
|
prompt = f""" |
|
Perform a SWOT analysis based on the following: |
|
Strengths: {strengths} |
|
Weaknesses: {weaknesses} |
|
Opportunities: {opportunities} |
|
Threats: {threats} |
|
""" |
|
response = strategy_generator(prompt, max_length=200, num_return_sequences=1) |
|
return response[0]['generated_text'] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
gr.Markdown("# AI Business Strategy Generator") |
|
gr.Markdown("Create actionable business strategies and SWOT analyses.") |
|
|
|
with gr.Tab("Generate Strategy"): |
|
industry_input = gr.Textbox(label="Industry", placeholder="E.g., E-commerce, Healthcare") |
|
challenge_input = gr.Textbox(label="Key Challenge", placeholder="E.g., Low customer retention") |
|
goals_input = gr.Textbox(label="Goals", placeholder="E.g., Increase sales by 20% in 6 months") |
|
strategy_button = gr.Button("Generate Strategy") |
|
strategy_output = gr.Textbox(label="Generated Strategy", lines=10) |
|
|
|
strategy_button.click( |
|
generate_strategy, |
|
inputs=[industry_input, challenge_input, goals_input], |
|
outputs=[strategy_output] |
|
) |
|
|
|
with gr.Tab("SWOT Analysis"): |
|
strengths_input = gr.Textbox(label="Strengths", placeholder="E.g., Strong brand presence") |
|
weaknesses_input = gr.Textbox(label="Weak |
|
|