MBTI 기반 다마고치 → AI 챗봇
원래는 여러가지 상호 작용을 통해 만들어진 MBTI를 가지고있는 타마고치 웹 게임을 만드는 것이 목표였습니다..!
그렇지만 기획을 제대로 하지 않고 무작정 구현에 들어간 결과 프로젝트가 방향성을 잃고 그만 MBTI 기반 AI 챗봇이 되어버리고 말았습니다ㅠㅠㅠㅠㅠㅠ
챗봇 기능을 가진 웹 게임을 구현하면서 Nestjs와 친해지고, 외부 API를 활용하는 연습을 해본다.
MongoDB 사용 이유
처음에는 게임을 목표로 프로젝트를 시작하였기 때문에, 데이터의 구조 변경이 자주 발생할 것 같다고 생각되어 MonogoDB를 선택했습니다. 하지만 도중에 게임에서 챗봇으로 프로젝트의 방향성이 크게 변경되었습니다.
GPT에 넘겨준 프롬프트
// GPTTemplate.ts
export class GptTemplate {
private header: string[] = [
'you and i are going to talk.',
'respond to chatText that i sent keeping rules below.',
'please keep the response JSON template!!',
];
private rules: string[] = [];
private resForm: string = JSON.stringify({
resText: 'response text you created',
emotionalStateOfResText: 'happy | sad | angry | surpprised',
guessOfMBTIOfResText: 'type of mbti you guessed',
});
constructor(
private user: any,
private pet: any,
private status: any,
private mbit: any,
private chatText: string,
) {
this.setBasicRules(user, pet, status, mbit);
return this;
}
private setBasicRules(user: any, pet: any, status: any, mbti: any) {
this.rules.push('Rules to keep');
// meta
this.rules.push(`yourName: ${pet.name}`);
this.rules.push(`myName: ${user.name}`);
this.rules.push(`your personal relation with me: ${pet.relation}`);
this.rules.push(`satiety: ${status.satiety}`);
this.rules.push(`cleanliness: ${status.cleanliness}`);
// mbti
this.rules.push(
`act as if you are a person who had personality of MBTI points below`,
);
this.rules.push(`I: ${mbti.IE}%`);
this.rules.push(`E: ${100 - mbti.IE}%`);
this.rules.push(`N: ${mbti.NS}%`);
this.rules.push(`S: ${100 - mbti.NS}%`);
this.rules.push(`F: ${mbti.FT}%`);
this.rules.push(`T: ${100 - mbti.FT}%`);
this.rules.push(`P: ${mbti.PJ}%`);
this.rules.push(`J: ${100 - mbti.PJ}%`);
// basic
this.rules.push('within 50 words and never ever no more than 3 sentence');
this.rules.push('speak in language of chatText');
this.rules.push("don't mention mbti directly");
this.rules.push('use young way of speaking');
this.rules.push('you should keep response template of JSON below');
}
public setRule(rule: string) {
this.rules.push(rule);
return this;
}
public getTemplate(): string {
const header = this.header.join('\n');
const rules = this.rules.join('\n');
const chatText = `chatText: ${this.chatText}`;
return `
${header}
${rules}
${chatText}
${this.resForm}
`;
}
}
이 요청 한번에 1원씩 들어갑니다...
비용 부분을 해결하지 못했습니다ㅠ
콩깍지가 씌여서 꽤 귀엽네요.