Skip to content

Commit 5d4d894

Browse files
authored
Merge pull request #45 from GYFX35/add-military-assistance-role-13962245380982954364
Add military services assistance role
2 parents 047e9c7 + e4b3ba2 commit 5d4d894

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed

app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,17 @@ def investigation_security_endpoint():
955955
return jsonify({"status": "success", "message": message})
956956

957957

958+
@app.route('/api/v1/military/assistance', methods=['POST'])
959+
@require_api_key
960+
def military_assistance_endpoint():
961+
data = request.get_json()
962+
prompt = data.get('prompt')
963+
if not prompt:
964+
return jsonify({"error": _("Prompt is required")}), 400
965+
message = google_ai.provide_military_assistance(prompt)
966+
return jsonify({"status": "success", "message": message})
967+
968+
958969
@app.route('/api/register', methods=['POST'])
959970
def register():
960971
data = request.get_json()

frontend/static/js/script.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,42 @@ document.addEventListener('DOMContentLoaded', () => {
552552
}
553553
});
554554
}
555+
556+
// --- Military Assistance ---
557+
const militaryAssistanceBtn = document.getElementById('military-assistance-btn');
558+
if (militaryAssistanceBtn) {
559+
militaryAssistanceBtn.addEventListener('click', async () => {
560+
const input = document.getElementById('military-assistance-input');
561+
const responseContainer = document.getElementById('military-assistance-response');
562+
const apiKey = prompt("Please enter your API key to use the Military Services Assistance:");
563+
564+
if (!apiKey) {
565+
responseContainer.textContent = 'API key is required.';
566+
return;
567+
}
568+
569+
try {
570+
const response = await fetch('/api/v1/military/assistance', {
571+
method: 'POST',
572+
headers: {
573+
'Content-Type': 'application/json',
574+
'X-API-Key': apiKey
575+
},
576+
body: JSON.stringify({
577+
prompt: input.value
578+
})
579+
});
580+
581+
if (!response.ok) {
582+
const error = await response.json();
583+
throw new Error(error.error || 'Failed to get a response from the military assistance role');
584+
}
585+
586+
const result = await response.json();
587+
responseContainer.textContent = result.message;
588+
} catch (error) {
589+
responseContainer.textContent = `Error: ${error.message}`;
590+
}
591+
});
592+
}
555593
});

frontend/templates/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<div class="logo">UsingAI</div>
1616
<ul>
1717
<li><a href="#services">Services</a></li>
18+
<li><a href="#military-assistance">Military</a></li>
1819
<li><a href="#purchase">Purchase</a></li>
1920
<li><a href="#portfolio">Portfolio</a></li>
2021
<li><a href="#contact">Contact</a></li>
@@ -78,6 +79,26 @@ <h3>{{ _('Music Instrumentalist Player') }}</h3>
7879
<h3>{{ _('Investigation Role') }}</h3>
7980
<p>{{ _('Expert cybersecurity and global security investigator for FBI, CIA, and IA, focusing on data protection.') }}</p>
8081
</div>
82+
<div class="card">
83+
<h3>{{ _('Military Services Assistance') }}</h3>
84+
<p>{{ _('Strategic assistance for armies and security services, including tactical planning and risk assessment.') }}</p>
85+
</div>
86+
</div>
87+
</section>
88+
89+
<!-- Military Services Assistance Section -->
90+
<section id="military-assistance" class="services">
91+
<h2>{{ _('Military Services Assistance') }}</h2>
92+
<div class="service-cards">
93+
<div class="card">
94+
<h3>{{ _('Tactical Planning & Security Strategy') }}</h3>
95+
<p>{{ _('Enter your request for military or security services assistance below.') }}</p>
96+
<textarea id="military-assistance-input" placeholder="{{ _('Your military assistance request') }}" class="styled-textarea" rows="4"></textarea>
97+
<button id="military-assistance-btn" class="btn">{{ _('Submit') }}</button>
98+
<div class="response-container" id="military-assistance-response-container">
99+
<pre id="military-assistance-response"></pre>
100+
</div>
101+
</div>
81102
</div>
82103
</section>
83104

google_ai.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,35 @@ def provide_investigation_assistance(prompt: str) -> str:
623623
except Exception as e:
624624
print(f"Error providing investigation assistance with Vertex AI: {e}")
625625
return f"Error: {e}"
626+
627+
628+
def provide_military_assistance(prompt: str) -> str:
629+
"""
630+
Provides military and security services assistance using Vertex AI.
631+
"""
632+
model = GenerativeModel("gemini-1.5-flash")
633+
634+
generation_prompt = f"""
635+
You are an expert military and security strategist. Your task is to provide assistance and guidance for armies and security services.
636+
Your expertise includes:
637+
- Tactical Planning: Advising on mission strategies, field operations, and resource deployment.
638+
- Security Protocols: Developing and refining security measures for personnel, infrastructure, and information.
639+
- Logistics and Supply Chain: Optimizing the movement and maintenance of military equipment and supplies.
640+
- Risk Assessment: Identifying potential threats and developing mitigation strategies for various scenarios.
641+
- Crisis Management: Providing guidance on handling emergency situations and maintaining order.
642+
643+
User Request:
644+
---
645+
{prompt}
646+
---
647+
648+
Provide a professional, detailed, and strategic response based on the user's request.
649+
"""
650+
651+
try:
652+
response = model.generate_content(generation_prompt)
653+
return response.text.strip()
654+
655+
except Exception as e:
656+
print(f"Error providing military assistance with Vertex AI: {e}")
657+
return f"Error: {e}"

0 commit comments

Comments
 (0)