Skip to content

Commit 03c9155

Browse files
liustveADOT Patch workflow
andauthored
Revert GitHub Actions commit 6a28e79 (#243)
*Issue #, if available:* *Description of changes:* By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --------- Co-authored-by: ADOT Patch workflow <[email protected]>
1 parent 6a28e79 commit 03c9155

File tree

3 files changed

+42
-82
lines changed

3 files changed

+42
-82
lines changed

pet-nutrition-service/db-seed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ module.exports = function(){
2121
])
2222
.then(() => logger.info('collection populated'))
2323
.catch(err => logger.error('error populating collection:', err));
24-
};
24+
};

pet_clinic_ai_agents/nutrition_agent/nutrition_agent.py

Lines changed: 22 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -16,85 +16,55 @@
1616
def get_nutrition_data(pet_type):
1717
"""Helper function to get nutrition data from the API"""
1818
if not NUTRITION_SERVICE_URL:
19-
return {"facts": "", "products": "", "error": "Nutrition service not configured"}
19+
return {"facts": "Error: Nutrition service not found", "products": ""}
2020

2121
try:
2222
response = requests.get(f"{NUTRITION_SERVICE_URL}/{pet_type.lower()}", timeout=5)
2323

2424
if response.status_code == 200:
2525
data = response.json()
26-
return {"facts": data.get('facts', ''), "products": data.get('products', ''), "error": None}
27-
elif response.status_code == 404:
28-
return {"facts": "", "products": "", "error": f"No nutrition data available for {pet_type}"}
29-
else:
30-
return {"facts": "", "products": "", "error": "Nutrition service temporarily unavailable"}
26+
return {"facts": data.get('facts', ''), "products": data.get('products', '')}
27+
return {"facts": f"Error: Nutrition service could not find information for pet: {pet_type.lower()}", "products": ""}
3128
except requests.RequestException:
32-
return {"facts": "", "products": "", "error": "Nutrition service temporarily unavailable"}
29+
return {"facts": "Error: Nutrition service down", "products": ""}
3330

3431
@tool
3532
def get_feeding_guidelines(pet_type):
3633
"""Get feeding guidelines based on pet type"""
3734
data = get_nutrition_data(pet_type)
38-
39-
if data["error"]:
40-
return f"I don't have specific nutrition information available for {pet_type} at the moment. Please consult with our veterinarian at (555) 123-PETS for personalized dietary recommendations."
41-
42-
if not data["facts"]:
43-
return f"Nutrition information for {pet_type} is not available in our current database. Please speak with our veterinarian for proper dietary guidance."
44-
45-
result = f"Nutrition guidelines for {pet_type}: {data['facts']}"
35+
result = f"Nutrition info for {pet_type}: {data['facts']}"
4636
if data['products']:
47-
result += f" We carry these recommended products at our clinic: {data['products']}"
37+
result += f" Recommended products available at our clinic: {data['products']}"
4838
return result
4939

5040
@tool
5141
def get_dietary_restrictions(pet_type):
5242
"""Get dietary recommendations for specific health conditions by animal type"""
5343
data = get_nutrition_data(pet_type)
54-
55-
if data["error"]:
56-
return f"I don't have specific dietary restriction information for {pet_type} at the moment. Please consult with our veterinarian at (555) 123-PETS for condition-specific dietary advice."
57-
58-
if not data["facts"]:
59-
return f"Dietary restriction information for {pet_type} is not available in our current database. Please speak with our veterinarian for proper guidance on health conditions."
60-
61-
result = f"Dietary considerations for {pet_type}: {data['facts']}. Always consult our veterinarian for condition-specific advice."
44+
result = f"Dietary info for {pet_type}: {data['facts']}. Consult veterinarian for condition-specific advice."
6245
if data['products']:
63-
result += f" We carry these recommended products at our clinic: {data['products']}"
46+
result += f" Recommended products available at our clinic: {data['products']}"
6447
return result
6548

6649
@tool
6750
def get_nutritional_supplements(pet_type):
6851
"""Get supplement recommendations by animal type"""
6952
data = get_nutrition_data(pet_type)
70-
71-
if data["error"]:
72-
return f"I don't have specific supplement information for {pet_type} at the moment. Please consult with our veterinarian at (555) 123-PETS for supplement recommendations."
73-
74-
if not data["facts"]:
75-
return f"Supplement information for {pet_type} is not available in our current database. Please speak with our veterinarian for proper supplement guidance."
76-
77-
result = f"Supplement guidance for {pet_type}: Based on {data['facts']}, consult our veterinarian for specific supplement needs."
53+
result = f"Supplement info for {pet_type}: {data['facts']}. Consult veterinarian for supplements."
7854
if data['products']:
79-
result += f" We carry these recommended products at our clinic: {data['products']}"
55+
result += f" Recommended products available at our clinic: {data['products']}"
8056
return result
8157

