-
Notifications
You must be signed in to change notification settings - Fork 1
/
app_finetuned.ts
66 lines (56 loc) · 1.86 KB
/
app_finetuned.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import * as socketio from "socket.io";
import * as express from "express";
import * as path from "path";
import GPT_CONFIG from "./gpt-module/config";
import finetuneService from "./gpt-module/fine-tune-service";
import { FineTunedController } from "./src/controller/finetuned.controller";
export class App {
private app: express.Application;
private server: any;
private messageController;
constructor() {
this.app = express();
this.messageController = new FineTunedController();
this.config();
this.routes();
}
private config(): void {
this.app.use(express.json());
this.app.use(express.urlencoded({ extended: false }));
}
private routes(): void {
this.app.use(
"/dashboard",
(_req: express.Request, res: express.Response) => {
res.sendFile(path.join(__dirname, "/src/view/index_finetuned.html"));
}
);
this.app.use("/messages", this.messageController.getRouter());
}
public initSocketIo() {
const socketIo = new socketio.Server(this.server);
socketIo.on("connection", () => {
console.log("SocketIO connection created");
});
this.messageController.setSocketIo(socketIo);
}
public async start(): Promise<void> {
const port = process.env.PORT || 3000;
this.server = this.app.listen(port, async () => {
console.log("Application started on port 3000!");
// step 1
// get file upload by API https://api.openai.com/v1/files
// console.log("Upload fine-tune...");
// await finetuneService.upload(
// `${__dirname}/sourceData/fineTuneData.jsonl`
// );
// step 2
// get fine-tune model by API https://api.openai.com/v1/fine-tunes
// console.log("Create fine-tune...");
// await finetuneService.createFineTune("file-Zpw7NMJ53zEY8f7AJSnCYD7E");
});
this.initSocketIo();
}
}
const app = new App();
app.start();