search_engine / app.py
Vitomir Jovanović
Application file
06940e7
raw
history blame
850 Bytes
# streamlit_app.py
import streamlit as st
import requests
# Streamlit app title
st.title("Top K Search with Vector DataBase")
# FastAPI endpoint URL
url = "http://127.0.0.1:8000/search/"
# Input fields in Streamlit
id = st.text_input("Enter ID:", value="1")
prompt = st.text_input("Enter your prompt:")
k = st.number_input("Top K results:", min_value=1, max_value=100, value=3)
# Trigger the search when the button is clicked
if st.button("Search"):
# Construct the request payload
payload = {
"id": id,
"prompt": prompt,
"k": k
}
# Make the POST request
response = requests.post(url, json=payload)
# Handle the response
if response.status_code == 200:
results = response.json()
st.write(results)
else:
st.error(f"Error: {response.status_code} - {response.text}")