Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,10 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Load a free language model pipeline
|
5 |
-
#
|
6 |
strategy_generator = pipeline("text2text-generation", model="google/flan-t5-small")
|
7 |
|
8 |
-
# Function to generate business strategy
|
9 |
def generate_strategy(industry, challenge, goals):
|
10 |
prompt = f"""
|
11 |
Create a detailed business strategy for the following:
|
@@ -16,7 +16,7 @@ def generate_strategy(industry, challenge, goals):
|
|
16 |
response = strategy_generator(prompt, max_length=200, num_return_sequences=1)
|
17 |
return response[0]['generated_text']
|
18 |
|
19 |
-
# Function to perform SWOT analysis
|
20 |
def swot_analysis(strengths, weaknesses, opportunities, threats):
|
21 |
prompt = f"""
|
22 |
Perform a SWOT analysis based on the following:
|
@@ -31,9 +31,11 @@ def swot_analysis(strengths, weaknesses, opportunities, threats):
|
|
31 |
# Gradio interface
|
32 |
with gr.Blocks() as demo:
|
33 |
gr.Markdown("# AI Business Strategy Generator")
|
34 |
-
gr.Markdown("
|
35 |
|
|
|
36 |
with gr.Tab("Generate Strategy"):
|
|
|
37 |
industry_input = gr.Textbox(label="Industry", placeholder="E.g., E-commerce, Healthcare")
|
38 |
challenge_input = gr.Textbox(label="Key Challenge", placeholder="E.g., Low customer retention")
|
39 |
goals_input = gr.Textbox(label="Goals", placeholder="E.g., Increase sales by 20% in 6 months")
|
@@ -46,6 +48,21 @@ with gr.Blocks() as demo:
|
|
46 |
outputs=[strategy_output]
|
47 |
)
|
48 |
|
|
|
49 |
with gr.Tab("SWOT Analysis"):
|
|
|
50 |
strengths_input = gr.Textbox(label="Strengths", placeholder="E.g., Strong brand presence")
|
51 |
-
weaknesses_input = gr.Textbox(label="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
# Load a free language model pipeline
|
5 |
+
# Replace 'google/flan-t5-small' with another open-source model if needed
|
6 |
strategy_generator = pipeline("text2text-generation", model="google/flan-t5-small")
|
7 |
|
8 |
+
# Function to generate a business strategy
|
9 |
def generate_strategy(industry, challenge, goals):
|
10 |
prompt = f"""
|
11 |
Create a detailed business strategy for the following:
|
|
|
16 |
response = strategy_generator(prompt, max_length=200, num_return_sequences=1)
|
17 |
return response[0]['generated_text']
|
18 |
|
19 |
+
# Function to perform a SWOT analysis
|
20 |
def swot_analysis(strengths, weaknesses, opportunities, threats):
|
21 |
prompt = f"""
|
22 |
Perform a SWOT analysis based on the following:
|
|
|
31 |
# Gradio interface
|
32 |
with gr.Blocks() as demo:
|
33 |
gr.Markdown("# AI Business Strategy Generator")
|
34 |
+
gr.Markdown("Generate actionable business strategies and SWOT analyses using AI.")
|
35 |
|
36 |
+
# Tab 1: Generate Business Strategy
|
37 |
with gr.Tab("Generate Strategy"):
|
38 |
+
gr.Markdown("### Input Information to Generate a Business Strategy")
|
39 |
industry_input = gr.Textbox(label="Industry", placeholder="E.g., E-commerce, Healthcare")
|
40 |
challenge_input = gr.Textbox(label="Key Challenge", placeholder="E.g., Low customer retention")
|
41 |
goals_input = gr.Textbox(label="Goals", placeholder="E.g., Increase sales by 20% in 6 months")
|
|
|
48 |
outputs=[strategy_output]
|
49 |
)
|
50 |
|
51 |
+
# Tab 2: SWOT Analysis
|
52 |
with gr.Tab("SWOT Analysis"):
|
53 |
+
gr.Markdown("### Input Information to Perform a SWOT Analysis")
|
54 |
strengths_input = gr.Textbox(label="Strengths", placeholder="E.g., Strong brand presence")
|
55 |
+
weaknesses_input = gr.Textbox(label="Weaknesses", placeholder="E.g., Limited market reach")
|
56 |
+
opportunities_input = gr.Textbox(label="Opportunities", placeholder="E.g., Emerging markets")
|
57 |
+
threats_input = gr.Textbox(label="Threats", placeholder="E.g., Rising competition")
|
58 |
+
swot_button = gr.Button("Perform SWOT Analysis")
|
59 |
+
swot_output = gr.Textbox(label="Generated SWOT Analysis", lines=10)
|
60 |
+
|
61 |
+
swot_button.click(
|
62 |
+
swot_analysis,
|
63 |
+
inputs=[strengths_input, weaknesses_input, opportunities_input, threats_input],
|
64 |
+
outputs=[swot_output]
|
65 |
+
)
|
66 |
+
|
67 |
+
# Launch the Gradio app
|
68 |
+
demo.launch()
|