Skip to content

Commit

Permalink
chore: bump openai 4.2.0 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hqwuzhaoyi committed Aug 27, 2023
1 parent f128dc9 commit 2e78b72
Show file tree
Hide file tree
Showing 6 changed files with 2,557 additions and 2,803 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

17
00:02:25,000 --> 00:02:29,000
>> Maine, when you last snarp anything, here.
Maine, when you last snarp anything, here.

18
00:02:29,000 --> 00:02:36,000
Expand All @@ -80,35 +80,35 @@

21
00:02:40,440 --> 00:02:42,440
>> When this is all over, got a refit,
When this is all over, got a refit,

22
00:02:42,440 --> 00:02:44,520
go lights back, reduce your load.

23
00:02:44,520 --> 00:02:47,200
>> It's just some jitters, ain't nothing to worry about.
It's just some jitters, ain't nothing to worry about.

24
00:02:47,200 --> 00:02:50,320
>> You can't keep this up, babe.
You can't keep this up, babe.

25
00:02:50,320 --> 00:02:55,440
>> Fuck that, a little meadow ain't gonna be enough to hurt.
Fuck that, a little meadow ain't gonna be enough to hurt.

26
00:02:55,440 --> 00:02:57,440
>> Maine?
Maine?

27
00:02:57,440 --> 00:02:59,120
>> Maine?
Maine?

28
00:02:59,120 --> 00:03:02,840
>> Fuck off, ain't nobody gonna set my limits but me.
Fuck off, ain't nobody gonna set my limits but me.

29
00:03:02,840 --> 00:03:07,600
Expand All @@ -120,15 +120,15 @@

31
00:03:09,160 --> 00:03:11,560
>> Kiwi's mid dive, can't rush her, you know that.
Kiwi's mid dive, can't rush her, you know that.

32
00:03:11,560 --> 00:03:17,160
[MUSIC]

33
00:03:17,160 --> 00:03:20,160
>> I guess it's harder to break through than I thought it'd be.
I guess it's harder to break through than I thought it'd be.

34
00:03:20,160 --> 00:03:28,160
Expand All @@ -140,27 +140,27 @@

36
00:03:33,160 --> 00:03:34,160
>> Maine.
Maine.

37
00:03:34,160 --> 00:03:36,160
>> Stop, shit, what are you?
Stop, shit, what are you?

38
00:03:36,160 --> 00:03:41,160
>> Hey!
Hey!

39
00:03:41,160 --> 00:03:44,160
>> Kiwi, Maine, Falco.
Kiwi, Maine, Falco.

40
00:03:44,160 --> 00:03:47,160
>> Jesus, you back with us?
Jesus, you back with us?

41
00:03:47,160 --> 00:03:51,160
>> D'Oio, what gives?
D'Oio, what gives?

42
00:03:51,160 --> 00:03:52,160
Expand Down
48 changes: 24 additions & 24 deletions packages/translater/output.srt
Original file line number Diff line number Diff line change
Expand Up @@ -4,102 +4,102 @@

2
00:02:25,000 --> 00:02:29,000
>>缅因州,当你最后一次捕捉任何东西时,就在这里
Maine,你上次在这里打喷嚏

3
00:02:29,000 --> 00:02:36,000
[音乐]

4
00:02:36,000 --> 00:02:38,000
该死的,你在发抖
该死,你在颤抖

5
00:02:38,000 --> 00:02:40,440
所有的铬都会扰乱你的神经
所有那些铬层都在干扰你的神经

6
00:02:40,440 --> 00:02:42,440
>> 当这一切都结束后,进行了改装,
当这一切结束后,进行一次翻新。

7
00:02:42,440 --> 00:02:44,520
走灯回来,减轻你的负担。
重新点亮灯光,减轻你的负担。

8
00:02:44,520 --> 00:02:47,200
>> 这只是一些不安,没什么可担心的
这只是一些紧张感,不用担心

9
00:02:47,200 --> 00:02:50,320
>> 你不能再这样下去了,宝贝
亲爱的,你不能继续这样下去

10
00:02:50,320 --> 00:02:55,440
>> 操,一点草地都不足以伤害
去他的,一个小草地不足以伤害我

11
00:02:55,440 --> 00:02:59,120
>>缅因州?
缅因州?

12
00:02:59,120 --> 00:03:02,840
>> 滚蛋,除了我,没有人能限制我
滚开,没人能限制我,只有我自己能

