SpatialWebAgent commited on
Commit
820b4b3
·
verified ·
1 Parent(s): 127686a

Update disambiguation/disambiguate.py

Browse files
Files changed (1) hide show
  1. disambiguation/disambiguate.py +18 -18
disambiguation/disambiguate.py CHANGED
@@ -18,24 +18,24 @@ import regex_spatial
18
  import streamlit as st
19
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
20
 
21
- # BACKEND_URL = "https://SpatialWebAgent-dockerb22.hf.space/api/predict/"
22
-
23
- # def call_backend(input_text):
24
- # try:
25
- # headers = {
26
- # "Authorization": f"Bearer {API_TOKEN}"
27
- # }
28
- # response = requests.post(
29
- # BACKEND_URL,
30
- # headers=headers,
31
- # json={"data": [input_text]},
32
- # timeout=10
33
- # )
34
- # if response.status_code == 200:
35
- # return response.json() # ✅ 保留原始 JSON 对象 (dict)
36
- # return {"error": f"❌ Backend Error (HTTP {response.status_code})"}
37
- # except Exception as e:
38
- # return {"error": f"⚠️ Connection Error: {str(e)}"}
39
 
40
 
41
 
 
18
  import streamlit as st
19
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
20
 
21
+ BACKEND_URL = "https://SpatialWebAgent-dockerb22.hf.space/api/predict/"
22
+
23
+ def call_backend(input_text):
24
+ try:
25
+ headers = {
26
+ "Authorization": f"Bearer {API_TOKEN}"
27
+ }
28
+ response = requests.post(
29
+ BACKEND_URL,
30
+ headers=headers,
31
+ json={"data": [input_text]},
32
+ timeout=10
33
+ )
34
+ if response.status_code == 200:
35
+ return response.json() # ✅ 保留原始 JSON 对象 (dict)
36
+ return {"error": f"❌ Backend Error (HTTP {response.status_code})"}
37
+ except Exception as e:
38
+ return {"error": f"⚠️ Connection Error: {str(e)}"}
39
 
40
 
41