From c199aeac7ef42bb4d82397ce5f976ffd733d4604 Mon Sep 17 00:00:00 2001 From: Benjamin Rasmussen Date: Thu, 13 Apr 2023 20:37:02 +0200 Subject: [PATCH] Expand linter. --- .eslintrc | 4 +--- .github/workflows/typescript.yml | 4 ++-- .prettierrc | 2 +- README.md | 1 + chatbot_engine/chatbot.ts | 2 +- package.json | 3 +-- supabase/functions/openaibot/index.ts | 4 ++-- tsconfig.json | 3 +-- 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4ad3acc..7498105 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,9 +1,7 @@ { "root": true, "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint" - ], + "plugins": ["@typescript-eslint"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index 2baad82..a6c394e 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -19,8 +19,8 @@ jobs: - name: Setup Node uses: actions/setup-node@v2 with: - node-version: '16' - cache: 'npm' + node-version: "16" + cache: "npm" cache-dependency-path: ./package-lock.json - name: Cache dependencies diff --git a/.prettierrc b/.prettierrc index 9e26dfe..0967ef4 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/README.md b/README.md index fa3e83f..1f9ef74 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ These summaries are generated by OpenAI, and passed along to future bot prompts. ## to-do - Double-proof that no user data has been shared with Supabase before consent has been given + - (At the moment, temporary data may be stored) - Add more documentation for others to fork this repo and set up their own chatbot. diff --git a/chatbot_engine/chatbot.ts b/chatbot_engine/chatbot.ts index 39ba10f..ecc14b5 100644 --- a/chatbot_engine/chatbot.ts +++ b/chatbot_engine/chatbot.ts @@ -12,7 +12,7 @@ import { callAPI as openAICallAPI } from "./openai.ts"; import { returnResponse, returnError } from "./response.ts"; // Clean up the prompt string, such as removing the bot call name. -function getCleanPrompt(prompt: string, bot_name: string) { +export function getCleanPrompt(prompt: string, bot_name: string) { // If the bot has been initialized by calling it's name, // we'll remove it from the prompt. const bot_user_name = `@**${bot_name}**`; diff --git a/package.json b/package.json index 29bcd90..89bb91c 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,9 @@ "name": "zulip-openai", "version": "1.0.0", "description": "Zulip/OpenAI chatbots, powered by Supabase.", - "main": "index.js", "scripts": { "js:eslint": "eslint './**/*.ts'", - "js:prettier": "prettier './**/*.ts'", + "js:prettier": "prettier './'", "lint": "concurrently 'npm:js:eslint' 'npm:js:prettier -- --check' --raw", "format": "concurrently 'npm:js:eslint -- --fix' 'npm:js:prettier -- --write' --max-processes 1 --raw", "test": "concurrently 'npm:js:lint' 'npm:js:format'" diff --git a/supabase/functions/openaibot/index.ts b/supabase/functions/openaibot/index.ts index f875a15..0dda0d9 100644 --- a/supabase/functions/openaibot/index.ts +++ b/supabase/functions/openaibot/index.ts @@ -11,7 +11,7 @@ serve(async (req) => { prompt = getCleanPrompt(prompt, bot_full_name); - const messages = []; + const messages = [] as any[]; // Treat each line of the prompt as a seperate message. // - If the line is empty, skip it. @@ -19,7 +19,7 @@ serve(async (req) => { // - If the line starts with 'assistant:', treat it as an assistant message. // - Else, we treat it as a user message. const lines = prompt.split("\n"); - lines.forEach((line) => { + lines.forEach((line: string) => { let role = "user"; if (line.startsWith("system:")) { diff --git a/tsconfig.json b/tsconfig.json index 2c63c08..0967ef4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,2 +1 @@ -{ -} +{}