Vitomir Jovanović commited on
Commit
06940e7
·
1 Parent(s): 01f5415

Application file

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # streamlit_app.py
2
+ import streamlit as st
3
+ import requests
4
+
5
+ # Streamlit app title
6
+ st.title("Top K Search with Vector DataBase")
7
+
8
+ # FastAPI endpoint URL
9
+ url = "http://127.0.0.1:8000/search/"
10
+
11
+ # Input fields in Streamlit
12
+ id = st.text_input("Enter ID:", value="1")
13
+ prompt = st.text_input("Enter your prompt:")
14
+ k = st.number_input("Top K results:", min_value=1, max_value=100, value=3)
15
+
16
+ # Trigger the search when the button is clicked
17
+ if st.button("Search"):
18
+ # Construct the request payload
19
+ payload = {
20
+ "id": id,
21
+ "prompt": prompt,
22
+ "k": k
23
+ }
24
+
25
+ # Make the POST request
26
+ response = requests.post(url, json=payload)
27
+
28
+ # Handle the response
29
+ if response.status_code == 200:
30
+ results = response.json()
31
+ st.write(results)
32
+ else:
33
+ st.error(f"Error: {response.status_code} - {response.text}")