Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,39 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load a
|
5 |
-
#
|
6 |
-
strategy_generator = pipeline("text2text-generation", model="google/flan-t5-
|
7 |
|
8 |
# Function to generate a business strategy
|
9 |
def generate_strategy(industry, challenge, goals):
|
10 |
prompt = f"""
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
"""
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
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:
|
23 |
-
Strengths: {strengths}
|
24 |
-
Weaknesses: {weaknesses}
|
25 |
-
Opportunities: {opportunities}
|
26 |
-
Threats: {threats}
|
|
|
27 |
"""
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
30 |
|
31 |
# Gradio interface
|
32 |
with gr.Blocks() as demo:
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load a more capable open-source model
|
5 |
+
# You can use "google/flan-t5-large" or other alternatives depending on available resources
|
6 |
+
strategy_generator = pipeline("text2text-generation", model="google/flan-t5-large")
|
7 |
|
8 |
# Function to generate a business strategy
|
9 |
def generate_strategy(industry, challenge, goals):
|
10 |
prompt = f"""
|
11 |
+
Generate a detailed and actionable business strategy for a company in the {industry} industry.
|
12 |
+
- Challenge: {challenge}
|
13 |
+
- Goals: {goals}
|
14 |
+
Provide realistic steps and measurable outcomes to address the challenge and achieve the goals.
|
15 |
"""
|
16 |
+
try:
|
17 |
+
response = strategy_generator(prompt, max_length=300, num_return_sequences=1)
|
18 |
+
return response[0]['generated_text']
|
19 |
+
except Exception as e:
|
20 |
+
return f"Error generating strategy: {e}"
|
21 |
|
22 |
# Function to perform a SWOT analysis
|
23 |
def swot_analysis(strengths, weaknesses, opportunities, threats):
|
24 |
prompt = f"""
|
25 |
+
Perform a comprehensive SWOT analysis for a company based on the following:
|
26 |
+
- Strengths: {strengths}
|
27 |
+
- Weaknesses: {weaknesses}
|
28 |
+
- Opportunities: {opportunities}
|
29 |
+
- Threats: {threats}
|
30 |
+
Provide actionable insights for each category to guide business decision-making.
|
31 |
"""
|
32 |
+
try:
|
33 |
+
response = strategy_generator(prompt, max_length=300, num_return_sequences=1)
|
34 |
+
return response[0]['generated_text']
|
35 |
+
except Exception as e:
|
36 |
+
return f"Error generating SWOT analysis: {e}"
|
37 |
|
38 |
# Gradio interface
|
39 |
with gr.Blocks() as demo:
|