adollbo commited on
Commit
bf55023
·
1 Parent(s): b1a0686

added evaluations code

Browse files
Files changed (1) hide show
  1. app.py +30 -4
app.py CHANGED
@@ -10,16 +10,34 @@ logging.basicConfig(level=logging.INFO)
10
  st.set_page_config(layout="wide")
11
 
12
  st.title("Observing potential fraudulent transactions")
 
 
13
  st.write(
14
  "Fill in left hand side and click on button to observe a potential fraudulent transaction"
15
  )
16
 
17
- st.divider()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  def get_model_url():
 
20
  model_url = st.text_area(
21
- "Model URL (without the /explain endpoint, default is the demo deployment)",
22
- "https://api.app.deeploy.ml/workspaces/708b5808-27af-461a-8ee5-80add68384c7/deployments/dc8c359d-5f61-4107-8b0f-de97ec120289/",
23
  height=125,
24
  )
25
  elems = model_url.split("/")
@@ -43,12 +61,20 @@ with st.sidebar:
43
  # Add deeploy logo
44
  st.image("deeploy_logo.png", width=270)
45
  # Ask for model URL and token
46
- host = st.text_input("Host (Changing is optional)", "app.deeploy.ml")
47
  model_url, workspace_id, deployment_id = get_model_url()
48
  deployment_token = st.text_input("Deeploy Model Token", "my-secret-token")
49
  if deployment_token == "my-secret-token":
50
  button_clicked = st.button("Get suspicious transaction", key="get1", help="Click to get a suspicious transaction", use_container_width=True, on_click=lambda: st.experimental_rerun())
51
 
 
 
 
 
 
 
 
 
52
 
53
  ChangeButtonColour("Get suspicious transaction", '#FFFFFF', "#00052D")#'#FFFFFF', "#00052D"
54
 
 
10
  st.set_page_config(layout="wide")
11
 
12
  st.title("Observing potential fraudulent transactions")
13
+ st.divider()
14
+
15
  st.write(
16
  "Fill in left hand side and click on button to observe a potential fraudulent transaction"
17
  )
18
 
19
+ def send_evaluation(client, deployment_id, request_log_id, prediction_log_id, evaluation_input):
20
+ """Send evaluation to Deeploy."""
21
+ try:
22
+ with st.spinner("Submitting response..."):
23
+ # Call the explain endpoint as it also includes the prediction
24
+ client.evaluate(deployment_id, request_log_id, prediction_log_id, evaluation_input)
25
+ return True
26
+ except Exception as e:
27
+ logging.error(e)
28
+ st.error(
29
+ "Failed to submit feedback."
30
+ + "Check whether you are using the right model URL and Token. "
31
+ + "Contact Deeploy if the problem persists."
32
+ )
33
+ st.write(f"Error message: {e}")
34
+
35
 
36
  def get_model_url():
37
+ """Get model url and retrieve workspace id and deployment id from it"""
38
  model_url = st.text_area(
39
+ "Model URL (default is the demo deployment)",
40
+ "https://api.app.deeploy.ml/workspaces/708b5808-27af-461a-8ee5-80add68384c7/deployments/1785f8b8-c5a6-4f55-9a83-df8bdb0b9977/",
41
  height=125,
42
  )
43
  elems = model_url.split("/")
 
61
  # Add deeploy logo
62
  st.image("deeploy_logo.png", width=270)
63
  # Ask for model URL and token
64
+ host = st.text_input("Host (changing is optional)", "app.deeploy.ml")
65
  model_url, workspace_id, deployment_id = get_model_url()
66
  deployment_token = st.text_input("Deeploy Model Token", "my-secret-token")
67
  if deployment_token == "my-secret-token":
68
  button_clicked = st.button("Get suspicious transaction", key="get1", help="Click to get a suspicious transaction", use_container_width=True, on_click=lambda: st.experimental_rerun())
69
 
70
+ # define client options and instantiate client
71
+ client_options = {
72
+ "host": host,
73
+ "deployment_token": deployment_token,
74
+ "workspace_id": workspace_id,
75
+ }
76
+ client = Client(**client_options)
77
+
78
 
79
  ChangeButtonColour("Get suspicious transaction", '#FFFFFF', "#00052D")#'#FFFFFF', "#00052D"
80