feat(ai): LLM 티어별(Pro/Flash) 엔드포인트 오버라이드 + 모델 비교 벤치 스크립트 - #234
Merged
Merged
Conversation
로컬 LLM(Ollama 등 OpenAI 호환 서버) 검토를 위해, Pro/Flash 가 각자 다른 서버를 쓸 수 있게 한다. 기본값은 비어 있어 기존처럼 두 티어 모두 게이트웨이를 공유 — 동작 변화 없음. - Settings: LLM_PRO_BASE_URL / LLM_PRO_API_KEY / LLM_FLASH_BASE_URL / LLM_FLASH_API_KEY 추가, llm_base_url_for(tier) / llm_api_key_for(tier) 로 11개 ChatOpenAI 생성 지점을 일원화 - base_url 을 오버라이드한 티어는 공용 LLM_API_KEY(학교 게이트웨이 키)를 물려받지 않는다 (다른 서버로 키 유출 방지). 키 없는 로컬 서버는 placeholder 키로 SDK 검증만 통과 - docker-compose / .env.example / docs/environment.md 에 신규 변수 반영 - scripts/llm_bench.py: 운영 프롬프트·파서(질문 풀 생성, 스트리밍 꼬리질문)를 그대로 태워 후보 모델의 성공률·지연·출력 샘플을 JSON 으로 남기는 벤치마크
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
작업 내용
LLM_PRO_BASE_URL/LLM_PRO_API_KEY/LLM_FLASH_BASE_URL/LLM_FLASH_API_KEY추가. 체인 11곳의ChatOpenAI생성을settings.llm_base_url_for(tier)/llm_api_key_for(tier)로 일원화LLM_API_KEY(학교 게이트웨이 키)를 물려받지 않음 — 다른 서버로 키 유출 방지ai/scripts/llm_bench.py: 운영 프롬프트·파서(질문 풀 생성, 스트리밍 꼬리질문) 그대로 후보 모델 비교.env.example/docs/environment.md반영변경 이유 / 배경
로컬 LLM(Ollama) 도입 검토. 꼬리질문(Flash)만 로컬로 돌리고 질문 풀·피드백·PDF 비전(Pro)은 게이트웨이에 두는 식의 부분 전환을 설정만으로 가능하게 한다. 기본값은 비어 있어 운영 동작 변화 없음.
벤치 결과 요약 (ana-server, GTX 1660 Ti 6GB, Ollama num_ctx 8192, 워밍 후)
모든 모델이 JSON/태그 출력 형식은 지켰다(파싱 성공 100%). 품질은 Gemini 우위 — 로컬 모델은 질문 반복·저가치 질문(키 형식/길이)·용어 오역("topic"→"테마")·복합질문 경향.
로컬 전환 시 주의
num_ctx4096 은 질문 풀 프롬프트(샘플만으로 3,113 토큰)에 부족 → 조용히 잘림.PARAMETER num_ctx 8192파생 모델 필요LLM_FLASH_TIMEOUT_SEC=10에 근접. Ollama 기본 keep_alive 5분 후 언로드되면 로드 +4초pdf_vision(스캔 PDF 판독)이 깨짐테스트
test_llm_endpoint_settings.py5건), 전체 399 passed영향 범위
리뷰어 체크포인트
Settings.llm_api_key_for의 키 비상속 규칙🤖 Generated with Claude Code