Spaces:
Running
Running
# 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://localhost:8084/search/" | |
url = "https://huggingface.co/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}") | |