File size: 793 Bytes
e92154d
 
 
 
 
 
 
 
 
 
ec7ef1b
 
 
5c73d5c
 
 
 
 
e54130b
c224647
 
e92154d
c224647
 
 
 
5c73d5c
 
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
import os
import requests

import streamlit as st

BE = os.getenv("be_url")


datasets = requests.get(f"{BE}/v1/datasets", timeout=500).json()

st.sidebar.title("Datasets")
ds = st.sidebar.selectbox(options=[ d["name"] for d in datasets], 
                          label="Select your dataset")
print(ds)
if ds:
    query = st.text_input("Enter your search query",
                          placeholder="Ask your question")
    if query:
        res = requests.get(f"{BE}/v1/datasets/{ds}/answer?query={query}", 
                       timeout=5000 ).json()
        answer = res["answer"]

        st.write(answer)
        files = [f"{f['file']}, page {f['page']}" for f in res["metadata"]]
        for fi in files:
            st.markdown(f"- {fi}")
else:
    st.write("Choose your dataset!")