AI_BizGen / app.py
mgbam's picture
Add AI_BizGen file
9434c21
raw
history blame
2.07 kB
import gradio as gr
from transformers import pipeline
# Load a free language model pipeline
# You can replace 'google/flan-t5-small' with other free models like 'bigscience/bloom-560m'
strategy_generator = pipeline("text2text-generation", model="google/flan-t5-small")
# Function to generate business strategy
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']
# Function to perform SWOT analysis
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']
# Gradio interface
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