diff --git a/package-lock.json b/package-lock.json index 68c836b..0105256 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "multer-s3": "^2.10.0", "mysql2": "^3.7.0", "nodemailer": "^6.9.8", - "openai": "^4.26.0", + "openai": "^4.28.0", "redis": "^4.6.12", "solapi": "^5.2.4", "swagger-cli": "^4.0.4", diff --git a/package.json b/package.json index ee24188..209b20e 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "multer-s3": "^2.10.0", "mysql2": "^3.7.0", "nodemailer": "^6.9.8", - "openai": "^4.26.0", + "openai": "^4.28.0", "redis": "^4.6.12", "solapi": "^5.2.4", "swagger-cli": "^4.0.4", diff --git a/src/controllers/summary.controller.js b/src/controllers/summary.controller.js index ec39c05..2a2d3d9 100644 --- a/src/controllers/summary.controller.js +++ b/src/controllers/summary.controller.js @@ -1,5 +1,5 @@ // src/controllers/summary.controller.js -import { getSummary, getTitle } from '../services/chatGPT.service.js'; +import { 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'; @@ -43,6 +43,7 @@ export const summary = async (req, res) => { }) } console.log("시간데이터 있는 데이터",timeStampData); + // const tempResult=await fineTunningData(JSON.stringify(timeStampData)); console.log(scriptText); const summaryResult = await getSummary(scriptText); @@ -54,12 +55,12 @@ export const summary = async (req, res) => { console.log("summary json 데이터",summaryData); //gpt 데이터 const gptResponse = await chatGPTCall(scriptText); - + console.log("gpt받아온 데이터",gptResponse); const startIndex = gptResponse.indexOf('{'); // 첫 번째 '{'의 인덱스 찾기 const trimmedResponse = gptResponse.substring(startIndex); const gptData=JSON.parse(trimmedResponse); - console.log(gptResponse); + //유튜브 제목 요약 const titleData=await getTitle(videoTitle); diff --git a/src/services/chatGPT.service.js b/src/services/chatGPT.service.js index 0e1867e..5a23941 100644 --- a/src/services/chatGPT.service.js +++ b/src/services/chatGPT.service.js @@ -1,6 +1,7 @@ // src/services/chatGPTService.js import axios from 'axios'; import dotenv from 'dotenv'; +import OpenAI from 'openai'; dotenv.config(); @@ -45,7 +46,7 @@ export const chatGPTCall = async (scriptText) => { const prompt = `Run this script from step 1 , Make sure to fulfill the condition given to the system promport. original script: ${scriptText}\n ` ; - + console.log("프롬프트",prompt); const response = await axios.post( OPENAI_API_URL, { @@ -205,3 +206,21 @@ export const getSummary = async (scriptText) => { throw error; } }; + +export const fineTunningData = async (script)=>{ + try { + + const openai = new OpenAI({ + apiKey: OPENAI_API_KEY + }) + + const result= await openai.completions.create({ + prompt: script, + model:"ft:davinci-002:personal::8sC2Qcki", + max_tokens :8000 + }) + console.log("스크립트",result); + } catch (error) { + console.log(error); + } +} \ No newline at end of file