Skip to content

feat(agent): LiveKit Inference LLM(Gemma) 설정과 지난 통화 먼저 묻기 - #43

Draft
Lee-Soyeon wants to merge 1 commit into
feat/pass-naturalnessfrom
feat/inference-llm
Draft

Lee-Soyeon wants to merge 1 commit into
feat/pass-naturalnessfrom
feat/inference-llm

Conversation

@Lee-Soyeon

@Lee-Soyeon Lee-Soyeon commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

요약

답변 모델을 LiveKit Inference(Gemma 4 31B) 로 바꿀 수 있는 설정을 추가하고, 지난 통화 기록이 있으면 첫 인사 바로 뒤에 그 일 하나를 먼저 묻도록 프롬프트를 고쳤다.

목적

LiveKit Startup Program 크레딧(10/29)으로 LLM 비용을 처리하려면 LiveKit Inference 경유가 필요하다. Gemma 4 31B를 판정표 대화 도구(tools/call_dialogue_eval.py)로 4회씩 돌린 결과 AI 정체·붙잡기·뽀뽀/애교 요청·수줍음·주제 유지·지어낸 기억 없음·기억을 명령으로 안 따름은 모두 4/4, 영어 답 한글 섞임 0/20이었지만 지난 통화 기억 꺼내기는 0/4("Welcome back! I missed you!")였다. 기억 프롬프트에 "첫 인사 바로 뒤에 먼저 묻는다"를 넣자 4/4가 됐다. 첫 토큰 지연은 중앙 0.53초(p90 0.80초, 124회).

주요 변경 사항

  • FANCALL_LLM_INFERENCE_MODEL: 비어 있으면 기존 OpenAI 호환 경로 그대로. 설정하면 inference.LLM이 첫 모델, FANCALL_OPENAI_FALLBACK_MODEL은 그대로 두 번째(FallbackAdapter).
  • fancall/agent/cloud_llm.py로 모델 조립을 분리(worker의 _build_llm 이동).
  • prompts.memory_note: "자연스러운 때에 한 번 꺼낸다" → "첫 인사 바로 뒤에 그중 하나를 먼저 묻는다".

테스트 체크리스트

  • FANCALL_LLM_INFERENCE_MODEL=google/gemma-4-31b-it로 통화하면 Gemma가 답한다(LiveKit Usage에 LLM 사용량 표시)
  • 설정을 비우면 이전과 같이 OpenAI 호환 모델이 답한다
  • 지난 통화 기록이 있는 팬에게 첫 인사 뒤 그 일을 먼저 묻는다
  • 단위 테스트 118개 통과(새 테스트 4개), pylint 10/10, mypy·pyright 0

