mgbam commited on
Commit
51b14ac
·
verified ·
1 Parent(s): dd6b41c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -4,7 +4,7 @@ from transformers import pipeline
4
  # Load a more capable open-source model
5
  strategy_generator = pipeline("text2text-generation", model="google/flan-t5-large")
6
 
7
- # Function to clean up repetitive sentences in generated text
8
  def clean_output(text):
9
  sentences = text.split(". ")
10
  seen = set()
@@ -18,13 +18,20 @@ def clean_output(text):
18
  # Function to generate a business strategy
19
  def generate_strategy(industry, challenge, goals):
20
  prompt = f"""
21
- You are a business consultant helping a company in the {industry} industry.
22
  The company faces the following challenge: {challenge}.
23
  The company aims to achieve the following goal: {goals}.
24
- Provide a detailed and actionable business strategy with specific steps, measurable outcomes, and innovative ideas.
 
 
 
 
 
 
 
25
  """
26
  try:
27
- response = strategy_generator(prompt, max_length=300, num_return_sequences=1, temperature=0.7)
28
  cleaned_response = clean_output(response[0]['generated_text'])
29
  return cleaned_response
30
  except Exception as e:
@@ -33,15 +40,15 @@ def generate_strategy(industry, challenge, goals):
33
  # Function to perform a SWOT analysis
34
  def swot_analysis(strengths, weaknesses, opportunities, threats):
35
  prompt = f"""
36
- You are a business consultant performing a SWOT analysis for a company.
37
  - Strengths: {strengths}
38
  - Weaknesses: {weaknesses}
39
  - Opportunities: {opportunities}
40
  - Threats: {threats}
41
- Provide actionable insights for each category and suggestions on how to maximize strengths and opportunities while addressing weaknesses and threats.
42
  """
43
  try:
44
- response = strategy_generator(prompt, max_length=300, num_return_sequences=1, temperature=0.7)
45
  cleaned_response = clean_output(response[0]['generated_text'])
46
  return cleaned_response
47
  except Exception as e:
 
4
  # Load a more capable open-source model
5
  strategy_generator = pipeline("text2text-generation", model="google/flan-t5-large")
6
 
7
+ # Function to clean up repetitive or irrelevant sentences in generated text
8
  def clean_output(text):
9
  sentences = text.split(". ")
10
  seen = set()
 
18
  # Function to generate a business strategy
19
  def generate_strategy(industry, challenge, goals):
20
  prompt = f"""
21
+ You are a professional business consultant specializing in the {industry} industry.
22
  The company faces the following challenge: {challenge}.
23
  The company aims to achieve the following goal: {goals}.
24
+ Provide a detailed business strategy including:
25
+ - 3-5 actionable steps
26
+ - Measurable short-term outcomes (6 months to 1 year)
27
+ - Innovative ideas tailored to the industry
28
+ Example format:
29
+ 1. Step 1: Description
30
+ 2. Step 2: Description
31
+ 3. Step 3: Description
32
  """
33
  try:
34
+ response = strategy_generator(prompt, max_length=300, num_return_sequences=1, temperature=0.7, top_p=0.9)
35
  cleaned_response = clean_output(response[0]['generated_text'])
36
  return cleaned_response
37
  except Exception as e:
 
40
  # Function to perform a SWOT analysis
41
  def swot_analysis(strengths, weaknesses, opportunities, threats):
42
  prompt = f"""
43
+ You are a professional business consultant performing a SWOT analysis for a company.
44
  - Strengths: {strengths}
45
  - Weaknesses: {weaknesses}
46
  - Opportunities: {opportunities}
47
  - Threats: {threats}
48
+ Provide actionable insights for each category, including specific recommendations on how to leverage strengths and opportunities while addressing weaknesses and threats.
49
  """
50
  try:
51
+ response = strategy_generator(prompt, max_length=300, num_return_sequences=1, temperature=0.7, top_p=0.9)
52
  cleaned_response = clean_output(response[0]['generated_text'])
53
  return cleaned_response
54
  except Exception as e: