prasadnu commited on
Commit
f1559a0
·
1 Parent(s): 17c4b5b

ubi integration

Browse files
Files changed (1) hide show
  1. pages/Semantic_Search.py +15 -11
pages/Semantic_Search.py CHANGED
@@ -885,24 +885,28 @@ def render_answer(answer,index):
885
 
886
  <script>
887
  function sendEvent(itemId) {{
888
- fetch("{lambda_url}", {{
889
- method: "POST",
890
- headers: {{
891
- "Content-Type": "application/json"
892
- }},
893
- body: JSON.stringify({{
894
  action_name: "expander_open",
895
  item_id: itemId,
896
- session_id: "{st.session_state.get('session_id', 'unknown')}",
897
- query_id: "{st.session_state.get('query_id', 'unknown')}",
898
  timestamp: new Date().toISOString(),
899
  message_type: "INFO",
900
  message: "Expander opened for item " + itemId
901
- }})
902
- }}).then(response => console.log("Event sent for", itemId));
 
 
 
 
 
 
 
 
903
  }}
904
 
905
- // Automatically trigger click when the expander is opened
906
  document.getElementById("{doc_id}").click();
907
  </script>
908
  """, height=0)
 
885
 
886
  <script>
887
  function sendEvent(itemId) {{
888
+ const payload = {{
889
+ target_index: "ubi_events",
890
+ document: {{
 
 
 
891
  action_name: "expander_open",
892
  item_id: itemId,
893
+ session_id: "{st.session_state.get("session_id", "sess_unknown")}",
894
+ query_id: "{st.session_state.get("query_id", "query_unknown")}",
895
  timestamp: new Date().toISOString(),
896
  message_type: "INFO",
897
  message: "Expander opened for item " + itemId
898
+ }}
899
+ }};
900
+
901
+ fetch("{lambda_url}", {{
902
+ method: "POST",
903
+ headers: {{
904
+ "Content-Type": "application/json"
905
+ }},
906
+ body: JSON.stringify(payload)
907
+ }}).then(response => console.log("Sent to Lambda:", response.status));
908
  }}
909
 
 
910
  document.getElementById("{doc_id}").click();
911
  </script>
912
  """, height=0)