mattx
gsheet_call
Wrapper around Google Sheets API v4.
Parameters
- service_account: JSON string containing Google Service Account key
- sheet_id: Google Sheet ID
- method: HTTP method to use
- action: Full URL with
https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/
removed - data: HTTP request body
Requirements
- a Google Cloud service account
- the Google Sheets API v4 enabled in your Google Cloud project
- the spreadsheet ID (provide it in the sheet_id parameter)
Instructions
- Share the spreadsheet with the service account
- Make a JSON key for the service account, then set it as a secret. Use the secret for the service_account parameter.
- Figure out the action you want to perform. You will need to provide everything that comes after {spreadsheetId}/ as the action parameter. For example:
values/A1:C1:append?valueInputOption=RAW
- Figure out the request body. For example:
{values: [["foo", "bar", "baz"]]}
verify_discord_signature
Verify HTTP signatures coming from Discord.
- public_key should be the Ed25519 public key from Discord, as a hex string
- body should be the request body as a string. If you have a JSON object as the request body, use JSON.stringify.
- signature should be the X-Signature-Ed25519 header
- timestamp should be the X-Signature-Timestamp header You must return a 401 error and return early if this function returns false, otherwise you will pretty quickly get a big scary warning from Discord that your endpoint has been removed. Note that you'll only be able to add one once you've integrated this correctly.
As this function only deals with strings, it doesn't matter whether you use an Express or web endpoint.
parse_cookies
Parses Cookie headers into objects.
jar
: Value of the Cookie headerdecoder
: Function to run on all cookie names and values. This is to get around character limitations (see RFC 6265). There is no formal standard, but as most sites prefer URL encoding, it is the default.x => x
can be used as a way to disable decoding.
remind_new_open_llm
This val sends you an email whenever a new LLM appears in the top 10 LLMs on the Open LLM Leaderboard. Use an interval of at least 12 hours as the top 10 doesn't change that frequently. You can adjust the array slice to change how many places on the leaderboard to monitor, or remove it entirely to fill up your mailbox.
Bugs
If a model unfairly gets to the top 10 and then gets flagged for it, you'll get a reminder for an LLM that's in most cases not new at all. Hopefully this doesn't happen too often.
scrape_open_llm_leaderboard
This uses scrape_gradio_data to scrape the Open LLM Leaderboard and grab the names of all models that are not flagged. Array is ordered by average benchmark accuracy.
scrape_gradio_data
Scrapes the gradio_config object from Gradio sites/spaces. Most useful when pointed at a gradio site with lots of static data like the Open LLM Leaderboard