Skip to content

Commit

Permalink
fix discord logging env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed May 4, 2024
1 parent f6bc965 commit f7889ba
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions app/hooks/useChat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export const CHATBOT_URL = 'https://chat.stampy.ai:8443/chat'

export type Citation = {
title: string
authors: string[]
Expand Down Expand Up @@ -250,7 +248,7 @@ const fetchLLM = async (
controller: AbortController,
settings?: ChatSettings
): Promise<Response | void> =>
fetch(CHATBOT_URL, {
fetch(`${CHATBOT_URL}`, {
signal: controller.signal,
method: 'POST',
cache: 'no-cache',
Expand Down
1 change: 1 addition & 0 deletions app/routes/chat.log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
4 changes: 3 additions & 1 deletion remix.env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion wrangler.toml.template
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
DISCORD_LOGGING_CHANNEL_ID = "{DISCORD_LOGGING_CHANNEL_ID}"
DISCORD_LOGGING_TOKEN = "{DISCORD_LOGGING_TOKEN}"

0 comments on commit f7889ba

Please sign in to comment.