MBTI 챗봇 회고록

GGAE99·2023년 8월 1일
0

회고록

목록 보기
1/1
post-thumbnail

서비스 개요, 기능 설명

MBTI 기반 다마고치 → AI 챗봇

원래는 여러가지 상호 작용을 통해 만들어진 MBTI를 가지고있는 타마고치 웹 게임을 만드는 것이 목표였습니다..!

그렇지만 기획을 제대로 하지 않고 무작정 구현에 들어간 결과 프로젝트가 방향성을 잃고 그만 MBTI 기반 AI 챗봇이 되어버리고 말았습니다ㅠㅠㅠㅠㅠㅠ

목표

챗봇 기능을 가진 웹 게임을 구현하면서 Nestjs와 친해지고, 외부 API를 활용하는 연습을 해본다.

사용 기술 스택

  • FE: NextJS, Redux, Tailwind, Axios
  • BE: NestJS, MongoDB, Mongoose, OpenAI, Papago, Joi

MongoDB 사용 이유
처음에는 게임을 목표로 프로젝트를 시작하였기 때문에, 데이터의 구조 변경이 자주 발생할 것 같다고 생각되어 MonogoDB를 선택했습니다. 하지만 도중에 게임에서 챗봇으로 프로젝트의 방향성이 크게 변경되었습니다.

트러블 슈팅

  • GPT 비용
    • 맥락을 부여하기 위해서 작성한 프롬프트의 양이 많아져서 토큰사용양이 급증하고 비용이 예상했던 정도보다 너무 부담스러워졌습니다.
    • 효율적인 프롬프트 작성의 필요성을 느꼈습니다.
  • 기획의 잦은 변경
    • 처음 프로젝트를 시작할 때 충분히 조사와 검증을 하지 않고 시작해서 중간에 프로젝트 방향을 바꾸게 되었습니다.
    • 백지에서 구현해 나가는 것보다 이미 존재하는 구조속에서 수정해 나가는 것이 더 큰 공수가 들어간 다는 것을 느끼게 되었습니다.

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원씩 들어갑니다...
비용 부분을 해결하지 못했습니다ㅠ

새롭게 배운 부분

  • NestJS 기본사용법
  • Chat GPT API 연결 및 활용
    • GptTemplate 클래스를 통한 프롬프트 생성
  • Papago 번역 API 연결 및 활용
  • MongoDB, Mongoose 사용
  • 프로젝트를 시작하는 단계에서 기획의 중요성을 많이 느꼈습니다.
  • 단순한 프로젝트였지만 GPT 기반의 서비스를 실재로 구현할 경우 비용적 측면을 정확히 계산할 필요성을 느꼈습니다. 구현할 수 있다고 하더라도 비용의 문제가 발생해 수익성을 보장할 수 없다면, 실제 서비스는 해야할 이유가 없기 때문입니다. 따라서 서비스의 경제성을 고려한 기술 선택이 중요하다고 생각하게 되었습니다.
  • 기획의 변경은 비즈니스 상황에 따라서 결정되는 부분이므로 개발 과정에서 변경이 일어나는 것은 피할 수 없을 것 입니다. 따라서 변경사항이 발생했을 경우 수정 및 기능 추가가 확장성 있도록 구조를 잡으면서 개발을 해나가는 것이 중요하다고 생각하게 되었습니다.

아쉬웠던 부분

  • 프로젝트를 완결성있게 마무리하지 못한 부분이 아쉬웠습니다.
  • 프롬프트 생성과 관련해서 베스트 practice가 무엇일지 지금도 알 수 없었습니다.

총평

  • 학습목적 프로젝트여서 제대로된 기획 없이 배운 기능 및 기술을 최대한 적용하다보니 큰 기획의 선회가 발생했습니다.
  • 작은 프로젝트임에도 불구하고 많은 인지적, 시간적 비용이 발생했습니다.
  • 실제 비즈니스에서도 비즈니스 상황에 따라 서비스 방향성이 바뀌는 경우가 있을 텐데, 회사 차원에서 적지 않은 비용이 발생할 것이라고 예상되었습니다. 따라서 의사결정의 신중함과 초기 개발 단계에서 변경 가능성을 염두해둔 확장성 있는 구조의 확립이 중요하다고 생각하게 되었습니다.
  • 학습 및 재미용 프로젝트였지만 많은 것을 배울 수 있었습니다!!


콩깍지가 씌여서 꽤 귀엽네요.

0개의 댓글