Skip to content

Commit 8872fea

Browse files
liustveADOT Patch workflow
andauthored
Revert commit 3c78ba8 (#221)
*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 3c78ba8 commit 8872fea

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

pet_clinic_ai_agents/nutrition_agent/nutrition_agent.py

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,22 @@
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": "Error: Nutrition service not found", "products": "", "has_data": False}
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', ''), "has_data": True}
27-
elif response.status_code == 404:
28-
return {"facts": f"We don't currently have nutrition information for {pet_type} in our database", "products": "", "has_data": False}
29-
return {"facts": f"Error: Nutrition service could not find information for pet: {pet_type.lower()}", "products": "", "has_data": False}
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": ""}
3028
except requests.RequestException:
31-
return {"facts": "Error: Nutrition service down", "products": "", "has_data": False}
29+
return {"facts": "Error: Nutrition service down", "products": ""}
3230

3331
@tool
3432
def get_feeding_guidelines(pet_type):
3533
"""Get feeding guidelines based on pet type"""
3634
data = get_nutrition_data(pet_type)
37-
if not data['has_data']:
38-
return data['facts']
39-
4035
result = f"Nutrition info for {pet_type}: {data['facts']}"
4136
if data['products']:
4237
result += f" Recommended products available at our clinic: {data['products']}"
@@ -46,9 +41,6 @@ def get_feeding_guidelines(pet_type):
4641
def get_dietary_restrictions(pet_type):
4742
"""Get dietary recommendations for specific health conditions by animal type"""
4843
data = get_nutrition_data(pet_type)
49-
if not data['has_data']:
50-
return data['facts']
51-
5244
result = f"Dietary info for {pet_type}: {data['facts']}. Consult veterinarian for condition-specific advice."
5345
if data['products']:
5446
result += f" Recommended products available at our clinic: {data['products']}"
@@ -58,9 +50,6 @@ def get_dietary_restrictions(pet_type):
5850
def get_nutritional_supplements(pet_type):
5951
"""Get supplement recommendations by animal type"""
6052
data = get_nutrition_data(pet_type)
61-
if not data['has_data']:
62-
return data['facts']
63-
6453
result = f"Supplement info for {pet_type}: {data['facts']}. Consult veterinarian for supplements."
6554
if data['products']:
6655
result += f" Recommended products available at our clinic: {data['products']}"
@@ -70,9 +59,6 @@ def get_nutritional_supplements(pet_type):
7059
def create_order(product_name, pet_type, quantity=1):
7160
"""Create an order for a recommended product. Requires pet_type and quantity."""
7261
data = get_nutrition_data(pet_type)
73-
if not data['has_data']:
74-
return f"Sorry, we don't currently have nutrition information for {pet_type} in our database, so we cannot process orders for this pet type."
75-
7662
if data['products'] and product_name.lower() in data['products'].lower():
7763
order_id = f"ORD-{uuid.uuid4().hex[:8].upper()}"
7864
return f"Order {order_id} created for {quantity}x {product_name}. Total: ${quantity * 29.99:.2f}. Expected delivery: 3-5 business days."
@@ -89,18 +75,14 @@ def create_nutrition_agent():
8975
"You are a specialized pet nutrition expert at our veterinary clinic, providing accurate, evidence-based dietary guidance for pets. "
9076
"Never mention using any API, tools, or external services - present all advice as your own expert knowledge.\n\n"
9177
"When providing nutrition guidance:\n"
92-
"- ONLY provide recommendations when you have specific nutrition information available for the requested pet type\n"
93-
"- If you don't have nutrition information for a specific pet type, clearly state that we don't currently have that information in our database\n"
94-
"- NEVER fabricate or hallucinate product names, nutrition facts, or recommendations when data is not available\n"
95-
"- When you DO have nutrition information available, use it as the foundation for your recommendations\n"
96-
"- Only recommend SPECIFIC PRODUCT NAMES that are actually provided to you in the nutrition data\n"
97-
"- Mention our branded products by name (like PurrfectChoice, BarkBite, FeatherFeast, etc.) ONLY when they are available in our database\n"
98-
"- Emphasize that we carry high-quality, veterinarian-recommended food brands at our clinic ONLY for pets we have data for\n"
99-
"- Give actionable dietary recommendations including feeding guidelines, restrictions, and supplements ONLY when data is available\n"
100-
"- Expand on basic nutrition facts with comprehensive guidance for age, weight, and health conditions ONLY when you have the underlying data\n"
101-
"- Always mention that pet owners can purchase the recommended food items directly from our clinic for convenience and quality assurance ONLY when products are available\n"
102-
"- If asked to order or purchase a product for a pet type we don't have data for, politely decline and explain we don't have information for that pet type\n"
103-
"- For unsupported pet types, suggest contacting our clinic directly for personalized consultation"
78+
"- Use the specific nutrition information available to you as the foundation for your recommendations\n"
79+
"- Always recommend the SPECIFIC PRODUCT NAMES provided to you that pet owners should buy FROM OUR PET CLINIC\n"
80+
"- Mention our branded products by name (like PurrfectChoice, BarkBite, FeatherFeast, etc.) when recommending food\n"
81+
"- Emphasize that we carry high-quality, veterinarian-recommended food brands at our clinic\n"
82+
"- Give actionable dietary recommendations including feeding guidelines, restrictions, and supplements\n"
83+
"- Expand on basic nutrition facts with comprehensive guidance for age, weight, and health conditions\n"
84+
"- Always mention that pet owners can purchase the recommended food items directly from our clinic for convenience and quality assurance\n"
85+
"- If asked to order or purchase a product, use the create_order tool to place the order"
10486
)
10587

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

0 commit comments

Comments
 (0)