File size: 2,379 Bytes
17b9280 f15cd74 b64ad10 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 f15cd74 17b9280 d602bf7 f15cd74 17b9280 f15cd74 17b9280 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
import os
import requests
import streamlit as st
try:
from dotenv import load_dotenv
load_dotenv()
except ImportError:
pass
from responses import SubmitQuestionAndDocumentsResponse
st.set_page_config(layout="wide")
if os.getenv("ENV") == "production":
BASE_URL = "https://deven-cleric-backend.onrender.com"
else:
BASE_URL = "http://localhost:8000"
def make_sidebar():
with st.sidebar:
st.title("Sidebar")
st.write("This is a sidebar.")
st.write("You can add widgets here")
def create_payload(question, logs):
payload = {"question": question, "logs": logs}
# st.write(payload)
return payload
def process_payload(payload):
all_logs = payload["logs"]
text = ""
for log in all_logs:
text += requests.get(log).text
payload["text"] = text
return payload
def main():
st.title("Hello, World!")
# print("Hello, World!")
make_sidebar()
col1, col2 = st.columns(2)
with col1:
st.write("This is column 2")
logs = st.multiselect(
"Select the options",
[
"https://storage.googleapis.com/cleric-assignment-call-logs/call_log_20240314_104111.txt",
"https://storage.googleapis.com/cleric-assignment-call-logs/call_log_20240315_104111.txt",
"https://storage.googleapis.com/cleric-assignment-call-logs/call_log_20240316_104111.txt",
],
)
with col2:
st.write("This is column 1")
question = st.text_input(
"Ask the question", value="What product design decisions did the team make?"
)
payload = create_payload(question, logs)
processed_payload = process_payload(payload)
# st.write(processed_payload)
data = SubmitQuestionAndDocumentsResponse(**processed_payload)
st.write(data.model_dump())
if st.button("Submit"):
# url = "https://deven-cleric-backend.onrender.com/submit_question_and_documents/"
url = f"{BASE_URL}/submit_question_and_documents/"
resp = requests.post(url, json=data.model_dump())
st.write(resp.status_code)
st.write(resp.json())
url_local_get = f"{BASE_URL}/get_question_and_facts/"
resp = requests.get(url_local_get)
st.write(resp.status_code)
st.write(resp.json())
if __name__ == "__main__":
main()
|