-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code style update: GPT API 관련 공통 기능 모듈화
- Loading branch information
1 parent
a9c5610
commit 27066c0
Showing
9 changed files
with
89 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 프롬프트 및 모델명 가져오기 | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
function loadConfig(fileName) { | ||
const filePath = path.resolve(__dirname, `../key/${fileName}`); | ||
return JSON.parse(fs.readFileSync(filePath, "utf-8")); | ||
} | ||
|
||
const promptData = loadConfig("prompt.json"); | ||
const modelData = loadConfig("model.json"); | ||
|
||
module.exports = { promptData, modelData }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// OpenAI 초기화 및 GPT API 호출 | ||
const OpenAI = require("openai"); | ||
|
||
const openai = new OpenAI({ | ||
api_key: process.env.OPENAI_API_KEY, | ||
}); | ||
|
||
// GPT API 호출 | ||
async function callOpenAI(modelName, messages, maxTokens = 256) { | ||
const response = await openai.chat.completions.create({ | ||
model: modelName, | ||
messages: messages, | ||
temperature: 0.0, | ||
max_tokens: maxTokens, | ||
top_p: 0.0, | ||
frequency_penalty: 0, | ||
presence_penalty: 0, | ||
}); | ||
|
||
return response.choices[0].message.content; | ||
} | ||
|
||
module.exports = { callOpenAI }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters