Skip to content

Commit

Permalink
Upgrade Dependencies and GPT-4 (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinejaussoin authored Jul 18, 2023
1 parent 103de33 commit d4b7d42
Show file tree
Hide file tree
Showing 21 changed files with 3,038 additions and 2,620 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ jobs:
- run: yarn
- run: yarn lint
- run: yarn build
test-docs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./docs
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: yarn
- run: yarn typecheck
- run: yarn build
52 changes: 26 additions & 26 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@sendgrid/mail": "7.7.0",
"@sentry/node": "7.52.1",
"@sentry/node": "7.59.2",
"@types/bcryptjs": "2.4.2",
"@types/connect-redis": "0.0.20",
"@types/cookie-parser": "^1.4.3",
Expand All @@ -31,10 +31,10 @@
"@types/express-mung": "0.5.2",
"@types/express-rate-limit": "6.0.0",
"@types/express-session": "1.17.4",
"@types/jest": "29.5.1",
"@types/lodash": "4.14.194",
"@types/lodash-es": "^4.17.7",
"@types/node": "18.11.19",
"@types/jest": "29.5.3",
"@types/lodash": "4.14.195",
"@types/lodash-es": "^4.17.8",
"@types/node": "20.4.2",
"@types/node-fetch": "2.6.4",
"@types/nodemailer": "6.4.8",
"@types/passport": "1.0.11",
Expand All @@ -46,60 +46,60 @@
"@types/request": "^2.48.8",
"@types/shortid": "0.0.29",
"@types/socket.io-redis": "3.0.0",
"@types/uuid": "9.0.1",
"@typescript-eslint/eslint-plugin": "5.59.6",
"@typescript-eslint/parser": "5.59.6",
"@types/uuid": "9.0.2",
"@typescript-eslint/eslint-plugin": "6.1.0",
"@typescript-eslint/parser": "6.1.0",
"bcryptjs": "2.4.3",
"chalk": "5.2.0",
"chalk-template": "^1.0.0",
"chalk": "5.3.0",
"chalk-template": "^1.1.0",
"connect-redis": "6.1.3",
"cookie-parser": "^1.4.6",
"copyfiles": "2.4.1",
"crypto-js": "4.1.1",
"date-fns": "2.30.0",
"dotenv": "16.0.3",
"eslint": "8.41.0",
"dotenv": "16.3.1",
"eslint": "8.45.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-prettier": "5.0.0",
"express": "4.18.2",
"express-mung": "0.5.1",
"express-rate-limit": "6.7.0",
"express-rate-limit": "6.7.1",
"express-session": "1.17.3",
"freemail": "1.7.0",
"handlebars": "4.7.7",
"jest": "29.5.0",
"jest": "29.6.1",
"lexorank": "1.0.5",
"lodash": "4.17.21",
"lodash-es": "^4.17.21",
"moment": "2.29.4",
"node-fetch": "3.3.1",
"nodemailer": "6.9.2",
"nodemon": "2.0.22",
"openai": "^3.2.1",
"nodemailer": "6.9.3",
"nodemon": "3.0.1",
"openai": "^3.3.0",
"passport": "0.5.0",
"passport-github2": "0.1.12",
"passport-google-oauth20": "2.0.0",
"passport-local": "1.0.0",
"passport-microsoft": "1.0.0",
"passport-okta-oauth20": "1.1.0",
"passport-slack-oauth2": "1.1.1",
"passport-slack-oauth2": "1.2.0",
"passport-twitter": "^1.0.4",
"pg": "8.11.0",
"prettier": "2.8.8",
"pg": "8.11.1",
"prettier": "3.0.0",
"rate-limiter-flexible": "2.4.1",
"redis": "3.1.2",
"request": "^2.88.2",
"rimraf": "5.0.1",
"scripty": "^2.1.1",
"shortid": "2.2.16",
"socket.io": "4.6.1",
"socket.io": "4.7.1",
"socket.io-redis": "6.1.1",
"stripe": "12.6.0",
"ts-jest": "29.1.0",
"stripe": "12.13.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typeorm": "0.3.16",
"typeorm": "0.3.17",
"typeorm-naming-strategies": "4.1.0",
"typescript": "5.0.4",
"typescript": "5.1.6",
"unique-names-generator": "^4.7.1",
"uuid": "9.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion backend/src/ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function dialog(
const chat = await getAiChatSession(chatId, user, systemMessage);
const api = new OpenAIApi(configure());
const response = await api.createChatCompletion({
model: 'gpt-3.5-turbo',
model: 'gpt-4',
messages: [systemMessage, ...messages],
});
const answer = response.data.choices[0].message!;
Expand Down
4 changes: 2 additions & 2 deletions backend/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ export type AdminStats = {
clients: number;
};

export type CoachRole = 'user' | 'assistant' | 'system';
export type CoachRole = 'user' | 'assistant' | 'system' | 'function';

export type CoachMessage = {
role: CoachRole;
content: string;
content?: string;
};

export type TrackingEvent =
Expand Down
7 changes: 5 additions & 2 deletions backend/src/db/actions/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function getAiChatSession(
return chat;
}
const user = await getUser(userView.id);
if (user) {
if (user && systemMessage.content) {
const newChat = new AiChatEntity(id, user);
await repository.save(newChat);
const messageRepository = manager.withRepository(AiChatMessageRepository);
Expand All @@ -46,9 +46,12 @@ export async function getAiChatSession(

export async function recordAiChatMessage(
role: CoachRole,
content: string,
content: string | undefined,
chat: AiChatEntity
): Promise<void> {
if (!content) {
return;
}
return await transaction(async (manager) => {
const repository = manager.withRepository(AiChatMessageRepository);
await repository.save(new AiChatMessageEntity(v4(), chat, content, role));
Expand Down
2 changes: 1 addition & 1 deletion backend/src/db/actions/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function createSession(
...c,
id: v4(),
author: { id: author.id },
} as ColumnDefinition)
}) as ColumnDefinition
)
: [],
},
Expand Down
4 changes: 1 addition & 3 deletions backend/src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,7 @@ export default (io: Server) => {
} catch (rejection) {
// https://stackoverflow.com/questions/22110010/node-socket-io-anything-to-prevent-flooding/23548884
console.error(
chalk`${d()} {red Websocket has been rate limited for user {yellow ${
ids?.identityId
}} and SID {yellow ${sid}}}`
chalk`${d()} {red Websocket has been rate limited for user {yellow ${ids?.identityId}} and SID {yellow ${sid}}}`
);
throttledManualReport('websocket is being throttled', undefined);
socket.emit(RECEIVE_RATE_LIMITED);
Expand Down
Loading

0 comments on commit d4b7d42

Please sign in to comment.