Skip to content

Commit 967141b

Browse files
authored
Merge pull request #43 from GYFX35/add-business-plan-role-12516223705830048336
Add Business Plan Creator role
2 parents ac71ea7 + 1289a30 commit 967141b

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,17 @@ def document_assistance_endpoint():
933933
return jsonify({"status": "success", "message": message})
934934

935935

936+
@app.route('/api/v1/business/plan', methods=['POST'])
937+
@require_api_key
938+
def business_plan_endpoint():
939+
data = request.get_json()
940+
prompt = data.get('prompt')
941+
if not prompt:
942+
return jsonify({"error": _("Prompt is required")}), 400
943+
message = google_ai.provide_business_plan_assistance(prompt)
944+
return jsonify({"status": "success", "message": message})
945+
946+
936947
@app.route('/api/register', methods=['POST'])
937948
def register():
938949
data = request.get_json()

frontend/static/js/script.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,42 @@ document.addEventListener('DOMContentLoaded', () => {
476476
}
477477
});
478478
}
479+
480+
// --- Business Plan Creator ---
481+
const businessPlanBtn = document.getElementById('business-plan-btn');
482+
if (businessPlanBtn) {
483+
businessPlanBtn.addEventListener('click', async () => {
484+
const input = document.getElementById('business-plan-input');
485+
const responseContainer = document.getElementById('business-plan-response');
486+
const apiKey = prompt("Please enter your API key to use the Business Plan Creator:");
487+
488+
if (!apiKey) {
489+
responseContainer.textContent = 'API key is required.';
490+
return;
491+
}
492+
493+
try {
494+
const response = await fetch('/api/v1/business/plan', {
495+
method: 'POST',
496+
headers: {
497+
'Content-Type': 'application/json',
498+
'X-API-Key': apiKey
499+
},
500+
body: JSON.stringify({
501+
prompt: input.value
502+
})
503+
});
504+
505+
if (!response.ok) {
506+
const error = await response.json();
507+
throw new Error(error.error || 'Failed to get a response from the business plan creator');
508+
}
509+
510+
const result = await response.json();
511+
responseContainer.textContent = result.message;
512+
} catch (error) {
513+
responseContainer.textContent = `Error: ${error.message}`;
514+
}
515+
});
516+
}
479517
});

frontend/templates/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ <h3>{{ _('Music Instrumentalist Player') }}</h3>
7777
</div>
7878
</section>
7979

80+
<!-- Business Plan Creator Section -->
81+
<section id="business-plan-creator" class="services">
82+
<h2>{{ _('Business Plan Creator') }}</h2>
83+
<div class="service-cards">
84+
<div class="card">
85+
<h3>{{ _('Create, perfect, and develop your business plan') }}</h3>
86+
<p>{{ _('Enter your request for business plan assistance below.') }}</p>
87+
<textarea id="business-plan-input" placeholder="{{ _('Your business plan request') }}" class="styled-textarea" rows="4"></textarea>
88+
<button id="business-plan-btn" class="btn">{{ _('Submit') }}</button>
89+
<div class="response-container" id="business-plan-response-container">
90+
<pre id="business-plan-response"></pre>
91+
</div>
92+
</div>
93+
</div>
94+
</section>
95+
8096
<!-- Document Specialist Section -->
8197
<section id="document-specialist" class="services">
8298
<h2>{{ _('Document Specialist') }}</h2>

google_ai.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,33 @@ def provide_document_assistance(prompt: str) -> str:
561561
except Exception as e:
562562
print(f"Error providing document assistance with Vertex AI: {e}")
563563
return f"Error: {e}"
564+
565+
566+
def provide_business_plan_assistance(prompt: str) -> str:
567+
"""
568+
Provides assistance with creating, perfecting, and developing business plans using Vertex AI.
569+
"""
570+
model = GenerativeModel("gemini-1.5-flash")
571+
572+
generation_prompt = f"""
573+
You are an expert business consultant and strategist. Your task is to help the user create, perfect, and develop a comprehensive business plan.
574+
Your expertise includes:
575+
- Business Plan Creation: Drafting executive summaries, market analyses, operational plans, and financial projections.
576+
- Perfection: Reviewing existing business plans for clarity, consistency, and persuasiveness.
577+
- Development: Expanding on business ideas, identifying potential risks, and suggesting growth strategies.
578+
579+
User Request:
580+
---
581+
{prompt}
582+
---
583+
584+
Provide a professional, detailed, and actionable response based on the user's request.
585+
"""
586+
587+
try:
588+
response = model.generate_content(generation_prompt)
589+
return response.text.strip()
590+
591+
except Exception as e:
592+
print(f"Error providing business plan assistance with Vertex AI: {e}")
593+
return f"Error: {e}"

0 commit comments

Comments
 (0)