Add AI_BizGen file
Browse files
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load a free language model pipeline
|
5 |
+
# You can replace 'google/flan-t5-small' with other free models like 'bigscience/bloom-560m'
|
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:
|
12 |
+
Industry: {industry}
|
13 |
+
Challenge: {challenge}
|
14 |
+
Goals: {goals}
|
15 |
+
"""
|
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:
|
23 |
+
Strengths: {strengths}
|
24 |
+
Weaknesses: {weaknesses}
|
25 |
+
Opportunities: {opportunities}
|
26 |
+
Threats: {threats}
|
27 |
+
"""
|
28 |
+
response = strategy_generator(prompt, max_length=200, num_return_sequences=1)
|
29 |
+
return response[0]['generated_text']
|
30 |
+
|
31 |
+
# Gradio interface
|
32 |
+
with gr.Blocks() as demo:
|
33 |
+
gr.Markdown("# AI Business Strategy Generator")
|
34 |
+
gr.Markdown("Create actionable business strategies and SWOT analyses.")
|
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")
|
40 |
+
strategy_button = gr.Button("Generate Strategy")
|
41 |
+
strategy_output = gr.Textbox(label="Generated Strategy", lines=10)
|
42 |
+
|
43 |
+
strategy_button.click(
|
44 |
+
generate_strategy,
|
45 |
+
inputs=[industry_input, challenge_input, goals_input],
|
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="Weak
|