Spaces:
Running
Running
import streamlit as st | |
import requests | |
api_key = st.secrets["BRIAN_API_KEY"] | |
def send_post_request(prompt, kb): | |
url = " https://api.brianknows.org/api/v0/agent/knowledge" | |
data = {"prompt": prompt, "kb": kb} | |
headers = { | |
"Content-Type": "application/json", | |
"X-Brian-Api-Key": api_key, # Include the API key in the headers | |
} | |
response = requests.post(url, json=data, headers=headers) | |
if response.status_code == 200: | |
return response.json() # Returns the JSON response if successful | |
else: | |
return ( | |
response.status_code, | |
response.text, | |
) # Returns the status code and error if not successful | |
# Example usage: | |
kb_name = st.text_input(label="kb_name") | |
query = st.text_input(label="query") | |
if st.button("askbrian"): | |
result = send_post_request(query, kb_name) | |
st.json(result) | |