Skip to content

Commit

Permalink
Expand linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
rasben committed Apr 13, 2023
1 parent 9cb0791 commit c199aea
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 13 deletions.
4 changes: 1 addition & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion chatbot_engine/chatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}**`;
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
4 changes: 2 additions & 2 deletions supabase/functions/openaibot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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.
// - If the line starts with 'system:', treat it as a system message.
// - 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:")) {
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
{
}
{}

0 comments on commit c199aea

Please sign in to comment.