Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade a lot deps #894

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ COPY yarn.lock .
RUN apk add git
RUN npm install -g yarn
COPY . .
RUN yarn install --ignore-optional
RUN yarn install
RUN yarn build
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@turf/helpers": "^6.5.0",
"bcrypt": "^5.0.1",
"body-parser": "^1.20.2",
"chalkercli": "^1.6.4",
"chalkercli": "https://github.com/TurtIeSocks/chalkercli.git",
"chokidar": "^3.5.3",
"compression": "^1.7.4",
"cors": "^2.8.5",
Expand Down Expand Up @@ -137,7 +137,7 @@
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"monaco-editor": "^0.41.0",
"nodemon": "^2.0.22",
"nodemon": "^3.0.2",
"prettier": "^2.8.8",
"rollup-plugin-delete": "^2.0.0",
"vite": "4.3.9",
Expand Down
15 changes: 8 additions & 7 deletions packages/locales/lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
/* eslint-disable guard-for-in */

require('dotenv').config()
const { Configuration, OpenAIApi } = require('openai')
const { OpenAI } = require('openai')

const { log, HELPERS } = require('@rm/logger')

const { readAndParseJson, readLocaleDirectory, writeAll } = require('./utils')

const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
})
const openai = new OpenAIApi(configuration)
const openAI = process.env.OPENAI_API_KEY
? new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
})
: null

/**
* @typedef {Record<string, string>} I18nObject
Expand Down Expand Up @@ -101,7 +102,7 @@ function matchJSON(str) {
* @returns
*/
async function sendToGPT(locale, missingKeys) {
return openai.createChatCompletion({
return openAI.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [
{
Expand Down Expand Up @@ -157,7 +158,7 @@ async function generate() {
const result = await Promise.all(
chunks.map(async (x) => {
const raw = await sendToGPT(locale, x)
const { content } = raw.data.choices[0].message
const { content } = raw.choices[0].message
const clean = matchJSON(`${content}`)
try {
return JSON.parse(clean)
Expand Down
2 changes: 1 addition & 1 deletion packages/locales/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"@rm/config": "*",
"@rm/logger": "*",
"dotenv": "^16.3.1",
"openai": "^3.3.0"
"openai": "^4.24.1"
}
}
Loading