Spaces:
Sleeping
Sleeping
Download database/save_query.py from SJ-1989/ChatSJB: direct link, hf CLI and curl.
- Browser
- Download file 544 Bytes
-
https://huggingface.co/spaces/SJ-1989/ChatSJB/resolve/main/database/save_query.py
- Command line
-
hf download hf://spaces/SJ-1989/ChatSJB/database/save_query.py
-
curl -L -o save_query.py https://huggingface.co/spaces/SJ-1989/ChatSJB/resolve/main/database/save_query.py
544 Bytes
| import logging | |
| import config | |
| from supabase import create_client | |
| logger = logging.getLogger(__name__) | |
| supabase = create_client( | |
| config.SUPABASE_URL, | |
| config.SUPABASE_KEY, | |
| ) | |
| def save_query( | |
| query: str, | |
| response_type: str | |
| ): | |
| """ | |
| Saves a user query and associated metadata to the Supabase database. | |
| """ | |
| try: | |
| supabase.table('queries').insert({ | |
| 'query': query, | |
| 'response_type': response_type | |
| }).execute() | |
| except Exception: | |
| logger.exception('Failed to save query') |