Skip to content

Commit a099a9e

Browse files
Add Supply Chain Consultant and Logistics & Transportation Specialist roles
- Implemented `provide_supply_chain_assistance` and `provide_logistics_assistance` in `google_ai.py`. - Added `/api/v1/supply-chain/assistance` and `/api/v1/logistics/assistance` endpoints in `app.py`. - Updated `frontend/templates/index.html` with new cards and sections. - Updated `frontend/static/js/script.js` with client-side logic. - Updated translation catalogs and compiled them. Co-authored-by: GYFX35 <[email protected]>
1 parent e19a66c commit a099a9e

File tree

9 files changed

+608
-226
lines changed

9 files changed

+608
-226
lines changed

app.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,28 @@ def podcast_assistance_endpoint():
977977
return jsonify({"status": "success", "message": message})
978978

979979

980+
@app.route('/api/v1/supply-chain/assistance', methods=['POST'])
981+
@require_api_key
982+
def supply_chain_assistance_endpoint():
983+
data = request.get_json()
984+
prompt = data.get('prompt')
985+
if not prompt:
986+
return jsonify({"error": _("Prompt is required")}), 400
987+
message = google_ai.provide_supply_chain_assistance(prompt)
988+
return jsonify({"status": "success", "message": message})
989+
990+
991+
@app.route('/api/v1/logistics/assistance', methods=['POST'])
992+
@require_api_key
993+
def logistics_assistance_endpoint():
994+
data = request.get_json()
995+
prompt = data.get('prompt')
996+
if not prompt:
997+
return jsonify({"error": _("Prompt is required")}), 400
998+
message = google_ai.provide_logistics_assistance(prompt)
999+
return jsonify({"status": "success", "message": message})
1000+
1001+
9801002
@app.route('/api/v1/translate', methods=['POST'])
9811003
@require_api_key
9821004
def translate_endpoint():

frontend/static/js/script.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,82 @@ document.addEventListener('DOMContentLoaded', () => {
641641
});
642642
}
643643

