Skip to content

Commit

Permalink
[feat] 로직변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jainefer committed Nov 14, 2024
1 parent 084ab5a commit bf282e2
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 261 deletions.
156 changes: 140 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@distube/ytdl-core": "^4.15.1",
"@ffmpeg-installer/ffmpeg": "^1.1.0",
"@ffprobe-installer/ffprobe": "^2.1.2",
"aws-sdk": "^2.1542.0",
Expand Down Expand Up @@ -41,8 +42,7 @@
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.0",
"uuid": "^9.0.1",
"youtube-mp3-downloader": "^0.7.11",
"ytdl-core": "^4.11.5"
"youtube-mp3-downloader": "^0.7.11"
},
"devDependencies": {
"@babel/cli": "^7.23.4",
Expand Down
22 changes: 12 additions & 10 deletions src/controllers/summary.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// src/controllers/summary.controller.js
import { fineTunningData, getSummary, getTitle } from '../services/chatGPT.service.js';
import { cleanResponse, fineTunningData, getSummary, getTitle } from '../services/chatGPT.service.js';
import { readFileFromObjectStorage } from '../services/storage.service.js';
import { getScriptFileName } from '../services/storage.service.js';
import { chatGPTCall } from '../services/chatGPT.service.js';
Expand Down Expand Up @@ -49,18 +49,20 @@ export const summary = async (req, res) => {
console.log(scriptText);

const summaryResult = await getSummary(scriptText);
//console.log("요약데이터",summaryResult);
console.log("요약데이터",summaryResult);
// const startSummaryIndex = summaryResult.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기
// console.log("찾은 인덱스",startSummaryIndex);
// const trimmedSummaryResponse = summaryResult.substring(startSummaryIndex);
const summaryData=JSON.parse(summaryResult);
console.log("summary json 데이터",summaryData);
// const summaryData=JSON.parse(summaryResult);
console.log("summary json 데이터",summaryResult);
//gpt 데이터
const gptResponse = await chatGPTCall(scriptText);
console.log("gpt받아온 데이터",gptResponse);
const startIndex = gptResponse.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기
const trimmedResponse = gptResponse.substring(startIndex);
const gptData=JSON.parse(trimmedResponse);
const gptData=await cleanResponse(gptResponse);
console.log("가공",gptData)
// const startIndex = gptResponse.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기
// const trimmedResponse = gptResponse.substring(startIndex);
// const gptData=JSON.parse(tempData);



Expand All @@ -71,7 +73,7 @@ export const summary = async (req, res) => {
//맵핑
const data=await timeStampMapping(gptData,timeStampData);
console.log("돌아온 데이터",data);
console.log(summaryData.video_name);
// console.log(summaryResul.video_name);
const tagData=await splitTag(gptData.tag);


Expand All @@ -80,9 +82,9 @@ export const summary = async (req, res) => {
"title":videoTitle,
"youtube_created_at":youtubeDate,
"link":"https://www.youtube.com/embed/"+videoId,
"description":summaryData.video_name[0].name,
"description":summaryResult.video_name.name,
"subheading":data,
"summary":summaryData.Summary,
"summary":summaryResult.Summary,
"tag":tagData
}
res.send(response(status.SUCCESS,{
Expand Down
Loading

0 comments on commit bf282e2

Please sign in to comment.