@kangthink/q-engine
Version:
A question-answer generation engine that stimulates thinking
82 lines • 3.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PromptManager = void 0;
const types_1 = require("../types");
class PromptManager {
constructor() {
this.prompts = new Map();
// 브라우저에서는 기본 프롬프트만 사용
this.loadDefaultPrompts();
}
// 브라우저에서는 파일 시스템 접근 불가, 기본 프롬프트만 사용
async loadFromFile(_filePath) {
console.warn('File loading is not supported in browser environment');
}
async loadFromDirectory(_directory) {
console.warn('Directory loading is not supported in browser environment');
}
// JSON 객체로 프롬프트 추가 (브라우저에서 동적 로딩용)
loadFromObject(templates) {
templates.forEach(template => this.addPrompt(template));
}
addPrompt(template) {
const key = this.generateKey(template.mode, template.id);
this.prompts.set(key, template);
}
getPrompt(mode, id) {
if (id) {
return this.prompts.get(this.generateKey(mode, id));
}
// If no specific id, return the first prompt for the mode
for (const [, prompt] of this.prompts.entries()) {
if (prompt.mode === mode) {
return prompt;
}
}
return undefined;
}
getDefaultPrompt(mode) {
const prompt = this.getPrompt(mode, 'default');
if (!prompt) {
throw new Error(`No default prompt found for mode: ${mode}`);
}
return prompt;
}
generateKey(mode, id) {
return `${mode}:${id}`;
}
loadDefaultPrompts() {
const defaultPrompts = this.getDefaultPrompts();
defaultPrompts.forEach(prompt => this.addPrompt(prompt));
}
getDefaultPrompts() {
return [
{
id: 'default',
mode: types_1.TransformMode.FIVE_W_ONE_H,
template: `"{{content}}"에 대해 육하원칙(누가, 무엇을, 언제, 어디서, 왜, 어떻게)을 적용한 {{targetType}}{{count}}개를 생성하세요. 각 줄에 하나씩 질문만 작성하세요.`,
variables: ['content', 'targetType', 'count'],
},
{
id: 'default',
mode: types_1.TransformMode.SOCRATIC,
template: `"{{content}}"에 대해 소크라테스식 {{targetType}}{{count}}개를 생성하세요. 가정을 의심하고 더 깊은 사고를 유도하는 질문만 각 줄에 하나씩 작성하세요.`,
variables: ['content', 'targetType', 'count'],
},
{
id: 'default',
mode: types_1.TransformMode.MATRIX,
template: `"{{content}}"에 대해 Matrix 방법(레벨{{level}}, {{direction}})으로 {{targetType}}{{count}}개를 생성하세요. {{levelDescription}} {{directionDescription}} 질문만 각 줄에 하나씩 작성하세요.`,
variables: ['content', 'targetType', 'count', 'level', 'levelDescription', 'direction', 'directionDescription'],
},
{
id: 'default',
mode: types_1.TransformMode.SCIENTIFIC,
template: `"{{content}}"에 대해 과학적 질문 방법(Scientific Method)으로 {{targetType}}{{count}}개를 생성하세요. 관찰(observation), 가설(hypothesis), 변수(variable), 실험(experiment), 분석(analysis), 결론(conclusion)의 각 단계에 해당하는 질문만, 각 줄에 하나씩 작성하세요.`,
variables: ['content', 'targetType', 'count'],
},
];
}
}
exports.PromptManager = PromptManager;
//# sourceMappingURL=PromptManager.browser.js.map