8258
@tool
8359
def create_order(product_name, pet_type, quantity=1):
8460
"""Create an order for a recommended product. Requires product_name, pet_type, and optional quantity (default 1)."""
61+
product_lower = product_name.lower()
8562
data = get_nutrition_data(pet_type)
86-
87-
if data["error"]:
88-
return f"I cannot process orders for {pet_type} products at the moment. Please call our clinic at (555) 123-PETS to place your order."
89-
90-
if not data['products']:
91-
return f"I don't have product information available for {pet_type}. Please call our clinic at (555) 123-PETS to check product availability."
92-
93-
if product_name.lower() in data['products'].lower():
63+
if data['products'] and product_name.lower() in data['products'].lower():
9464
order_id = f"ORD-{uuid.uuid4().hex[:8].upper()}"
9565
return f"Order {order_id} created for {quantity}x {product_name}. Total: ${quantity * 29.99:.2f}. Expected delivery: 3-5 business days. You can pick it up at our clinic or we'll ship it to you."
9666

97-
return f"Sorry, {product_name} is not available in our current inventory for {pet_type}. Available products: {data['products']}. Please call (555) 123-PETS for more options."
67+
return f"Sorry, {product_name} is not available in our inventory for {pet_type}. Available products: {data['products']}"
9868

9969
def create_nutrition_agent():
10070
model = BedrockModel(
@@ -105,21 +75,16 @@ def create_nutrition_agent():
10575

10676
system_prompt = (
10777
"You are a specialized pet nutrition expert at our veterinary clinic, providing accurate, evidence-based dietary guidance for pets. "
108-
"CRITICAL: You must NEVER fabricate, invent, or make up product names, nutrition facts, or recommendations that are not provided to you through your tools.\n\n"
109-
"STRICT GUIDELINES:\n"
110-
"- ONLY recommend products that are explicitly provided to you through the nutrition data tools\n"
111-
"- NEVER invent product names like 'AvianVital', 'HoppyHerb', or any other products not in your database\n"
112-
"- If nutrition information is not available, clearly state 'information not available' and direct customers to speak with a veterinarian\n"
113-
"- Always validate that products exist in your database before making recommendations\n"
114-
"- When tools return errors or no data, acknowledge the limitation and provide fallback guidance\n\n"
78+
"Never mention using any API, tools, or external services - present all advice as your own expert knowledge.\n\n"
11579
"When providing nutrition guidance:\n"
116-
"- Use ONLY the specific nutrition information provided by your tools\n"
117-
"- Recommend ONLY the exact product names returned by your nutrition data tools\n"
118-
"- If no products are available, direct customers to call the clinic at (555) 123-PETS\n"
119-
"- Always mention consulting with our veterinarian for personalized advice\n"
120-
"- Never mention using tools, APIs, or external services - present advice as your expertise\n"
121-
"- If information is unavailable, be honest and direct customers to veterinary consultation\n"
122-
"- Emphasize that we carry veterinarian-recommended products at our clinic when available"
80+
"- Use the specific nutrition information available to you as the foundation for your recommendations\n"
81+
"- Always recommend the SPECIFIC PRODUCT NAMES provided to you that pet owners should buy FROM OUR PET CLINIC\n"
82+
"- Mention our branded products by name (like PurrfectChoice, BarkBite, FeatherFeast, etc.) when recommending food\n"
83+
"- Emphasize that we carry high-quality, veterinarian-recommended food brands at our clinic\n"
84+
"- Give actionable dietary recommendations including feeding guidelines, restrictions, and supplements\n"
85+
"- Expand on basic nutrition facts with comprehensive guidance for age, weight, and health conditions\n"
86+
"- Always mention that pet owners can purchase the recommended food items directly from our clinic for convenience and quality assurance\n"
87+
"- If asked to order or purchase a product, use the create_order tool to place the order"
12388
)
12489

12590
return Agent(model=model, tools=tools, system_prompt=system_prompt)

pet_clinic_ai_agents/primary_agent/pet_clinic_agent.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def consult_nutrition_specialist(query):
4242

4343
agent_arn = os.environ.get('NUTRITION_AGENT_ARN')
4444
if not agent_arn:
45-
return "Our nutrition specialist is currently unavailable. Please call (555) 123-PETS ext. 201 to speak with Dr. Smith directly."
45+
return "Nutrition specialist configuration error. Please call (555) 123-PETS ext. 201."
4646

4747
try:
4848
region = os.environ.get('AWS_REGION') or os.environ.get('AWS_DEFAULT_REGION', 'us-east-1')
@@ -57,16 +57,13 @@ def consult_nutrition_specialist(query):
5757
# Read the streaming response
5858
if 'response' in response:
5959
body = response['response'].read().decode('utf-8')
60-
# Check if the response indicates an error or unavailability
61-
if "not available" in body.lower() or "error" in body.lower() or "temporarily unavailable" in body.lower():
62-
return "Our nutrition specialist doesn't have that information available right now. Please call (555) 123-PETS ext. 201 to speak with Dr. Smith for personalized advice."
6360
return body
6461
else:
65-
return "Our nutrition specialist is experiencing high demand. Please call (555) 123-PETS ext. 201 to speak with Dr. Smith directly."
62+
return "Our nutrition specialist is experiencing high demand. Please try again in a few moments or call (555) 123-PETS ext. 201."
6663
except ClientError as e:
67-
return "Our nutrition specialist is currently unavailable. Please call (555) 123-PETS ext. 201 to speak with Dr. Smith directly."
64+
return str(e)
6865
except Exception as e:
69-
return "Our nutrition specialist is currently unavailable. Please call (555) 123-PETS ext. 201 to speak with Dr. Smith directly."
66+
return "Unable to reach our nutrition specialist. Please call (555) 123-PETS ext. 201."
7067

7168
agent = None
7269
agent_app = BedrockAgentCoreApp()
@@ -78,23 +75,21 @@ def consult_nutrition_specialist(query):
7875
"- Directing clients to appropriate specialists\n"
7976
"- Scheduling guidance\n"
8077
"- Basic medical guidance and when to seek veterinary care\n\n"
81-
"CRITICAL GUIDELINES - NEVER FABRICATE INFORMATION:\n"
82-
"- NEVER invent, make up, or fabricate product names, services, or medical advice\n"
83-
"- ONLY provide information that is explicitly available through your tools\n"
84-
"- If information is not available, clearly state so and direct customers to call the clinic\n"
85-
"- NEVER recommend products that are not confirmed to be available\n\n"
86-
"RESPONSE GUIDELINES:\n"
87-
"- Keep ALL responses BRIEF and CONCISE - aim for 2-3 sentences maximum\n"
88-
"- ONLY use the consult_nutrition_specialist tool for EXPLICIT nutrition-related questions\n"
89-
"- For product orders: Always ask for pet type if not mentioned BEFORE consulting nutrition specialist\n"
90-
"- When delegating to nutrition specialist, include both product name AND pet type in query\n"
91-
"- DO NOT use nutrition agent for general clinic questions, appointments, hours, or emergencies\n"
92-
"- NEVER expose technical details, agent ARNs, tools, or APIs to users\n"
93-
"- When consulting nutrition specialist, simply say 'Let me consult our nutrition specialist'\n"
94-
"- If specialist is unavailable or returns errors, direct customers to call Dr. Smith at ext. 201\n"
95-
"- For medical concerns, provide general guidance and recommend veterinary appointment\n"
96-
"- For emergencies, immediately provide emergency contact information\n"
97-
"- Always recommend purchasing verified products from our pet clinic only"
78+
"IMPORTANT GUIDELINES:\n"
79+
"- Keep ALL responses BRIEF and CONCISE - aim for 2-3 sentences maximum unless specifically asked for details\n"
80+
"- When recommending products, clearly list them using bullet points with product names\n"
81+
"- ONLY use the consult_nutrition_specialist tool for EXPLICIT nutrition-related questions (diet, feeding, supplements, food recommendations, what to feed, can pets eat X, nutrition advice)\n"
82+
"- For product orders: If pet type is NOT mentioned, ask the customer what type of pet they have (dog, cat, bird, etc.) BEFORE consulting the nutrition specialist\n"
83+
"- When delegating orders to nutrition specialist, include both the product name AND pet type in your query (e.g., 'Place an order for BarkBite Complete Nutrition for a dog')\n"
84+
"- DO NOT use the nutrition agent for general clinic questions, appointments, hours, emergencies, or non-nutrition medical issues\n"
85+
"- NEVER expose or mention agent ARNs, tools, APIs, or any technical details in your responses to users\n"
86+
"- NEVER say things like 'I'm using a tool' or 'Let me look that up' - just respond naturally\n"
87+
"- When consulting the nutrition specialist, ONLY say 'Let me consult our nutrition specialist' - nothing else about the process\n"
88+
"- If the specialist returns an error or indicates unavailability, inform the customer that our specialist is currently unavailable\n"
89+
"- For nutrition questions, provide 2-3 product recommendations in a brief bulleted list, then suggest monitoring and consultation if needed\n"
90+
"- Always recommend purchasing products from our pet clinic\n"
91+
"- For medical concerns, provide general guidance and recommend scheduling a veterinary appointment\n"
92+
"- For emergencies, immediately provide emergency contact information"
9893
)
9994

10095
def create_clinic_agent():

0 commit comments

Comments
 (0)