From f7889bad7b8303bf09dda4d9eb7fd99fc44af38c Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Sat, 4 May 2024 13:36:14 +0200 Subject: [PATCH] fix discord logging env vars --- .github/workflows/deploy-dev.yml | 3 ++- .github/workflows/deploy.yml | 3 ++- app/hooks/useChat.ts | 4 +--- app/routes/chat.log.ts | 1 + remix.env.d.ts | 4 +++- wrangler.toml.template | 3 ++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 271ea4b8..8d51c6c1 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -25,7 +25,8 @@ jobs: | sed s/{CODA_INCOMING_TOKEN}/${{ secrets.CODA_INCOMING_TOKEN }}/ \ | sed s/{CODA_WRITES_TOKEN}/${{ secrets.CODA_WRITES_TOKEN }}/ \ | sed s/{GOOGLE_ANALYTICS_ID}/${{ secrets.GOOGLE_ANALYTICS_ID }}/ \ - | sed s/{DISCORD_LOGGING_URL}/${{ secrets.DISCORD_LOGGING_URL }}/ \ + | sed s/{DISCORD_LOGGING_CHANNEL_ID}/${{ secrets.DISCORD_LOGGING_CHANNEL_ID }}/ \ + | sed s/{DISCORD_LOGGING_TOKEN}/${{ secrets.DISCORD_LOGGING_TOKEN }}/ \ > wrangler.toml npm ci npm run deploy diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 108ff512..a9031a90 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,7 +24,8 @@ jobs: | sed s/{CODA_INCOMING_TOKEN}/${{ secrets.CODA_INCOMING_TOKEN }}/ \ | sed s/{CODA_WRITES_TOKEN}/${{ secrets.CODA_WRITES_TOKEN }}/ \ | sed s/{GOOGLE_ANALYTICS_ID}/${{ secrets.GOOGLE_ANALYTICS_ID }}/ \ - | sed s/{DISCORD_LOGGING_URL}/${{ secrets.DISCORD_LOGGING_URL }}/ \ + | sed s/{DISCORD_LOGGING_CHANNEL_ID}/${{ secrets.DISCORD_LOGGING_CHANNEL_ID }}/ \ + | sed s/{DISCORD_LOGGING_TOKEN}/${{ secrets.DISCORD_LOGGING_TOKEN }}/ \ > wrangler.toml npm ci npm run deploy diff --git a/app/hooks/useChat.ts b/app/hooks/useChat.ts index 69747950..d66216a3 100644 --- a/app/hooks/useChat.ts +++ b/app/hooks/useChat.ts @@ -1,5 +1,3 @@ -export const CHATBOT_URL = 'https://chat.stampy.ai:8443/chat' - export type Citation = { title: string authors: string[] @@ -250,7 +248,7 @@ const fetchLLM = async ( controller: AbortController, settings?: ChatSettings ): Promise => - fetch(CHATBOT_URL, { + fetch(`${CHATBOT_URL}`, { signal: controller.signal, method: 'POST', cache: 'no-cache', diff --git a/app/routes/chat.log.ts b/app/routes/chat.log.ts index d98dd439..55e6c4fe 100644 --- a/app/routes/chat.log.ts +++ b/app/routes/chat.log.ts @@ -43,6 +43,7 @@ export const action = async ({request}: ActionFunctionArgs) => { .join('\n') formData.append('payload_json', JSON.stringify({content: `Chat feedback:\n${info}`})) + const DISCORD_LOGGING_URL = `https://discord.com/api/webhooks/${DISCORD_LOGGING_CHANNEL_ID}/${DISCORD_LOGGING_TOKEN}` const response = await fetch(`${DISCORD_LOGGING_URL}`, {method: 'POST', body: formData}) if (!response.ok) { throw new Error(`Failed to post message: ${response.status} ${response.statusText}`) diff --git a/remix.env.d.ts b/remix.env.d.ts index 310f8f42..d6850c57 100644 --- a/remix.env.d.ts +++ b/remix.env.d.ts @@ -9,5 +9,7 @@ declare const CODA_INCOMING_TOKEN: string declare const CODA_WRITES_TOKEN: string declare const NLP_SEARCH_ENDPOINT: string declare const ALLOW_ORIGINS: string +declare const CHATBOT_URL: string declare const GOOGLE_ANALYTICS_ID: string -declare const DISCORD_LOGGING_URL: string +declare const DISCORD_LOGGING_CHANNEL_ID: string +declare const DISCORD_LOGGING_TOKEN: string diff --git a/wrangler.toml.template b/wrangler.toml.template index 30df39c4..1ff813c1 100644 --- a/wrangler.toml.template +++ b/wrangler.toml.template @@ -22,4 +22,5 @@ CODA_WRITES_TOKEN = "{CODA_WRITES_TOKEN}" NLP_SEARCH_ENDPOINT = "https://stampy-nlp-t6p37v2uia-uw.a.run.app/" ALLOW_ORIGINS = "https://chat.aisafety.info" GOOGLE_ANALYTICS_ID = "{GOOGLE_ANALYTICS_ID}" -DISCORD_LOGGING_URL = "{DISCORD_LOGGING_URL}" \ No newline at end of file +DISCORD_LOGGING_CHANNEL_ID = "{DISCORD_LOGGING_CHANNEL_ID}" +DISCORD_LOGGING_TOKEN = "{DISCORD_LOGGING_TOKEN}" \ No newline at end of file