Spaces:
Running
Running
File size: 850 Bytes
06940e7 |
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 |
# 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}")
|