File size: 2,072 Bytes
9434c21 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
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
|