GPTBase / utils.py
gptbase's picture
Update utils.py
6a580de
raw
history blame contribute delete
450 Bytes
import requests
import json
import streamlit as st
@st.experimental_memo()
def upload_file(file, api_key, ai_id):
file_data = {"file": file}
url = f'https://gptbase.ai/api/v1/ais/{ai_id}/files'
headers = {"Authorization": f"Bearer {api_key}"}
try:
response = requests.post(url, headers=headers, files=file_data)
print("upload")
return True
except requests.exceptions.HTTPError as err:
return False