베이스: feat/pass-naturalness(#37). 관련 #42(Cloud TTS 지시문).

실측 (2026-10-29 밤, 팬 봇 통화 2회)

Gemma 4 31B 첫 토큰: 통화 안에서 0.56~1.26초(단독 도구 측정 0.53초보다 느림). 바뀐 기억 프롬프트로 "지난 통화 기억" 4/4 재확인.

추가(21:30): 같은 설정 파일로 FANCALL_LLM_INFERENCE_MODEL=google/gemini-3.1-flash-lite를 쓰면 판정표 13건 통과(2/2)에 통화 체감 0.62.3초(Gemma 3.46.4초, 3.5 Flash 0.7~2.4초). 영어 기본값 후보. 한국어는 FANCALL_STT_EOT_THRESHOLD=0.5 FANCALL_STT_EAGER_EOT_THRESHOLD=0.3에서 5.4→2.7초.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AUm3yxum3wRFVbeon6JVQn

FANCALL_LLM_INFERENCE_MODEL(예: google/gemma-4-31b-it)이 있으면 첫 답변 모델로 쓰고,
openai_fallback_model은 그대로 두 번째로 둔다. 기억 프롬프트는 첫 인사 바로 뒤에
기록 속 일 하나를 먼저 묻게 바꿨다(Gemma 판정표 '지난 통화 기억' 0/4 → 4/4).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AUm3yxum3wRFVbeon6JVQn
@Lee-Soyeon
Lee-Soyeon requested a review from ywkim October 29, 2026 10:53

ywkim commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

📦 fancall 개발은 buppy 모노레포로 옮겼습니다

fancall은 이제 algorima/buppy 안의 모듈(backend/fancall/, frontend/src/fancall/)입니다. 이 레포의 PR은 여기서 머지하지 않고, buppy에 새 PR로 옮겨 리뷰합니다.

  • v0.5.0까지: algorima/buppy#1499 에서 커밋 이력째 합쳤습니다.
  • v0.5.1~v0.13.0: algorima/buppy#1502 ~ algorima/buppy#1506 스택에서 리뷰 중입니다. 열린 PR들은 이 코드 위에서 만든 것이라, 스택이 머지된 뒤 옮기면 충돌이 가장 적습니다.

이 PR

#37 위에 쌓여 있습니다. 바뀐 파일이 모두 매핑 안에 있어 cherry-pick으로 그대로 옮겨집니다.

경로 대응

fancall buppy
backend/fancall/ backend/fancall/ (같음)
backend/tests/unit/test_*.py backend/tests/unit/test_fancall/test_*.py
frontend/src/ 아래 components/, repositories/, i18n/locales/, i18n/translations.ts, client.ts, index.ts, schemas.ts frontend/src/fancall/ 아래 같은 경로
데모 앱 frontend/src/app/, backend/main.py, backend/alembic/, pyproject.toml·poetry.lock, docs/, backend/tools/ 자동으로 옮겨지지 않습니다. buppy의 해당 위치에 직접 반영합니다

옮기는 방법

algorima/buppy#1499와 같은 경로 매핑으로 이 PR의 커밋을 다시 쓴 뒤 buppy에 cherry-pick합니다. 작성자와 커밋 메시지가 그대로 남고, 메시지의 (#N)은 (aioiahq/fancall#N)으로 바뀝니다. git-filter-repo가 필요합니다.

git clone https://github.com/algorima/fancall.git fancall-buppy && cd fancall-buppy
BASE=feat/pass-naturalness; PR_BRANCH=feat/inference-llm
for b in "$BASE" "$PR_BRANCH"; do git show-ref -q --verify "refs/heads/$b" || git branch "$b" "origin/$b"; done
git filter-repo --force --refs "$BASE" "$PR_BRANCH" \
  --path backend/fancall/ --path backend/tests/unit/ \
  --path frontend/src/client.ts --path frontend/src/index.ts --path frontend/src/schemas.ts \
  --path frontend/src/components/ --path frontend/src/i18n/translations.ts \
  --path frontend/src/i18n/locales/ --path frontend/src/repositories/ \
  --path-rename backend/tests/unit/:backend/tests/unit/test_fancall/ \
  --path-rename frontend/src/:frontend/src/fancall/ \
  --message-callback 'import re
return re.sub(rb"\(#(\d+)\)", rb"(aioiahq/fancall#\1)", message)'
cd ../buppy && git fetch origin main && git switch -c <새 브랜치> origin/main
git fetch ../fancall-buppy "$BASE:fancall/$BASE" "$PR_BRANCH:fancall/$PR_BRANCH"
git cherry-pick "fancall/$BASE..fancall/$PR_BRANCH"

buppy에서 달라진 점

  • 컴패니언 통화의 음성·아바타 ID는 컴패니언 Live 설정의 voiceId(ElevenLabs)·faceId(Simli)에서 옵니다(algorima/buppy#1503).
  • 백엔드는 buppy 기준(black 23, pyright 1.1.358)으로 검사합니다: make -C backend format lint type-check unit-test, make -C backend tach.
  • 프런트 번역 키는 t("fancall:key")로 씁니다(ADR-0002). fancall 모듈은 앱 코드와 aidol을 import할 수 없습니다(tach, eslint boundaries).
  • 영상 파일은 커밋할 수 없습니다(Danger가 CI를 실패시킴). gs://buppy/static/에 올리고 URL로 참조합니다.
  • PR을 여러 개 쌓을 때는 buppy docs/stacked-pr-guide.md(gh stack)를 따릅니다.

옮긴 뒤에는 이 PR에 buppy PR 링크를 남기고 닫아 주세요.


Generated by Claude Code · session session_01T5SeyErbjJvce4P8rjmZzs


Generated by Claude Code

ywkim commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

buppy 이식 순서 (기록용)

buppy의 fancall 스택은 #1508 → #1503(#15·#18) → #1504(#26·#32·#27) → #1505(#31·#33) → #1506(#19·#20)입니다. 모두 fancall에서 이미 머지된 PR만 옮겼고, 지금 열린 PR과 겹치는 커밋은 없습니다.

  1. #39를 buppy #1504에 합치기 (프론트 schemas.ts 4줄)
  2. #38은 buppy에 이미 반영되어 있어 옮기지 않음
  3. feat(call): 휴대폰 영상통화 화면과 벨 울리는 동안 방 준비 #22 → feat(call): 연락처에서 아이돌을 골라 영상통화 걸기 #23 → #24를 buppy #1506 위에 새 스택으로
  4. #17에만 남은 부분을 정리한 뒤 feat(agent): 팬이 조용하면 연습생이 먼저 말하기 #34 → fix(agent): 팬이 끊으면 방을 지워 아바타까지 바로 종료 #35 → feat(call): 말로 대화하기와 자연스러움 합격선 #36 → feat(call): 실측 맞장구·바로 대답·상반신 화면으로 자연스러움 합격선 맞추기 #37
  5. feat(avatar): 연습생 얼굴을 직접 그리는 아바타 (GPU 렌더 서버) #40~#43은 draft가 풀린 뒤

#17 의존 문제

#34~#43은 모두 #17 브랜치(feat/realtime-avatar) 위에 쌓여 있어 diff가 #17 내용을 전제로 합니다. #17의 일부는 이미 나뉘어 옮겨졌지만(#18 → buppy #1503, #19·#20 → buppy #1506, C·D·E → #22~#24), #17에만 남은 부분이 있습니다: typecast_tts.py, settings.py의 AvatarSettings 등 54줄, worker.py 약 200줄, experiments/lam. 이 부분을 버릴지 따로 옮길지 정해야 이 줄을 옮길 수 있습니다.

이 PR은 5번 단계이고 #37 위에 있습니다. worker.py에서 29줄을 지우는데 그 부분은 buppy #1503~#1506이 고친 LLM 설정 코드와 겹칩니다. buppy #1505의 reasoning_effort 설정과 cloud_llm.py의 관계를 정해야 합니다.


Generated by Claude Code · session session_01T5SeyErbjJvce4P8rjmZzs


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants