MakeFrog / TechTalk

AI 면접관과 함께하는 개발자 면접 준비
46 stars 14 forks source link

[공통 / 학습] 프롬프트 로직 개선 + 면접 기능 오류 수정 + 앱 localization 마무리 작업 #115

Closed Xim-ya closed 2 months ago

Xim-ya commented 2 months ago

📝 변경 내용


🔍 상세

1. 프롬프트 로직 개선

final gemini = GenerativeModel(
  model: 'gemini-1.5-pro-001',
  apiKey: Flavor.env.geminiApiKey,
  systemInstruction: Content.system(
    'You are an interviewer, and the user is an applicant for a developer position. Please conduct the conversation naturally, as if you were an interviewer from a real company.',
  ),
  safetySettings: safetySettings,
);

systemInstruction을 조정하여 조금 더 자연스러운 응답을 하도록 변경.

    try {
      gemini.generateContentStream(
        [
          Content.text('''
      You will ask an interview question and verify the correctness of the user's answer.

      The question is related to ${StoredTopics.getById(param.qna.qna.id.getFirstPartOfSpliited)}.
      The question presented is: ${param.question}.
      The correct answer is: ${param.qna.qna.answers.map((str) => '-$str').join(' ')}'
      I answered: "${param.userAnswer}".  

      Based on the correct answer provided, determine whether response is correct by prefixing your response with "[c]" if it is correct, or "[w]" if it is incorrect.
      Provide a technical explanation(don't ask additional question) of up to 120 characters regarding the correctness and quality of the answer.

      If ${param.userAnswer} contains inappropriate or offensive content, respond with "[x]" indicating that the answer is unacceptable. Provide a brief explanation of why the answer is not suitable and how it should be appropriately addressed.

      Please respond in the language corresponding to language code "${AppLocale.currentLocale.languageCode}".
'''),
        ],

2. 생성형 ai 응답과정에서 exception이 떨어졌을 때 예외처리하지 못하는 이슈 수정

       onError: (e) {
          param.checkAnswer.call(answerState: AnswerState.error);
          log('ai 응답 실패 : $e');
        },

....
  ).onDone(() {
        /// 응답이 종료된 이후
        /// 1) Stream 닫기
        /// 2) 응답 진행 상태 초기화
        /// 3) 완료 콜백 메소드 실행
        state = FeedbackProgress.init;
        streamedFeedbackResponse.close().then((_) {
          String? streamedRes = streamedFeedbackResponse.valueOrNull;

          if (streamedRes == null) {
            return;
          } else {
            return param.onFeedBackCompleted(
              formatResponse(streamedFeedbackResponse.value),
            );
          }
        });
      });

3. 생성형 ai 응답과정에서 exception이 떨어졌을 때 예외처리하지 못하는 이슈 수정


```enum AnswerState {
  initial('[i]', ''),
  loading('[l]', ''),
  error('[e]', ''),
  correct('[c]', LocaleKeys.common_responseResult_correct),
  wrong('[w]', LocaleKeys.common_responseResult_incorrect),
  inappropriate('[x]', LocaleKeys.common_responseResult_incorrect); // 기존 코드 ( inappropriate('[i]', ..)
}

👥 리뷰어

@Yellowtoast @yundal8755


📌 기타 사항

Xim-ya commented 2 months ago

확인 감사합니다!

https://github.com/MakeFrog/TechTalk/pull/115/commits/43157a1a67e1a45fdbd6c93b66a4117cafe1da7a 해당 내용 수정하여 반영했습니다 :)