644+
// --- Supply Chain Assistance ---
645+
const supplyChainAssistanceBtn = document.getElementById('supply-chain-assistance-btn');
646+
if (supplyChainAssistanceBtn) {
647+
supplyChainAssistanceBtn.addEventListener('click', async () => {
648+
const input = document.getElementById('supply-chain-assistance-input');
649+
const responseContainer = document.getElementById('supply-chain-assistance-response');
650+
const apiKey = getApiKey("Please enter your API key to use the Supply Chain Consultant:");
651+
652+
if (!apiKey) {
653+
responseContainer.textContent = 'API key is required.';
654+
return;
655+
}
656+
657+
try {
658+
const response = await fetch('/api/v1/supply-chain/assistance', {
659+
method: 'POST',
660+
headers: {
661+
'Content-Type': 'application/json',
662+
'X-API-Key': apiKey
663+
},
664+
body: JSON.stringify({
665+
prompt: input.value
666+
})
667+
});
668+
669+
if (!response.ok) {
670+
const error = await response.json();
671+
throw new Error(error.error || 'Failed to get a response from the supply chain consultant');
672+
}
673+
674+
const result = await response.json();
675+
responseContainer.textContent = result.message;
676+
} catch (error) {
677+
responseContainer.textContent = `Error: ${error.message}`;
678+
}
679+
});
680+
}
681+
682+
// --- Logistics Assistance ---
683+
const logisticsAssistanceBtn = document.getElementById('logistics-assistance-btn');
684+
if (logisticsAssistanceBtn) {
685+
logisticsAssistanceBtn.addEventListener('click', async () => {
686+
const input = document.getElementById('logistics-assistance-input');
687+
const responseContainer = document.getElementById('logistics-assistance-response');
688+
const apiKey = getApiKey("Please enter your API key to use the Logistics & Transportation Specialist:");
689+
690+
if (!apiKey) {
691+
responseContainer.textContent = 'API key is required.';
692+
return;
693+
}
694+
695+
try {
696+
const response = await fetch('/api/v1/logistics/assistance', {
697+
method: 'POST',
698+
headers: {
699+
'Content-Type': 'application/json',
700+
'X-API-Key': apiKey
701+
},
702+
body: JSON.stringify({
703+
prompt: input.value
704+
})
705+
});
706+
707+
if (!response.ok) {
708+
const error = await response.json();
709+
throw new Error(error.error || 'Failed to get a response from the logistics specialist');
710+
}
711+
712+
const result = await response.json();
713+
responseContainer.textContent = result.message;
714+
} catch (error) {
715+
responseContainer.textContent = `Error: ${error.message}`;
716+
}
717+
});
718+
}
719+
644720
// --- Global Translator ---
645721
const translatorBtn = document.getElementById('translator-btn');
646722
if (translatorBtn) {

frontend/templates/index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,46 @@ <h3>{{ _('Military Services Assistance') }}</h3>
9696
<h3>{{ _('Podcast & Business Podcast Role') }}</h3>
9797
<p>{{ _('Expert podcast producer, creator, and designer for high-quality podcasts, specializing in business.') }}</p>
9898
</div>
99+
<div class="card">
100+
<h3>{{ _('Supply Chain Consultant') }}</h3>
101+
<p>{{ _('Expert consultant for optimizing supply chain strategy, inventory management, and sourcing.') }}</p>
102+
</div>
103+
<div class="card">
104+
<h3>{{ _('Logistics & Transportation Specialist') }}</h3>
105+
<p>{{ _('Professional specialist for managing goods movement, route optimization, and international logistics.') }}</p>
106+
</div>
107+
</div>
108+
</section>
109+
110+
<!-- Supply Chain Consultant Section -->
111+
<section id="supply-chain-assistance" class="services">
112+
<h2>{{ _('Supply Chain Consultant') }}</h2>
113+
<div class="service-cards">
114+
<div class="card">
115+
<h3>{{ _('Optimize Your Supply Chain') }}</h3>
116+
<p>{{ _('Enter your supply chain strategy, inventory, or sourcing request below.') }}</p>
117+
<textarea id="supply-chain-assistance-input" placeholder="{{ _('Your supply chain request') }}" class="styled-textarea" rows="4"></textarea>
118+
<button id="supply-chain-assistance-btn" class="btn">{{ _('Submit') }}</button>
119+
<div class="response-container" id="supply-chain-assistance-response-container">
120+
<pre id="supply-chain-assistance-response"></pre>
121+
</div>
122+
</div>
123+
</div>
124+
</section>
125+
126+
<!-- Logistics & Transportation Specialist Section -->
127+
<section id="logistics-assistance" class="services">
128+
<h2>{{ _('Logistics & Transportation Specialist') }}</h2>
129+
<div class="service-cards">
130+
<div class="card">
131+
<h3>{{ _('Manage Logistics & Transportation') }}</h3>
132+
<p>{{ _('Enter your logistics, route optimization, or shipping request below.') }}</p>
133+
<textarea id="logistics-assistance-input" placeholder="{{ _('Your logistics request') }}" class="styled-textarea" rows="4"></textarea>
134+
<button id="logistics-assistance-btn" class="btn">{{ _('Submit') }}</button>
135+
<div class="response-container" id="logistics-assistance-response-container">
136+
<pre id="logistics-assistance-response"></pre>
137+
</div>
138+
</div>
99139
</div>
100140
</section>
101141

google_ai.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,70 @@ def provide_podcast_assistance(prompt: str) -> str:
689689
return f"Error: {e}"
690690

691691

692+
def provide_supply_chain_assistance(prompt: str) -> str:
693+
"""
694+
Provides assistance with supply chain optimization and management using Vertex AI.
695+
"""
696+
model = GenerativeModel("gemini-1.5-flash")
697+
698+
generation_prompt = f"""
699+
You are an expert supply chain consultant. Your task is to provide assistance with optimizing and managing supply chain operations.
700+
Your expertise includes:
701+
- Supply Chain Strategy: Developing and implementing strategic supply chain plans.
702+
- Inventory Management: Optimizing inventory levels, reducing carrying costs, and improving order fulfillment.
703+
- Sourcing and Procurement: Identifying and evaluating suppliers, negotiating contracts, and managing supplier relationships.
704+
- Process Improvement: Identifying and implementing process improvements to increase efficiency and reduce costs.
705+
- Technology Integration: Advising on the selection and implementation of supply chain management software and technologies.
706+
707+
User Request:
708+
---
709+
{prompt}
710+
---
711+
712+
Provide a professional, detailed, and actionable response based on the user's request.
713+
"""
714+
715+
try:
716+
response = model.generate_content(generation_prompt)
717+
return response.text.strip()
718+
719+
except Exception as e:
720+
print(f"Error providing supply chain assistance with Vertex AI: {e}")
721+
return f"Error: {e}"
722+
723+
724+
def provide_logistics_assistance(prompt: str) -> str:
725+
"""
726+
Provides assistance with logistics and transportation management using Vertex AI.
727+
"""
728+
model = GenerativeModel("gemini-1.5-flash")
729+
730+
generation_prompt = f"""
731+
You are an expert logistics and transportation specialist. Your task is to provide assistance with managing the movement of goods and materials.
732+
Your expertise includes:
733+
- Transportation Management: Planning and executing transportation operations, selecting carriers, and negotiating rates.
734+
- Route Optimization: Optimizing delivery routes to reduce transportation costs and improve delivery times.
735+
- Warehousing and Distribution: Managing warehouse operations, optimizing storage space, and improving distribution efficiency.
736+
- International Logistics: Navigating the complexities of international shipping, customs regulations, and trade compliance.
737+
- Freight Forwarding: Coordinating the movement of freight across various modes of transportation.
738+
739+
User Request:
740+
---
741+
{prompt}
742+
---
743+
744+
Provide a professional, detailed, and practical response based on the user's request.
745+
"""
746+
747+
try:
748+
response = model.generate_content(generation_prompt)
749+
return response.text.strip()
750+
751+
except Exception as e:
752+
print(f"Error providing logistics assistance with Vertex AI: {e}")
753+
return f"Error: {e}"
754+
755+
692756
def translate_text(text: str, target_language: str) -> str:
693757
"""
694758
Translates text to a target language using Vertex AI.

0 commit comments

Comments
 (0)