refactor with post and get
Browse files
app.py
CHANGED
@@ -26,20 +26,8 @@ def make_sidebar():
|
|
26 |
st.write("This is a sidebar.")
|
27 |
st.write("You can add widgets here")
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
payload = {"question": question, "logs": logs}
|
32 |
-
# st.write(payload)
|
33 |
-
return payload
|
34 |
-
|
35 |
-
|
36 |
-
def process_payload(payload):
|
37 |
-
all_logs = payload["logs"]
|
38 |
-
text = ""
|
39 |
-
for log in all_logs:
|
40 |
-
text += requests.get(log).text
|
41 |
-
|
42 |
-
payload["text"] = text
|
43 |
return payload
|
44 |
|
45 |
|
@@ -51,8 +39,8 @@ def main():
|
|
51 |
col1, col2 = st.columns(2)
|
52 |
|
53 |
with col1:
|
54 |
-
st.write("This is column
|
55 |
-
|
56 |
"Select the options",
|
57 |
[
|
58 |
"https://storage.googleapis.com/cleric-assignment-call-logs/call_log_20240314_104111.txt",
|
@@ -62,28 +50,29 @@ def main():
|
|
62 |
)
|
63 |
|
64 |
with col2:
|
65 |
-
st.write("This is column
|
66 |
question = st.text_input(
|
67 |
"Ask the question", value="What product design decisions did the team make?"
|
68 |
)
|
69 |
|
70 |
-
payload = create_payload(question,
|
71 |
-
processed_payload = process_payload(payload)
|
72 |
-
# st.write(processed_payload)
|
73 |
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
|
77 |
if st.button("Submit"):
|
78 |
# url = "https://deven-cleric-backend.onrender.com/submit_question_and_documents/"
|
79 |
url = f"{BASE_URL}/submit_question_and_documents/"
|
80 |
resp = requests.post(url, json=data.model_dump())
|
81 |
-
st.write(resp.status_code)
|
82 |
-
st.write(resp.json())
|
83 |
|
84 |
url_local_get = f"{BASE_URL}/get_question_and_facts/"
|
85 |
resp = requests.get(url_local_get)
|
86 |
-
st.write(resp.status_code)
|
87 |
st.write(resp.json())
|
88 |
|
89 |
|
|
|
26 |
st.write("This is a sidebar.")
|
27 |
st.write("You can add widgets here")
|
28 |
|
29 |
+
def create_payload(question, documents):
|
30 |
+
payload = {"question": question, "documents": documents}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
return payload
|
32 |
|
33 |
|
|
|
39 |
col1, col2 = st.columns(2)
|
40 |
|
41 |
with col1:
|
42 |
+
st.write("This is column 1")
|
43 |
+
documents = st.multiselect(
|
44 |
"Select the options",
|
45 |
[
|
46 |
"https://storage.googleapis.com/cleric-assignment-call-logs/call_log_20240314_104111.txt",
|
|
|
50 |
)
|
51 |
|
52 |
with col2:
|
53 |
+
st.write("This is column 2")
|
54 |
question = st.text_input(
|
55 |
"Ask the question", value="What product design decisions did the team make?"
|
56 |
)
|
57 |
|
58 |
+
payload = create_payload(question, documents)
|
|
|
|
|
59 |
|
60 |
+
|
61 |
+
data = SubmitQuestionAndDocumentsResponse(**payload)
|
62 |
+
# on = st.toggle('View model dump', False, key='view_model_dump')
|
63 |
+
# if on:
|
64 |
+
# st.write(data.model_dump())
|
65 |
|
66 |
if st.button("Submit"):
|
67 |
# url = "https://deven-cleric-backend.onrender.com/submit_question_and_documents/"
|
68 |
url = f"{BASE_URL}/submit_question_and_documents/"
|
69 |
resp = requests.post(url, json=data.model_dump())
|
70 |
+
# st.write(resp.status_code)
|
71 |
+
# st.write(resp.json())
|
72 |
|
73 |
url_local_get = f"{BASE_URL}/get_question_and_facts/"
|
74 |
resp = requests.get(url_local_get)
|
75 |
+
# st.write(resp.status_code)
|
76 |
st.write(resp.json())
|
77 |
|
78 |
|