Download utils.py from gptbase/GPTBase: direct link, hf CLI and curl.
- Browser
- Download file 450 Bytes
-
https://huggingface.co/spaces/gptbase/GPTBase/resolve/main/utils.py
- Command line
-
hf download hf://spaces/gptbase/GPTBase/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/gptbase/GPTBase/resolve/main/utils.py
450 Bytes
| import requests | |
| import json | |
| import streamlit as st | |
| 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 |