sulcan commited on
Commit
baeb083
·
verified ·
1 Parent(s): bd53950

Update src/app.py

Browse files

trying to save feedback

Files changed (1) hide show
  1. src/app.py +13 -0
src/app.py CHANGED
@@ -6,6 +6,18 @@ import colorsys
6
  import math
7
  import os
8
  import streamlit.components.v1 as components
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  MODEL_NAME = "Qwen/Qwen2.5-1.5B-Instruct"
11
  SYSTEM_PROMPT = """System Framework: High Energy Physics Validation.
@@ -254,6 +266,7 @@ if model:
254
  if key not in ['tokenizer', 'model', 'model_status']:
255
  del st.session_state[key]
256
  if text_to_analyze:
 
257
  with st.spinner("Performing analysis and calculating attention..."):
258
  analysis_data, full_tokens, attention_matrix, start_idx, end_idx = get_analysis_data(text_to_analyze,
259
  SYSTEM_PROMPT,
 
6
  import math
7
  import os
8
  import streamlit.components.v1 as components
9
+ import requests
10
+
11
+ BIN_ID = os.getenv("BIN_ID")
12
+ API_KEY = os.getenv("API_KEY")
13
+
14
+
15
+ def save_feedback(feedback_text):
16
+ url = f"https://api.jsonbin.io/v3/b/{BIN_ID}"
17
+ headers = {"X-Master-Key": API_KEY}
18
+ data = {"feedback": feedback_text, "timestamp": "now"}
19
+
20
+ requests.put(url, json=data, headers=headers)
21
 
22
  MODEL_NAME = "Qwen/Qwen2.5-1.5B-Instruct"
23
  SYSTEM_PROMPT = """System Framework: High Energy Physics Validation.
 
266
  if key not in ['tokenizer', 'model', 'model_status']:
267
  del st.session_state[key]
268
  if text_to_analyze:
269
+ save_feedback(text_to_analyze)
270
  with st.spinner("Performing analysis and calculating attention..."):
271
  analysis_data, full_tokens, attention_matrix, start_idx, end_idx = get_analysis_data(text_to_analyze,
272
  SYSTEM_PROMPT,