From b7ebdba3b8d3444bd38a10352180a2876fbc66a0 Mon Sep 17 00:00:00 2001 From: grant Date: Wed, 20 Nov 2024 15:38:42 -0600 Subject: [PATCH 1/3] trivia season 3 --- package.json | 2 +- src/Classes/TriviaBot.ts | 47 ++++++++++++++------------ src/Data/supabase.ts | 6 +++- yarn.lock | 71 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 101 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index e3f491f..f6caf99 100644 --- a/package.json +++ b/package.json @@ -60,11 +60,11 @@ "graphql-tag": "^2.12.6", "husky": "^8.0.3", "jest": "^28.0.3", - "langchain": "^0.0.66", "lodash.deburr": "^4.1.0", "ms": "^2.0.0", "node-fetch": "^2.6.1", "node-html-parser": "^3.2.0", + "openai": "^4.73.0", "prettier": "^2.6.2", "react": "18.2.0", "reconnecting-websocket": "^4.4.0", diff --git a/src/Classes/TriviaBot.ts b/src/Classes/TriviaBot.ts index 366e8e5..59a3772 100644 --- a/src/Classes/TriviaBot.ts +++ b/src/Classes/TriviaBot.ts @@ -1,6 +1,6 @@ import * as dotenv from 'dotenv' dotenv.config() -import { OpenAIChat } from 'langchain/llms/openai' +import { OpenAI } from 'openai' import { ProjectBot } from './ProjectBot' import { Client, EmbedBuilder, Message, TextChannel } from 'discord.js' import { projectConfig } from '..' @@ -10,32 +10,21 @@ import { getTokenApiUrl, replaceVideoWithGIF } from './APIBots/utils' import { getAllTriviaScores, updateTriviaScore } from '../Data/supabase' // NOTE: if you change this, you'll need to manually update the supabase upsert query in updateTriviaScore -export const CURRENT_SEASON = 'season_two' +export const CURRENT_SEASON = 'season_three' export class TriviaBot { bot: Client - model?: OpenAIChat + model?: OpenAI channel?: TextChannel previousQuestion?: Message previousQuestionEmbed?: EmbedBuilder - previousAnswers: string[] = [] currentTriviaAnswer: string constructor(bot: Client) { this.bot = bot this.model = process.env.OPENAI_API_KEY - ? new OpenAIChat({ - modelName: 'gpt-3.5-turbo', // With valid API keys can also use 'gpt-4' - temperature: 0, - prefixMessages: [ - { - role: 'system', - content: ` - You are a bot that thinks of trivia questions with art projects as the answers. I will provide the title of the project and the project description. - DO NOT include the answer in your response. - `, - }, - ], + ? new OpenAI({ + apiKey: process.env.OPENAI_API_KEY, // This is the default and can be omitted }) : undefined @@ -149,14 +138,30 @@ Next question:` throw new Error("Can't ask trivia question - no OpenAI API key") } - let question = await this.model.call( - `Generate a short, cryptic, poetic, vague, difficult riddle that has the answer: "${project.projectName}". It is VERY important that you DO NOT include the answer in your response. The project description is: "${project.description}"` - ) + const completion = await this.model.chat.completions.create({ + model: 'gpt-4o-mini', + messages: [ + { + role: 'system', + content: + 'You are a trivia bot that generates trivia questions about generative art projects. The most important rule is NEVER to state the answer in your response', + }, + { + role: 'user', + content: `Generate a short, cryptic, poetic, vague, difficult riddle that has the answer: "${project.projectName}". It is VERY important that you DO NOT include the answer in your response. The project description is: "${project.description}"`, + }, + ], + }) + let answer = completion.choices[0].message.content ?? '' const regex = new RegExp(project.projectName, 'gi') - question = question.replaceAll(regex, '_____') + answer = answer.replaceAll(regex, '_____') - embed.setDescription(question) + if (!answer.length) { + throw new Error('No answer from GPT') + } + + embed.setDescription(answer) return embed } diff --git a/src/Data/supabase.ts b/src/Data/supabase.ts index 47301dd..506b523 100644 --- a/src/Data/supabase.ts +++ b/src/Data/supabase.ts @@ -26,7 +26,11 @@ export const updateTriviaScore = async (username: string): Promise => { // NOTE: When changing seasons, we have to manually change the upsert column here. Super annoying I know. const { error } = await supabaseClient .from(process.env.TRIVIA_TABLE ?? '') - .upsert({ user: `${username}`, score: totalScore, season_two: seasonScore }) + .upsert({ + user: `${username}`, + score: totalScore, + season_three: seasonScore, + }) if (error) { console.error('Error updating trivia score', error) diff --git a/yarn.lock b/yarn.lock index 8b2252f..4acccda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3008,6 +3008,16 @@ __metadata: languageName: node linkType: hard +"@types/node-fetch@npm:^2.6.4": + version: 2.6.12 + resolution: "@types/node-fetch@npm:2.6.12" + dependencies: + "@types/node": "npm:*" + form-data: "npm:^4.0.0" + checksum: 10c0/7693acad5499b7df2d1727d46cff092a63896dc04645f36b973dd6dd754a59a7faba76fcb777bdaa35d80625c6a9dd7257cca9c401a4bab03b04480cda7fd1af + languageName: node + linkType: hard + "@types/node@npm:*": version: 18.11.7 resolution: "@types/node@npm:18.11.7" @@ -3029,6 +3039,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^18.11.18": + version: 18.19.64 + resolution: "@types/node@npm:18.19.64" + dependencies: + undici-types: "npm:~5.26.4" + checksum: 10c0/a54009cd222f5751c903e5f4889a0f12e3d3755a1f87ce919455eeaf00a9ba0c9215c4a92bc3d8df585a894fa3e4cf218e5afccced355688624133e1a4b88235 + languageName: node + linkType: hard + "@types/normalize-package-data@npm:^2.4.1": version: 2.4.1 resolution: "@types/normalize-package-data@npm:2.4.1" @@ -3438,6 +3457,15 @@ __metadata: languageName: node linkType: hard +"agentkeepalive@npm:^4.2.1": + version: 4.5.0 + resolution: "agentkeepalive@npm:4.5.0" + dependencies: + humanize-ms: "npm:^1.2.1" + checksum: 10c0/394ea19f9710f230722996e156607f48fdf3a345133b0b1823244b7989426c16019a428b56c82d3eabef616e938812981d9009f4792ecc66bd6a59e991c62612 + languageName: node + linkType: hard + "aggregate-error@npm:^3.0.0": version: 3.1.0 resolution: "aggregate-error@npm:3.1.0" @@ -3662,6 +3690,7 @@ __metadata: ms: "npm:^2.0.0" node-fetch: "npm:^2.6.1" node-html-parser: "npm:^3.2.0" + openai: "npm:^4.73.0" prettier: "npm:^2.6.2" react: "npm:18.2.0" reconnecting-websocket: "npm:^4.4.0" @@ -6533,7 +6562,7 @@ __metadata: languageName: node linkType: hard -"form-data-encoder@npm:^1.7.1": +"form-data-encoder@npm:1.7.2, form-data-encoder@npm:^1.7.1": version: 1.7.2 resolution: "form-data-encoder@npm:1.7.2" checksum: 10c0/56553768037b6d55d9de524f97fe70555f0e415e781cb56fc457a68263de3d40fadea2304d4beef2d40b1a851269bd7854e42c362107071892cb5238debe9464 @@ -6573,7 +6602,7 @@ __metadata: languageName: node linkType: hard -"formdata-node@npm:^4.3.1": +"formdata-node@npm:^4.3.1, formdata-node@npm:^4.3.2": version: 4.4.1 resolution: "formdata-node@npm:4.4.1" dependencies: @@ -7312,6 +7341,15 @@ __metadata: languageName: node linkType: hard +"humanize-ms@npm:^1.2.1": + version: 1.2.1 + resolution: "humanize-ms@npm:1.2.1" + dependencies: + ms: "npm:^2.0.0" + checksum: 10c0/f34a2c20161d02303c2807badec2f3b49cbfbbb409abd4f95a07377ae01cfe6b59e3d15ac609cffcd8f2521f0eb37b7e1091acf65da99aa2a4f1ad63c21e7e7a + languageName: node + linkType: hard + "husky@npm:^8.0.3": version: 8.0.3 resolution: "husky@npm:8.0.3" @@ -9921,6 +9959,28 @@ __metadata: languageName: node linkType: hard +"openai@npm:^4.73.0": + version: 4.73.0 + resolution: "openai@npm:4.73.0" + dependencies: + "@types/node": "npm:^18.11.18" + "@types/node-fetch": "npm:^2.6.4" + abort-controller: "npm:^3.0.0" + agentkeepalive: "npm:^4.2.1" + form-data-encoder: "npm:1.7.2" + formdata-node: "npm:^4.3.2" + node-fetch: "npm:^2.6.7" + peerDependencies: + zod: ^3.23.8 + peerDependenciesMeta: + zod: + optional: true + bin: + openai: bin/cli + checksum: 10c0/ff2c1086e98563f3b164c25be94c2b299b6d38ea8556a14577dd7f57d3999fb1298913437dc011bf582f20f126ec5553900cd295d9ba30c29561abfe197a2cbd + languageName: node + linkType: hard + "optionator@npm:^0.9.1": version: 0.9.1 resolution: "optionator@npm:0.9.1" @@ -12156,6 +12216,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~5.26.4": + version: 5.26.5 + resolution: "undici-types@npm:5.26.5" + checksum: 10c0/bb673d7876c2d411b6eb6c560e0c571eef4a01c1c19925175d16e3a30c4c428181fb8d7ae802a261f283e4166a0ac435e2f505743aa9e45d893f9a3df017b501 + languageName: node + linkType: hard + "undici@npm:6.19.8": version: 6.19.8 resolution: "undici@npm:6.19.8" From 6ee1eaa8c4031d9d5d82b31624e2fb1ee5df05f2 Mon Sep 17 00:00:00 2001 From: grant Date: Wed, 20 Nov 2024 16:18:08 -0600 Subject: [PATCH 2/3] updated lock --- yarn.lock | 345 +----------------------------------------------------- 1 file changed, 2 insertions(+), 343 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4acccda..e230160 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,16 +22,6 @@ __metadata: languageName: node linkType: hard -"@anthropic-ai/sdk@npm:^0.4.3": - version: 0.4.4 - resolution: "@anthropic-ai/sdk@npm:0.4.4" - dependencies: - "@fortaine/fetch-event-source": "npm:^3.0.6" - cross-fetch: "npm:^3.1.5" - checksum: 10c0/0fb2a0cbc597238890f5d79f56afa53c72d54c05aceb1f37d61f89374feec83df7c93b86a4819978d8320ba11a071b6373aa9434248c6ceac71db00cc65af8ea - languageName: node - linkType: hard - "@ardatan/aggregate-error@npm:^0.0.6": version: 0.0.6 resolution: "@ardatan/aggregate-error@npm:0.0.6" @@ -1072,13 +1062,6 @@ __metadata: languageName: node linkType: hard -"@dqbd/tiktoken@npm:^1.0.7": - version: 1.0.7 - resolution: "@dqbd/tiktoken@npm:1.0.7" - checksum: 10c0/cd38d6819aabf12999a7a574683101849ecbe3f597ad6f943cbe4c1b9e7a7ad25acfdfb09a33f9366af99b3864e62133158bfbbd073ade2f244ec5e5c1de6160 - languageName: node - linkType: hard - "@eslint/eslintrc@npm:^1.3.3": version: 1.3.3 resolution: "@eslint/eslintrc@npm:1.3.3" @@ -1525,13 +1508,6 @@ __metadata: languageName: node linkType: hard -"@fortaine/fetch-event-source@npm:^3.0.6": - version: 3.0.6 - resolution: "@fortaine/fetch-event-source@npm:3.0.6" - checksum: 10c0/dfe7cf2d9c45920f865104c9fd68bc0704a010b68056abca2428c1ab23136051e856cea709744101e4d6223110f1b4be0c2352009185ab7636f40e3f560e4512 - languageName: node - linkType: hard - "@graphql-codegen/cli@npm:^2.13.11": version: 2.13.11 resolution: "@graphql-codegen/cli@npm:2.13.11" @@ -3094,13 +3070,6 @@ __metadata: languageName: node linkType: hard -"@types/retry@npm:0.12.0": - version: 0.12.0 - resolution: "@types/retry@npm:0.12.0" - checksum: 10c0/7c5c9086369826f569b83a4683661557cab1361bac0897a1cefa1a915ff739acd10ca0d62b01071046fe3f5a3f7f2aec80785fe283b75602dc6726781ea3e328 - languageName: node - linkType: hard - "@types/secp256k1@npm:^4.0.1": version: 4.0.3 resolution: "@types/secp256k1@npm:4.0.3" @@ -3685,7 +3654,6 @@ __metadata: graphql-tag: "npm:^2.12.6" husky: "npm:^8.0.3" jest: "npm:^28.0.3" - langchain: "npm:^0.0.66" lodash.deburr: "npm:^4.1.0" ms: "npm:^2.0.0" node-fetch: "npm:^2.6.1" @@ -3811,15 +3779,6 @@ __metadata: languageName: node linkType: hard -"axios@npm:^0.26.0": - version: 0.26.1 - resolution: "axios@npm:0.26.1" - dependencies: - follow-redirects: "npm:^1.14.8" - checksum: 10c0/77ad7f1e6ca04fcd3fa8af1795b09d8b7c005b71a31f28d99ba40cda0bdcc12a4627801d7fac5efa62b9f667a8402bd54c669039694373bc8d44f6be611f785c - languageName: node - linkType: hard - "axios@npm:^1.6.0": version: 1.6.8 resolution: "axios@npm:1.6.8" @@ -4015,20 +3974,13 @@ __metadata: languageName: node linkType: hard -"binary-extensions@npm:^2.0.0, binary-extensions@npm:^2.2.0": +"binary-extensions@npm:^2.0.0": version: 2.2.0 resolution: "binary-extensions@npm:2.2.0" checksum: 10c0/d73d8b897238a2d3ffa5f59c0241870043aa7471335e89ea5e1ff48edb7c2d0bb471517a3e4c5c3f4c043615caa2717b5f80a5e61e07503d51dc85cb848e665d languageName: node linkType: hard -"binary-search@npm:^1.3.5": - version: 1.3.6 - resolution: "binary-search@npm:1.3.6" - checksum: 10c0/786a770e3411cf563c9c7829e2854d79583a207b8faaa5022f93352893e1d06035ae5d80de1b168dcbd9d346fdb0dd2e3d7fcdf309b3a63dc027e92624da32a0 - languageName: node - linkType: hard - "bl@npm:^4.0.3, bl@npm:^4.1.0": version: 4.1.0 resolution: "bl@npm:4.1.0" @@ -4157,13 +4109,6 @@ __metadata: languageName: node linkType: hard -"browser-or-node@npm:^2.1.1": - version: 2.1.1 - resolution: "browser-or-node@npm:2.1.1" - checksum: 10c0/f727639581182f831b5bf4686b401dcad5cc29b5a6b70059c0aa90990844b8f15f3a1d328cc8e83dd3b4bfa69175f9bdf2f4383faec14d47205bfea532b9964d - languageName: node - linkType: hard - "browserify-aes@npm:^1.0.0, browserify-aes@npm:^1.0.4, browserify-aes@npm:^1.2.0": version: 1.2.0 resolution: "browserify-aes@npm:1.2.0" @@ -6149,13 +6094,6 @@ __metadata: languageName: node linkType: hard -"eventemitter3@npm:^4.0.4": - version: 4.0.7 - resolution: "eventemitter3@npm:4.0.7" - checksum: 10c0/5f6d97cbcbac47be798e6355e3a7639a84ee1f7d9b199a07017f1d2f1e2fe236004d14fa5dfaeba661f94ea57805385e326236a6debbc7145c8877fbc0297c6b - languageName: node - linkType: hard - "eventsource-parser@npm:^1.0.0": version: 1.0.0 resolution: "eventsource-parser@npm:1.0.0" @@ -6225,13 +6163,6 @@ __metadata: languageName: node linkType: hard -"expr-eval@npm:^2.0.2": - version: 2.0.2 - resolution: "expr-eval@npm:2.0.2" - checksum: 10c0/642f112ff28ea34574c595c3ad73ccd8e638498879a4dd28620c4dabebab2e11987a851266ba81883dae85a5800e0c93b3d06f81718b71a215f831534646e4f2 - languageName: node - linkType: hard - "express@npm:^4.14.0": version: 4.19.2 resolution: "express@npm:4.19.2" @@ -6503,15 +6434,6 @@ __metadata: languageName: node linkType: hard -"flat@npm:^5.0.2": - version: 5.0.2 - resolution: "flat@npm:5.0.2" - bin: - flat: cli.js - checksum: 10c0/f178b13482f0cd80c7fede05f4d10585b1f2fdebf26e12edc138e32d3150c6ea6482b7f12813a1091143bad52bb6d3596bca51a162257a21163c0ff438baa5fe - languageName: node - linkType: hard - "flatted@npm:^3.1.0": version: 3.2.7 resolution: "flatted@npm:3.2.7" @@ -6519,7 +6441,7 @@ __metadata: languageName: node linkType: hard -"follow-redirects@npm:^1.14.8, follow-redirects@npm:^1.15.6": +"follow-redirects@npm:^1.15.6": version: 1.15.6 resolution: "follow-redirects@npm:1.15.6" peerDependenciesMeta: @@ -7544,13 +7466,6 @@ __metadata: languageName: node linkType: hard -"is-any-array@npm:^2.0.0": - version: 2.0.1 - resolution: "is-any-array@npm:2.0.1" - checksum: 10c0/f9807458a51e63ca1ac27fd6f3a3ace8200f077094e00d9b05b24cfbc9d5594d586d6ecf3416271f26939d5cb93fc52ca869cb5744e77318c3f53ec70b08d61f - languageName: node - linkType: hard - "is-arguments@npm:^1.0.4": version: 1.1.1 resolution: "is-arguments@npm:1.1.1" @@ -8616,13 +8531,6 @@ __metadata: languageName: node linkType: hard -"jsonpointer@npm:^5.0.1": - version: 5.0.1 - resolution: "jsonpointer@npm:5.0.1" - checksum: 10c0/89929e58b400fcb96928c0504fcf4fc3f919d81e9543ceb055df125538470ee25290bb4984251e172e6ef8fcc55761eb998c118da763a82051ad89d4cb073fe7 - languageName: node - linkType: hard - "jsonwebtoken@npm:^8.5.1": version: 8.5.1 resolution: "jsonwebtoken@npm:8.5.1" @@ -8732,119 +8640,6 @@ __metadata: languageName: node linkType: hard -"langchain@npm:^0.0.66": - version: 0.0.66 - resolution: "langchain@npm:0.0.66" - dependencies: - "@anthropic-ai/sdk": "npm:^0.4.3" - "@dqbd/tiktoken": "npm:^1.0.7" - binary-extensions: "npm:^2.2.0" - browser-or-node: "npm:^2.1.1" - expr-eval: "npm:^2.0.2" - flat: "npm:^5.0.2" - jsonpointer: "npm:^5.0.1" - ml-distance: "npm:^4.0.0" - object-hash: "npm:^3.0.0" - openai: "npm:^3.2.0" - p-queue: "npm:^6.6.2" - p-retry: "npm:4" - uuid: "npm:^9.0.0" - yaml: "npm:^2.2.1" - zod: "npm:^3.21.4" - zod-to-json-schema: "npm:^3.20.4" - peerDependencies: - "@aws-sdk/client-lambda": ^3.310.0 - "@aws-sdk/client-s3": ^3.310.0 - "@getmetal/metal-sdk": "*" - "@huggingface/inference": ^1.5.1 - "@opensearch-project/opensearch": "*" - "@pinecone-database/pinecone": "*" - "@supabase/supabase-js": ^2.10.0 - "@tensorflow-models/universal-sentence-encoder": "*" - "@tensorflow/tfjs-converter": "*" - "@tensorflow/tfjs-core": "*" - "@zilliz/milvus2-sdk-node": ^2.2.0 - axios: "*" - cheerio: ^1.0.0-rc.12 - chromadb: ^1.4.0 - cohere-ai: ^5.0.2 - d3-dsv: ^2.0.0 - epub2: ^3.0.1 - hnswlib-node: ^1.4.2 - html-to-text: ^9.0.5 - mammoth: "*" - mongodb: ^5.2.0 - pdf-parse: 1.1.1 - playwright: ^1.32.1 - puppeteer: ^19.7.2 - redis: ^4.6.4 - replicate: ^0.9.0 - srt-parser-2: ^1.2.2 - typeorm: ^0.3.12 - weaviate-ts-client: ^1.0.0 - peerDependenciesMeta: - "@aws-sdk/client-lambda": - optional: true - "@aws-sdk/client-s3": - optional: true - "@getmetal/metal-sdk": - optional: true - "@huggingface/inference": - optional: true - "@opensearch-project/opensearch": - optional: true - "@pinecone-database/pinecone": - optional: true - "@supabase/supabase-js": - optional: true - "@tensorflow-models/universal-sentence-encoder": - optional: true - "@tensorflow/tfjs-converter": - optional: true - "@tensorflow/tfjs-core": - optional: true - "@zilliz/milvus2-sdk-node": - optional: true - axios: - optional: true - cheerio: - optional: true - chromadb: - optional: true - cohere-ai: - optional: true - d3-dsv: - optional: true - epub2: - optional: true - hnswlib-node: - optional: true - html-to-text: - optional: true - mammoth: - optional: true - mongodb: - optional: true - pdf-parse: - optional: true - playwright: - optional: true - puppeteer: - optional: true - redis: - optional: true - replicate: - optional: true - srt-parser-2: - optional: true - typeorm: - optional: true - weaviate-ts-client: - optional: true - checksum: 10c0/74f953534aa92d1cd5c86d791da661e63abe6d3051edb2a6d00194942ea98180045982b24c9dddf5c4c9353d95b495f9b28abb8fdbafcdc4dcf950dd33fb7154 - languageName: node - linkType: hard - "leven@npm:^3.1.0": version: 3.1.0 resolution: "leven@npm:3.1.0" @@ -9470,52 +9265,6 @@ __metadata: languageName: node linkType: hard -"ml-array-mean@npm:^1.1.6": - version: 1.1.6 - resolution: "ml-array-mean@npm:1.1.6" - dependencies: - ml-array-sum: "npm:^1.1.6" - checksum: 10c0/41ab68308e3472702f775a49c8ab9ee1e678e01cd59dbc59424c0f1017a37df1bb638e702831305f0e6366300eca48353f526773ab8f4d8d142a64d0461f9944 - languageName: node - linkType: hard - -"ml-array-sum@npm:^1.1.6": - version: 1.1.6 - resolution: "ml-array-sum@npm:1.1.6" - dependencies: - is-any-array: "npm:^2.0.0" - checksum: 10c0/fb3973ce2bfa19ab4f5e657f722494425b57025547657d332bf5bafe3e4e7e4bd1e082dfb970bcc0bfa87efa345b80a20a596dbb204be7b4802b52c35fd6cf77 - languageName: node - linkType: hard - -"ml-distance-euclidean@npm:^2.0.0": - version: 2.0.0 - resolution: "ml-distance-euclidean@npm:2.0.0" - checksum: 10c0/877aef472e134f79be9540b02f889b2a27976ca45d77f5d4ef7d8dd24058a60cf4637365b40a5aba1ab5490348a0fb1b3803143b25af88cdc66137fbfd665442 - languageName: node - linkType: hard - -"ml-distance@npm:^4.0.0": - version: 4.0.1 - resolution: "ml-distance@npm:4.0.1" - dependencies: - ml-array-mean: "npm:^1.1.6" - ml-distance-euclidean: "npm:^2.0.0" - ml-tree-similarity: "npm:^1.0.0" - checksum: 10c0/8c2eb077d2ba61437f2414f3b9ca1091c43fcabe2282ecc31d8ebf9e083c1df068e43c67f59a4674e7c8f473201ace4f02779b446427d6169a5d669cae94c816 - languageName: node - linkType: hard - -"ml-tree-similarity@npm:^1.0.0": - version: 1.0.0 - resolution: "ml-tree-similarity@npm:1.0.0" - dependencies: - binary-search: "npm:^1.3.5" - num-sort: "npm:^2.0.0" - checksum: 10c0/e3ecd07bead5d18bc7b6fed1dfefbe65aea4008d5556181b94b7d70550fba543d2501b224f12a9f5197c1d23d95faef2accc7fd265c5afd15ef55a38190ffc6e - languageName: node - linkType: hard - "mock-fs@npm:^4.1.0": version: 4.14.0 resolution: "mock-fs@npm:4.14.0" @@ -9827,13 +9576,6 @@ __metadata: languageName: node linkType: hard -"num-sort@npm:^2.0.0": - version: 2.1.0 - resolution: "num-sort@npm:2.1.0" - checksum: 10c0/cc1d43adbc9adfd5d208a8eb653827277376ff2e6eb75379f96e6a23d481040e317e63505e075b84ce49e19b9d960570646096428a715d12c5ef1381504d5135 - languageName: node - linkType: hard - "number-to-bn@npm:1.7.0": version: 1.7.0 resolution: "number-to-bn@npm:1.7.0" @@ -9858,13 +9600,6 @@ __metadata: languageName: node linkType: hard -"object-hash@npm:^3.0.0": - version: 3.0.0 - resolution: "object-hash@npm:3.0.0" - checksum: 10c0/a06844537107b960c1c8b96cd2ac8592a265186bfa0f6ccafe0d34eabdb526f6fa81da1f37c43df7ed13b12a4ae3457a16071603bcd39d8beddb5f08c37b0f47 - languageName: node - linkType: hard - "object-inspect@npm:^1.12.2, object-inspect@npm:^1.9.0": version: 1.12.2 resolution: "object-inspect@npm:1.12.2" @@ -9949,16 +9684,6 @@ __metadata: languageName: node linkType: hard -"openai@npm:^3.2.0": - version: 3.3.0 - resolution: "openai@npm:3.3.0" - dependencies: - axios: "npm:^0.26.0" - form-data: "npm:^4.0.0" - checksum: 10c0/3f4b29d21c042e140931d17cf1a23761f5e5ad23754d43da0c3611a3fb10e9ef00fdb076856c3f2af391ad29405b3b06d6c878f97f7a1e7981de0ae79eb1785e - languageName: node - linkType: hard - "openai@npm:^4.73.0": version: 4.73.0 resolution: "openai@npm:4.73.0" @@ -10033,13 +9758,6 @@ __metadata: languageName: node linkType: hard -"p-finally@npm:^1.0.0": - version: 1.0.0 - resolution: "p-finally@npm:1.0.0" - checksum: 10c0/6b8552339a71fe7bd424d01d8451eea92d379a711fc62f6b2fe64cad8a472c7259a236c9a22b4733abca0b5666ad503cb497792a0478c5af31ded793d00937e7 - languageName: node - linkType: hard - "p-limit@npm:3.1.0, p-limit@npm:^3.0.2, p-limit@npm:^3.1.0": version: 3.1.0 resolution: "p-limit@npm:3.1.0" @@ -10103,35 +9821,6 @@ __metadata: languageName: node linkType: hard -"p-queue@npm:^6.6.2": - version: 6.6.2 - resolution: "p-queue@npm:6.6.2" - dependencies: - eventemitter3: "npm:^4.0.4" - p-timeout: "npm:^3.2.0" - checksum: 10c0/5739ecf5806bbeadf8e463793d5e3004d08bb3f6177bd1a44a005da8fd81bb90f80e4633e1fb6f1dfd35ee663a5c0229abe26aebb36f547ad5a858347c7b0d3e - languageName: node - linkType: hard - -"p-retry@npm:4": - version: 4.6.2 - resolution: "p-retry@npm:4.6.2" - dependencies: - "@types/retry": "npm:0.12.0" - retry: "npm:^0.13.1" - checksum: 10c0/d58512f120f1590cfedb4c2e0c42cb3fa66f3cea8a4646632fcb834c56055bb7a6f138aa57b20cc236fb207c9d694e362e0b5c2b14d9b062f67e8925580c73b0 - languageName: node - linkType: hard - -"p-timeout@npm:^3.2.0": - version: 3.2.0 - resolution: "p-timeout@npm:3.2.0" - dependencies: - p-finally: "npm:^1.0.0" - checksum: 10c0/524b393711a6ba8e1d48137c5924749f29c93d70b671e6db761afa784726572ca06149c715632da8f70c090073afb2af1c05730303f915604fd38ee207b70a61 - languageName: node - linkType: hard - "p-timeout@npm:^6.1.1": version: 6.1.2 resolution: "p-timeout@npm:6.1.2" @@ -10938,13 +10627,6 @@ __metadata: languageName: node linkType: hard -"retry@npm:^0.13.1": - version: 0.13.1 - resolution: "retry@npm:0.13.1" - checksum: 10c0/9ae822ee19db2163497e074ea919780b1efa00431d197c7afdb950e42bf109196774b92a49fc9821f0b8b328a98eea6017410bfc5e8a0fc19c85c6d11adb3772 - languageName: node - linkType: hard - "reusify@npm:^1.0.4": version: 1.0.4 resolution: "reusify@npm:1.0.4" @@ -13139,13 +12821,6 @@ __metadata: languageName: node linkType: hard -"yaml@npm:^2.2.1": - version: 2.3.1 - resolution: "yaml@npm:2.3.1" - checksum: 10c0/ed4c21a907fb1cd60a25177612fa46d95064a144623d269199817908475fe85bef20fb17406e3bdc175351b6488056a6f84beb7836e8c262646546a0220188e3 - languageName: node - linkType: hard - "yargs-parser@npm:^18.1.2": version: 18.1.3 resolution: "yargs-parser@npm:18.1.3" @@ -13232,19 +12907,3 @@ __metadata: checksum: 10c0/856117aa15cf5103d2a2fb173f0ab4acb12b4b4d0ed3ab249fdbbf612e55d1cadfd27a6110940e24746fb0a78cf640b522cc8bca76f30a3b00b66e90cf82abe0 languageName: node linkType: hard - -"zod-to-json-schema@npm:^3.20.4": - version: 3.21.4 - resolution: "zod-to-json-schema@npm:3.21.4" - peerDependencies: - zod: ^3.21.4 - checksum: 10c0/2fe95b984f239465b81ac374ed975f5c271385f76a2a860edf6890f85ac0d38720163f0a204a3329152f40b928816ea50e913f3e66a7032c43cf2cbf17f8d6b3 - languageName: node - linkType: hard - -"zod@npm:^3.21.4": - version: 3.22.4 - resolution: "zod@npm:3.22.4" - checksum: 10c0/7578ab283dac0eee66a0ad0fc4a7f28c43e6745aadb3a529f59a4b851aa10872b3890398b3160f257f4b6817b4ce643debdda4fb21a2c040adda7862cab0a587 - languageName: node - linkType: hard From a045d1ff18b0283514c0ba8c02f1f751ee847933 Mon Sep 17 00:00:00 2001 From: grant Date: Thu, 21 Nov 2024 10:46:52 -0600 Subject: [PATCH 3/3] nice handy fix --- src/Classes/TriviaBot.ts | 1 - src/Data/supabase.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Classes/TriviaBot.ts b/src/Classes/TriviaBot.ts index 59a3772..1ee3e81 100644 --- a/src/Classes/TriviaBot.ts +++ b/src/Classes/TriviaBot.ts @@ -9,7 +9,6 @@ import axios from 'axios' import { getTokenApiUrl, replaceVideoWithGIF } from './APIBots/utils' import { getAllTriviaScores, updateTriviaScore } from '../Data/supabase' -// NOTE: if you change this, you'll need to manually update the supabase upsert query in updateTriviaScore export const CURRENT_SEASON = 'season_three' export class TriviaBot { diff --git a/src/Data/supabase.ts b/src/Data/supabase.ts index 506b523..c69aedd 100644 --- a/src/Data/supabase.ts +++ b/src/Data/supabase.ts @@ -23,13 +23,12 @@ export const updateTriviaScore = async (username: string): Promise => { seasonScore = parseInt(data[0][CURRENT_SEASON] ?? 0) + 1 } - // NOTE: When changing seasons, we have to manually change the upsert column here. Super annoying I know. const { error } = await supabaseClient .from(process.env.TRIVIA_TABLE ?? '') .upsert({ user: `${username}`, score: totalScore, - season_three: seasonScore, + [CURRENT_SEASON]: seasonScore, }) if (error) {