13
00:03:02,840 --> 00:03:07,600
也许这该死的没有麻烦的路现在不会回来了
也许这该死的远距离没有问题,现在不会退缩

14
00:03:07,600 --> 00:03:09,160
我们他妈的数据在哪里
我们的该死数据在哪里

15
00:03:09,160 --> 00:03:11,560
>> Kiwi 处于中潜状态,不能催促她,你知道的。
凯维正在潜水,不能急着去找她,你知道的。

16
00:03:11,560 --> 00:03:17,160
[音乐]
【音乐】

17
00:03:17,160 --> 00:03:20,160
>>我想突破比我想象的要难
我猜突破比我想象的要难

18
00:03:20,160 --> 00:03:28,160
[音乐]
【音乐】

19
00:03:28,160 --> 00:03:33,160
[声音]
【声音】

20
00:03:33,160 --> 00:03:34,160
>> 缅因州。
缅因州。

21
00:03:34,160 --> 00:03:36,160
>> 停下来,妈的,你是什么
停下来,该死,你是什么东西

22
00:03:36,160 --> 00:03:41,160
>> 嘿!
嘿!

23
00:03:41,160 --> 00:03:44,160
>> 猕猴桃,缅因州,法尔科
奇异果,缅因州,猎鹰

24
00:03:44,160 --> 00:03:47,160
>> 天啊,你回来和我们在一起了吗
耶稣,你回来了吗

25
00:03:47,160 --> 00:03:51,160
>> D'Oio,有什么作用
哎呀,怎么回事

26
00:03:51,160 --> 00:03:52,160
到底发生了什么
到底发生了什么鬼东西


15 changes: 7 additions & 8 deletions packages/translater/src/gpt3.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Configuration, OpenAIApi } from "openai";
import OpenAI from "openai";
import { Translator } from "./types";

export class GPTTranslator implements Translator {
model: OpenAIApi;
model: OpenAI;
baseUrl: string;
apiKey: string;
constructor(params: { baseUrl?: string; apiKey?: string } = {}) {
Expand All @@ -12,11 +12,10 @@ export class GPTTranslator implements Translator {
}

create() {
const configuration = new Configuration({
basePath: this.baseUrl ?? process.env.BASE_URL,
const openai = new OpenAI({
baseURL: this.baseUrl ?? process.env.BASE_URL,
apiKey: this.apiKey ?? process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

this.model = openai;
}
Expand All @@ -36,7 +35,7 @@ export class GPTTranslator implements Translator {

async translate(text, language = "Chinese") {
try {
const completion = await this.model.createChatCompletion({
const completion = await this.model.chat.completions.create({
model: "gpt-3.5-turbo",
temperature: 0.6,
messages: [
Expand All @@ -50,9 +49,9 @@ export class GPTTranslator implements Translator {

console.log(
"translate result: ",
completion.data.choices[0].message.content
completion.choices[0].message.content
);
return completion.data.choices[0].message.content;
return completion.choices[0].message.content;
} catch (error) {
console.log(error);
}
Expand Down
17 changes: 7 additions & 10 deletions packages/translater/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { GPTTranslator } from "./gpt3";
import SubtitleProcessor from "./fileStream";
// import dotenv from "dotenv";
// dotenv.config();
import fs from "fs";
import { parse, map, stringifySync, filter } from "subtitle";

import { resolve } from "path";
import fs from "fs";
import { parse, stringifySync, filter } from "subtitle";

import PQueue from "p-queue";
import { GoogleTranslator } from "./google";
Expand Down Expand Up @@ -210,9 +207,7 @@ class TranslateModel {
}

await delay(delayed);
} catch (error) {

}
} catch (error) {}
});

// Reset the group and text
Expand Down Expand Up @@ -277,8 +272,10 @@ class TranslateModel {
}
}

// const test = new TranslateModel(TranslateType.GOOGLE, {
// googleKey: process.env.GOOGLE_TRANSLATE_API_KEY,
// const test = new TranslateModel(TranslateType.GPT3, {
// // googleKey: process.env.GOOGLE_TRANSLATE_API_KEY,
// gpt3Key: process.env.OPENAI_API_KEY,
// baseUrl: process.env.BASE_URL,
// })
// .translateSrtStreamGroup(
// resolve(__dirname, "../Cyberpunk.Edgerunners.S01E06.DUBBED.1080p.WEBRip.x265-RARBG.srt"),
Expand Down
Loading

0 comments on commit 2e78b72

Please sign in to comment.