LLM 호출 규격 전환: 고객사 사내 LLM(FabriX/Gauss) 헤더 지원 (LLM_PROVIDER=fabrix)
- settings: LLM_PROVIDER/LLM_CHAT_PATH/LLM_BODY_MODEL/LLM_JSON_MODE/LLM_MAX_TOKENS, FABRIX_* 3종, llm_enabled() - llm_client: headers()/body() 를 규격별로 구성. fabrix 는 x-openapi-token(Bearer)/x-generative-ai-client/ x-llm-model-id/x-generative-ai-user-email, body model 은 LLM_BODY_MODEL - summarize/ping: 접속 점검 명령 (--show 로 요청만 확인) - docs/llm-provider-plan.md: 계획·.env 값·오류별 조치. 기본값은 openai 라 기존 동작 불변 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
89deb108b0
commit
0f70c0d245
@@ -16,6 +16,22 @@ class Settings(BaseSettings):
|
||||
llm_base_url: str = ""
|
||||
llm_api_key: str = ""
|
||||
llm_model: str = "glm-5.2"
|
||||
# 호출 규격 (docs/llm-provider-plan.md)
|
||||
# openai — Authorization: Bearer <LLM_API_KEY> (OpenRouter 등)
|
||||
# fabrix — 고객사 사내 LLM(FabriX/Gauss). 키 대신 커스텀 헤더 4종 (아래 fabrix_*)
|
||||
llm_provider: str = "openai"
|
||||
# base_url 뒤에 붙일 경로. 고객사 주소가 이미 완성형이면 빈 문자열로 둔다
|
||||
llm_chat_path: str = "/chat/completions"
|
||||
# 요청 body 의 model 값. 비우면 LLM_MODEL. (FabriX 는 body 는 "/mnt/models" 고정, 모델은 헤더가 고름)
|
||||
llm_body_model: str = ""
|
||||
# response_format={"type":"json_object"} 전송 여부. 서버가 400 을 주면 끈다 (파서가 본문에서 JSON 을 뽑는다)
|
||||
llm_json_mode: bool = True
|
||||
# 출력 토큰 상한. 0 이면 보내지 않음 (OpenRouter 는 잔액 견적에 쓰고, 추론 폭주 방어도 됨)
|
||||
llm_max_tokens: int = 0
|
||||
# FabriX 헤더 값 — x-generative-ai-client / x-openapi-token(Bearer 접두는 코드가 붙임) / x-generative-ai-user-email
|
||||
fabrix_client_key: str = ""
|
||||
fabrix_openapi_token: str = ""
|
||||
fabrix_user_email: str = ""
|
||||
# 요약 배치의 동시 LLM 호출 수. DB 쓰기는 메인 스레드에 남기고 호출만 병렬로 돈다.
|
||||
llm_concurrency: int = 4
|
||||
llm_timeout_s: int = 180
|
||||
@@ -53,5 +69,13 @@ class Settings(BaseSettings):
|
||||
wiki_search_backend: str = "pg"
|
||||
qmd_url: str = "http://127.0.0.1:8181"
|
||||
|
||||
def llm_enabled(self) -> bool:
|
||||
"""api 백엔드로 호출할 수 있는 상태인가 — 규격별 필수값이 다 있는지."""
|
||||
if not self.llm_base_url:
|
||||
return False
|
||||
if self.llm_provider == "fabrix":
|
||||
return bool(self.fabrix_client_key and self.fabrix_openapi_token)
|
||||
return bool(self.llm_api_key)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
Reference in New Issue
Block a user