File size: 875 Bytes
972d86d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)