Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ User Query → Search Agent → Product List → Info Agent → Full Details
- Comprehensive error messages with request details
- Graceful handling of API failures
- Frontend displays user-friendly error messages
- Frontend requests to local agents use a 5-second timeout so stalled agents return controlled JSON errors instead of hanging the UI

## 🛠️ Technical Details

Expand All @@ -155,4 +156,4 @@ User Query → Search Agent → Product List → Info Agent → Full Details

---

**Ready to explore? Start the agents in separate terminals and open the web interface! 🚀**
**Ready to explore? Start the agents in separate terminals and open the web interface! 🚀**
17 changes: 13 additions & 4 deletions frontend-integration/frontend_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"search": "http://127.0.0.1:8001",
"info": "http://127.0.0.1:8002"
}
AGENT_REQUEST_TIMEOUT = 5

@app.route('/')
def index():
Expand All @@ -24,7 +25,11 @@ def search_products():

# Call search agent with POST request
payload = {"query": query}
response = requests.post(f"{AGENTS['search']}/search", json=payload)
response = requests.post(
f"{AGENTS['search']}/search",
json=payload,
timeout=AGENT_REQUEST_TIMEOUT
)
response.raise_for_status()

# Agent returns JSON directly
Expand Down Expand Up @@ -65,7 +70,11 @@ def get_product_info():

# Call info agent with POST request
payload = {"barcode": barcode}
response = requests.post(f"{AGENTS['info']}/product", json=payload)
response = requests.post(
f"{AGENTS['info']}/product",
json=payload,
timeout=AGENT_REQUEST_TIMEOUT
)
response.raise_for_status()

# Agent returns JSON directly
Expand Down Expand Up @@ -111,7 +120,7 @@ def health_check():

for agent_name, agent_url in AGENTS.items():
try:
response = requests.get(f"{agent_url}/health", timeout=5)
response = requests.get(f"{agent_url}/health", timeout=AGENT_REQUEST_TIMEOUT)
if response.status_code == 200:
# Health endpoint returns JSON directly
health_data = response.json()
Expand All @@ -128,4 +137,4 @@ def health_check():
print("Available endpoints:")
print("- Main interface: http://127.0.0.1:5000")
print("- Health check: http://127.0.0.1:5000/health")
app.run(host='127.0.0.1', port=5000, debug=True)
app.run(host='127.0.0.1', port=5000, debug=True)
Loading