From 7dfec47a647254e03f001d03806afe5547dbe592 Mon Sep 17 00:00:00 2001 From: jainefer Date: Sat, 17 Feb 2024 14:23:21 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EB=B9=88=EB=B0=B0=EC=97=B4=20=EC=A3=BC?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .platform/nginx/nginx.conf | 2 ++ src/controllers/summary.controller.js | 18 ++++++++--------- src/dtos/video.dto.js | 29 ++++++++++++++++----------- src/routes/video.route.js | 1 + src/services/chatGPT.service.js | 6 ++++-- src/services/video.service.js | 1 + 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/.platform/nginx/nginx.conf b/.platform/nginx/nginx.conf index 3873382..538e1d8 100644 --- a/.platform/nginx/nginx.conf +++ b/.platform/nginx/nginx.conf @@ -46,6 +46,8 @@ http { proxy_send_timeout 300s; proxy_read_timeout 300s; send_timeout 300s; + proxy_buffers 8 16k; + proxy_buffer_size 32k; } access_log /var/log/nginx/access.log main; diff --git a/src/controllers/summary.controller.js b/src/controllers/summary.controller.js index 632cd79..290e652 100644 --- a/src/controllers/summary.controller.js +++ b/src/controllers/summary.controller.js @@ -14,15 +14,15 @@ export const processVideo = async (req, res) => { try { //사용자에게 입력받을 video ID 변수 - const token = req.cookies['tempToken']; + // const token = req.cookies['tempToken']; const videoUrl=req.query.v ?? ''; console.log(encodeURI(videoUrl)); const videoId = await extractYouTubeVideoId(encodeURI(videoUrl)); - if(!token) { - return res.status(401).send("비정상 접근입니다."); - } + // if(!token) { + // return res.status(401).send("비정상 접근입니다."); + // } const id =videoId; console.log("id",id); @@ -32,7 +32,7 @@ export const processVideo = async (req, res) => { videoTitle=title; }) - const clientId = token; + // const clientId = token; // Object Storage에서 해당 MP3 파일이 존재하는지 확인 const mp3Exists = await checkFileExistsInStorage(process.env.OBJECT_STORAGE_BUCKET_NAME, `${videoId}.mp3`); @@ -41,7 +41,7 @@ export const processVideo = async (req, res) => { if (!mp3Exists) { const audioFilePath = await convertVideoToAudio(videoId); // MP3 파일 변환 await uploadFileToStorage(audioFilePath); // 파일 업로드 후 로컬파일 삭제 - sendProgress(clientId, '음성파일 변환 완료.', 25); + // sendProgress(clientId, '음성파일 변환 완료.', 25); } @@ -51,7 +51,7 @@ export const processVideo = async (req, res) => { if (scriptFileName) { // 스크립트 파일이 이미 존재하면 해당 데이터 사용 const jsonData = await readFileFromObjectStorage(process.env.OBJECT_STORAGE_BUCKET_SUMMARY_NAME, scriptFileName); - sendProgress(clientId, '스크립트 불러오기 완료', 50); + // sendProgress(clientId, '스크립트 불러오기 완료', 50); const scriptText = jsonData.text; const timeStampData=[]; @@ -67,7 +67,7 @@ export const processVideo = async (req, res) => { const summaryResult = await getSummary(scriptText); console.log("요약데이터",summaryResult); - sendProgress(clientId, '요약 불러오기 완료', 75); + // sendProgress(clientId, '요약 불러오기 완료', 75); // const startSummaryIndex = summaryResult.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기 // console.log("찾은 인덱스",startSummaryIndex); // const trimmedSummaryResponse = summaryResult.substring(startSummaryIndex); @@ -75,7 +75,7 @@ export const processVideo = async (req, res) => { console.log("summary json 데이터",summaryData); //gpt 데이터 const gptResponse = await chatGPTCall(scriptText); - sendProgress(clientId, '서비스 완료', 100); + // sendProgress(clientId, '서비스 완료', 100); const startIndex = gptResponse.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기 const trimmedResponse = gptResponse.substring(startIndex); const gptData=JSON.parse(trimmedResponse); diff --git a/src/dtos/video.dto.js b/src/dtos/video.dto.js index 4e10983..69a6a72 100644 --- a/src/dtos/video.dto.js +++ b/src/dtos/video.dto.js @@ -28,20 +28,25 @@ export const updateVideoResponseDTO=(video) =>{ return {"status": video} } export const getSimpleVideoResponseDTO=(video,tag)=>{ - const videoData=[] - console.log("비디오 데이터",video); - console.log("태그 데이터",tag); - for(let i=0;i{ return{"id":data}; diff --git a/src/routes/video.route.js b/src/routes/video.route.js index 78c4b4f..c248e60 100644 --- a/src/routes/video.route.js +++ b/src/routes/video.route.js @@ -6,6 +6,7 @@ export const videoRoute = express.Router(); videoRoute.get('/dummyVideos/unRead',async(req,res)=>{ const result =await getUnReadDummyVideo(req,res); + }) videoRoute.get('/',async(req,res)=>{ diff --git a/src/services/chatGPT.service.js b/src/services/chatGPT.service.js index 40958da..c09689f 100644 --- a/src/services/chatGPT.service.js +++ b/src/services/chatGPT.service.js @@ -89,13 +89,15 @@ export const chatGPTCall = async (scriptText) => { export const getTitle=async(title)=>{ + console.log("유튜브제목",title); try { - const system_prompt='Step 1. Please summarize the title in one sentence when you receive the title. It should be given in Korean. Please give it in this json format'+ + const system_prompt='Step 1. Please summarize the title in one sentence when you receive the title. It should be given in Korean. Please give it in this json format '+ '{'+ '"Title": The original title summarized in one sentence'+ '}' - const prompt=`Run this script from step 1 , Make sure to fulfill the condition given to the system promport, response to korean. original title: ${title}\n ` + const prompt=` Please summarize the title in one sentence when you receive the title. It should be given in Korean. Please give it in this json format + { "title":"original title summary"} original title: ${title}\n ` const response = await axios.post( diff --git a/src/services/video.service.js b/src/services/video.service.js index 6254381..ed329bd 100644 --- a/src/services/video.service.js +++ b/src/services/video.service.js @@ -68,6 +68,7 @@ export const viewSimpleVideo=async(data)=>{ } export const viewRecentVideo=async(data)=>{ + console.log("서비스에서 전달되는 요청정보",data); console.log("123"); const TagData=[];