Skip to content

Commit 71a10f7

Browse files
committed
Revert "Fix: Pet clinic chatbot agent fabrication issues (#241)"
This reverts commit 6a28e79.
1 parent 5c905a4 commit 71a10f7

3 files changed

Lines changed: 11 additions & 42 deletions

File tree

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: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,73 +26,45 @@ def get_nutrition_data(pet_type):
2626
return {"facts": data.get('facts', ''), "products": data.get('products', '')}
2727
return {"facts": f"Error: Nutrition service could not find information for pet: {pet_type.lower()}", "products": ""}
2828
except requests.RequestException:
29-
return {"facts": "", "products": "", "error": "Nutrition service temporarily unavailable"}
29+
return {"facts": "Error: Nutrition service down", "products": ""}
3030

3131
@tool
3232
def get_feeding_guidelines(pet_type):
3333
"""Get feeding guidelines based on pet type"""
3434
data = get_nutrition_data(pet_type)
35-
36-
if data["error"]:
37-
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."
38-
39-
if not data["facts"]:
40-
return f"Nutrition information for {pet_type} is not available in our current database. Please speak with our veterinarian for proper dietary guidance."
41-
42-
result = f"Nutrition guidelines for {pet_type}: {data['facts']}"
35+
result = f"Nutrition info for {pet_type}: {data['facts']}"
4336
if data['products']:
44-
result += f" We carry these recommended products at our clinic: {data['products']}"
37+
result += f" Recommended products available at our clinic: {data['products']}"
4538
return result
4639

4740
@tool
4841
def get_dietary_restrictions(pet_type):
4942
"""Get dietary recommendations for specific health conditions by animal type"""
5043
data = get_nutrition_data(pet_type)
51-
52-
if data["error"]:
53-
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."
54-
55-
if not data["facts"]:
56-
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."
57-
58-
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."
5945
if data['products']:
60-
result += f" We carry these recommended products at our clinic: {data['products']}"
46+
result += f" Recommended products available at our clinic: {data['products']}"
6147
return result
6248

6349
@tool
6450
def get_nutritional_supplements(pet_type):
6551
"""Get supplement recommendations by animal type"""
6652
data = get_nutrition_data(pet_type)
67-
68-
if data["error"]:
69-
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."
70-
71-
if not data["facts"]:
72-
return f"Supplement information for {pet_type} is not available in our current database. Please speak with our veterinarian for proper supplement guidance."
73-
74-
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."
7554
if data['products']:
76-
result += f" We carry these recommended products at our clinic: {data['products']}"
55+
result += f" Recommended products available at our clinic: {data['products']}"
7756
return result
7857

7958
@tool
8059
def create_order(product_name, pet_type, quantity=1):
8160
"""Create an order for a recommended product. Requires product_name, pet_type, and optional quantity (default 1)."""
8261
product_lower = product_name.lower()
8362
data = get_nutrition_data(pet_type)
84-
85-
if data["error"]:
86-
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."
87-
88-
if not data['products']:
89-
return f"I don't have product information available for {pet_type}. Please call our clinic at (555) 123-PETS to check product availability."
90-
91-
if product_name.lower() in data['products'].lower():
63+
if data['products'] and product_name.lower() in data['products'].lower():
9264
order_id = f"ORD-{uuid.uuid4().hex[:8].upper()}"
9365
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."
9466

95-
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']}"
9668

9769
def create_nutrition_agent():
9870
model = BedrockModel(

pet_clinic_ai_agents/primary_agent/pet_clinic_agent.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,9 @@ 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:
6764
return str(e)
6865
except Exception as e:

0 commit comments

Comments
 (0)