From ae329c98b1a50dc12e0d7681eb3127e5ccc97877 Mon Sep 17 00:00:00 2001
From: salmanap
Date: Wed, 9 Oct 2024 18:25:41 +0000
Subject: [PATCH] deploy: 5c4a6bc8ff27f59c30a3c3173f600f91fded89e5
---
build_with_arch/agent.html | 55 ++++++++--------
build_with_arch/rag.html | 127 +++++++++++++++++++------------------
2 files changed, 92 insertions(+), 90 deletions(-)
diff --git a/build_with_arch/agent.html b/build_with_arch/agent.html
index 21dd9d25..9b01b896 100755
--- a/build_with_arch/agent.html
+++ b/build_with_arch/agent.html
@@ -256,34 +256,35 @@ is how you would go about enabling this scenario with Arch:
13 # Validate 'device_ids' parameter
14 device_ids = data.get("device_ids")
15 if not device_ids or not isinstance(device_ids, list):
-16 return jsonify(
-17 {"error": "'device_ids' parameter is required and must be a list"}
-18 ), 400
-19
-20 # Validate 'time_range' parameter (optional, defaults to 7)
-21 time_range = data.get("time_range", 7)
-22 if not isinstance(time_range, int):
-23 return jsonify({"error": "'time_range' must be an integer"}), 400
-24
-25 # Simulate retrieving statistics for the given device IDs and time range
-26 # In a real application, you would query your database or external service here
-27 statistics = []
-28 for device_id in device_ids:
-29 # Placeholder for actual data retrieval
-30 stats = {
-31 "device_id": device_id,
-32 "time_range": f"Last {time_range} days",
-33 "data": f"Statistics data for device {device_id} over the last {time_range} days.",
-34 }
-35 statistics.append(stats)
-36
-37 response = {"statistics": statistics}
-38
-39 return jsonify(response), 200
-40
+16 return (
+17 jsonify({"error": "'device_ids' parameter is required and must be a list"}),
+18 400,
+19 )
+20
+21 # Validate 'time_range' parameter (optional, defaults to 7)
+22 time_range = data.get("time_range", 7)
+23 if not isinstance(time_range, int):
+24 return jsonify({"error": "'time_range' must be an integer"}), 400
+25
+26 # Simulate retrieving statistics for the given device IDs and time range
+27 # In a real application, you would query your database or external service here
+28 statistics = []
+29 for device_id in device_ids:
+30 # Placeholder for actual data retrieval
+31 stats = {
+32 "device_id": device_id,
+33 "time_range": f"Last {time_range} days",
+34 "data": f"Statistics data for device {device_id} over the last {time_range} days.",
+35 }
+36 statistics.append(stats)
+37
+38 response = {"statistics": statistics}
+39
+40 return jsonify(response), 200
41
-42if __name__ == "__main__":
-43 app.run(debug=True)
+42
+43if __name__ == "__main__":
+44 app.run(debug=True)
diff --git a/build_with_arch/rag.html b/build_with_arch/rag.html
index d15cf1a7..85c5d475 100755
--- a/build_with_arch/rag.html
+++ b/build_with_arch/rag.html
@@ -205,34 +205,35 @@ streamline data retrieval and processing to build more efficient and precise RAG
13 # Validate 'device_ids' parameter
14 device_ids = data.get("device_ids")
15 if not device_ids or not isinstance(device_ids, list):
-16 return jsonify(
-17 {"error": "'device_ids' parameter is required and must be a list"}
-18 ), 400
-19
-20 # Validate 'time_range' parameter (optional, defaults to 7)
-21 time_range = data.get("time_range", 7)
-22 if not isinstance(time_range, int):
-23 return jsonify({"error": "'time_range' must be an integer"}), 400
-24
-25 # Simulate retrieving statistics for the given device IDs and time range
-26 # In a real application, you would query your database or external service here
-27 statistics = []
-28 for device_id in device_ids:
-29 # Placeholder for actual data retrieval
-30 stats = {
-31 "device_id": device_id,
-32 "time_range": f"Last {time_range} days",
-33 "data": f"Statistics data for device {device_id} over the last {time_range} days.",
-34 }
-35 statistics.append(stats)
-36
-37 response = {"statistics": statistics}
-38
-39 return jsonify(response), 200
-40
+16 return (
+17 jsonify({"error": "'device_ids' parameter is required and must be a list"}),
+18 400,
+19 )
+20
+21 # Validate 'time_range' parameter (optional, defaults to 7)
+22 time_range = data.get("time_range", 7)
+23 if not isinstance(time_range, int):
+24 return jsonify({"error": "'time_range' must be an integer"}), 400
+25
+26 # Simulate retrieving statistics for the given device IDs and time range
+27 # In a real application, you would query your database or external service here
+28 statistics = []
+29 for device_id in device_ids:
+30 # Placeholder for actual data retrieval
+31 stats = {
+32 "device_id": device_id,
+33 "time_range": f"Last {time_range} days",
+34 "data": f"Statistics data for device {device_id} over the last {time_range} days.",
+35 }
+36 statistics.append(stats)
+37
+38 response = {"statistics": statistics}
+39
+40 return jsonify(response), 200
41
-42if __name__ == "__main__":
-43 app.run(debug=True)
+42
+43if __name__ == "__main__":
+44 app.run(debug=True)
@@ -272,42 +273,42 @@ active intent, Arch adds the 19 intent_changed = True
20 else:
21 # Invalid value provided
-22 return jsonify(
-23 {"error": "Invalid value for x-arch-prompt-intent-change header"}
-24 ), 400
-25
-26 # Update user conversation based on intent change
-27 memory = update_user_conversation(user_id, client_messages, intent_changed)
-28
-29 # Retrieve messages since last intent change for LLM
-30 messages_for_llm = get_messages_since_last_intent(memory.chat_memory.messages)
-31
-32 # Forward messages to upstream LLM
-33 llm_response = forward_to_llm(messages_for_llm)
-34
-35 # Prepare the messages to return
-36 messages_to_return = []
-37 for message in memory.chat_memory.messages:
-38 role = "user" if isinstance(message, HumanMessage) else "assistant"
-39 content = message.content
-40 metadata = message.additional_kwargs.get("metadata", {})
-41 message_entry = {
-42 "uuid": metadata.get("uuid"),
-43 "timestamp": metadata.get("timestamp"),
-44 "role": role,
-45 "content": content,
-46 "intent_changed": metadata.get("intent_changed", False),
-47 }
-48 messages_to_return.append(message_entry)
-49
-50 # Prepare the response
-51 response = {
-52 "user_id": user_id,
-53 "messages": messages_to_return,
-54 "llm_response": llm_response,
-55 }
-56
-57 return jsonify(response), 200
+22 return (
+23 jsonify({"error": "Invalid value for x-arch-prompt-intent-change header"}),
+24 400,
+25 )
+26
+27 # Update user conversation based on intent change
+28 memory = update_user_conversation(user_id, client_messages, intent_changed)
+29
+30 # Retrieve messages since last intent change for LLM
+31 messages_for_llm = get_messages_since_last_intent(memory.chat_memory.messages)
+32
+33 # Forward messages to upstream LLM
+34 llm_response = forward_to_llm(messages_for_llm)
+35
+36 # Prepare the messages to return
+37 messages_to_return = []
+38 for message in memory.chat_memory.messages:
+39 role = "user" if isinstance(message, HumanMessage) else "assistant"
+40 content = message.content
+41 metadata = message.additional_kwargs.get("metadata", {})
+42 message_entry = {
+43 "uuid": metadata.get("uuid"),
+44 "timestamp": metadata.get("timestamp"),
+45 "role": role,
+46 "content": content,
+47 "intent_changed": metadata.get("intent_changed", False),
+48 }
+49 messages_to_return.append(message_entry)
+50
+51 # Prepare the response
+52 response = {
+53 "user_id": user_id,
+54 "messages": messages_to_return,
+55 "llm_response": llm_response,
+56 }
+57