Files
AI/ontology_platform/.env.example

78 lines
3.3 KiB
Plaintext
Raw Normal View History

2026-05-13 19:57:34 +09:00
# Ontology Platform 환경변수 예시
# 실제 값을 채워 `.env`로 복사하여 사용 (`.env`는 .gitignore에 포함됨)
# ─── Phase 0: OntoCast Base ─────────────────────────────────────────
ONTOCAST_WORKING_DIRECTORY=./data/working
Phase 0.7 — Acceptance Gate 자동화 + LM Studio 통합 + OntoCast 버그 수정 - platform/ → ont_platform/ rename Python 내장 platform 모듈과 이름 충돌. numpy/scipy가 platform.machine() 호출 시 우리 패키지를 가져와 AttributeError. ont_platform으로 변경하고 pyproject.toml, ont_platform/**, tests/** import 경로 모두 업데이트. - ont_platform/config.py: lenient LLM builder 추가 LM Studio/vLLM 등 OpenAI-호환 로컬 서버가 임의 모델 식별자(예: deepseek-r1-distill- qwen-7b)를 쓸 수 있도록 OntoCast의 OpenAIModel enum validation을 Pydantic model_construct로 우회. ToolConfig() 생성 시 충돌을 막기 위해 LLM_MODEL_NAME을 잠시 비웠다가 lenient 인스턴스로 교체. - ont_platform/api/deps.py: ToolBox 초기화를 asyncio.to_thread로 격리 LLMTool.create()가 내부에서 asyncio.run()을 부르는데 lifespan/테스트가 이미 async 컨텍스트라 이중 loop 충돌. 별도 스레드에서 sync 생성자 실행. - 테스트 인프라 정비 * tests/integration/test_api_smoke.py: TestClient 구버전 starlette 호환을 위해 lifespan='off' 대신 app.router.lifespan_context = noop 패턴 적용. * tests/unit/test_convert_document.py, test_select_ontology.py: ontocast.agent __init__.py가 re-export한 함수가 서브모듈을 가리는 문제로 sys.modules에서 실제 모듈 객체 직접 추출. * tests/e2e/conftest.py: .env 자동 로드 + provider별 skip 조건 (Ollama는 LLM_API_KEY 불필요). * tests/e2e/test_phase0_full_pipeline.py: provider별 키 분기, HDBSCAN 클러스터링이 동작하도록 fixture 페이로드 16문장으로 확장. - vendored OntoCast 버그 수정 3건 (VENDORED_MODIFICATIONS.md 기록): * agent/render_ontology.py: render_ontology_fresh()의 .format() 호출에 누락된 ontology_prefix 인자 추가 (Bootstrap 단계에서 KeyError: 'ontology_prefix'). * stategraph/node_factories.py: render_ontology/render_facts 노드의 state.model_copy(deep=True)로 budget_tracker가 deep-copy되어 root state의 BudgetTracker가 영원히 0인 채로 남던 버그 수정. 원본 인스턴스 공유로 변경. - 문서 갱신 README.md (Phase 0.7 부분완료 + ont_platform 폴더 이름), docs/phases/PHASE0_ACCEPTANCE_GATE.md (검증 이력 + Ollama/LM Studio 옵션), .env.example (LM Studio/Ollama/OpenAI 세 옵션 명시). 검증 - unit + integration 26/26 통과. - e2e (LM Studio + Qwen3-8B / DeepSeek-R1-Distill-Qwen-7B): 워크플로우 끝까지 실행 + 5번 LLM 호출 + LangGraph 전 노드 traceable 확인. 7-8B 로컬 모델은 strict structured output(Turtle RDF in JSON) 한계로 ontology/facts TTL 자동 생성 부분 성공. 클라우드 LLM 환경에서 재검증 필요. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-05-14 09:05:24 +09:00
# ─── LLM Provider ───────────────────────────────────────────────────
# 셋 중 하나를 골라 주석을 해제. ont_platform/config.py의 lenient 빌더가
# OntoCast OpenAIModel enum 제약을 우회하므로, LM Studio처럼 임의 모델명도
# LLM_MODEL_NAME에 그대로 적으면 된다.
# [옵션 A] LM Studio (현재 기본) — http://127.0.0.1:1234
# LM Studio의 "Developer > Reachable at" 주소를 그대로 LLM_BASE_URL에 입력.
# LLM_MODEL_NAME은 LM Studio가 로드한 모델 식별자와 일치시킨다.
2026-05-13 19:57:34 +09:00
LLM_PROVIDER=openai
Phase 0.7 — Acceptance Gate 자동화 + LM Studio 통합 + OntoCast 버그 수정 - platform/ → ont_platform/ rename Python 내장 platform 모듈과 이름 충돌. numpy/scipy가 platform.machine() 호출 시 우리 패키지를 가져와 AttributeError. ont_platform으로 변경하고 pyproject.toml, ont_platform/**, tests/** import 경로 모두 업데이트. - ont_platform/config.py: lenient LLM builder 추가 LM Studio/vLLM 등 OpenAI-호환 로컬 서버가 임의 모델 식별자(예: deepseek-r1-distill- qwen-7b)를 쓸 수 있도록 OntoCast의 OpenAIModel enum validation을 Pydantic model_construct로 우회. ToolConfig() 생성 시 충돌을 막기 위해 LLM_MODEL_NAME을 잠시 비웠다가 lenient 인스턴스로 교체. - ont_platform/api/deps.py: ToolBox 초기화를 asyncio.to_thread로 격리 LLMTool.create()가 내부에서 asyncio.run()을 부르는데 lifespan/테스트가 이미 async 컨텍스트라 이중 loop 충돌. 별도 스레드에서 sync 생성자 실행. - 테스트 인프라 정비 * tests/integration/test_api_smoke.py: TestClient 구버전 starlette 호환을 위해 lifespan='off' 대신 app.router.lifespan_context = noop 패턴 적용. * tests/unit/test_convert_document.py, test_select_ontology.py: ontocast.agent __init__.py가 re-export한 함수가 서브모듈을 가리는 문제로 sys.modules에서 실제 모듈 객체 직접 추출. * tests/e2e/conftest.py: .env 자동 로드 + provider별 skip 조건 (Ollama는 LLM_API_KEY 불필요). * tests/e2e/test_phase0_full_pipeline.py: provider별 키 분기, HDBSCAN 클러스터링이 동작하도록 fixture 페이로드 16문장으로 확장. - vendored OntoCast 버그 수정 3건 (VENDORED_MODIFICATIONS.md 기록): * agent/render_ontology.py: render_ontology_fresh()의 .format() 호출에 누락된 ontology_prefix 인자 추가 (Bootstrap 단계에서 KeyError: 'ontology_prefix'). * stategraph/node_factories.py: render_ontology/render_facts 노드의 state.model_copy(deep=True)로 budget_tracker가 deep-copy되어 root state의 BudgetTracker가 영원히 0인 채로 남던 버그 수정. 원본 인스턴스 공유로 변경. - 문서 갱신 README.md (Phase 0.7 부분완료 + ont_platform 폴더 이름), docs/phases/PHASE0_ACCEPTANCE_GATE.md (검증 이력 + Ollama/LM Studio 옵션), .env.example (LM Studio/Ollama/OpenAI 세 옵션 명시). 검증 - unit + integration 26/26 통과. - e2e (LM Studio + Qwen3-8B / DeepSeek-R1-Distill-Qwen-7B): 워크플로우 끝까지 실행 + 5번 LLM 호출 + LangGraph 전 노드 traceable 확인. 7-8B 로컬 모델은 strict structured output(Turtle RDF in JSON) 한계로 ontology/facts TTL 자동 생성 부분 성공. 클라우드 LLM 환경에서 재검증 필요. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-05-14 09:05:24 +09:00
LLM_MODEL_NAME=deepseek-r1-distill-qwen-7b
LLM_BASE_URL=http://127.0.0.1:1234/v1
LLM_API_KEY=lm-studio
2026-05-13 19:57:34 +09:00
LLM_TEMPERATURE=0.0
Phase 0.7 — Acceptance Gate 자동화 + LM Studio 통합 + OntoCast 버그 수정 - platform/ → ont_platform/ rename Python 내장 platform 모듈과 이름 충돌. numpy/scipy가 platform.machine() 호출 시 우리 패키지를 가져와 AttributeError. ont_platform으로 변경하고 pyproject.toml, ont_platform/**, tests/** import 경로 모두 업데이트. - ont_platform/config.py: lenient LLM builder 추가 LM Studio/vLLM 등 OpenAI-호환 로컬 서버가 임의 모델 식별자(예: deepseek-r1-distill- qwen-7b)를 쓸 수 있도록 OntoCast의 OpenAIModel enum validation을 Pydantic model_construct로 우회. ToolConfig() 생성 시 충돌을 막기 위해 LLM_MODEL_NAME을 잠시 비웠다가 lenient 인스턴스로 교체. - ont_platform/api/deps.py: ToolBox 초기화를 asyncio.to_thread로 격리 LLMTool.create()가 내부에서 asyncio.run()을 부르는데 lifespan/테스트가 이미 async 컨텍스트라 이중 loop 충돌. 별도 스레드에서 sync 생성자 실행. - 테스트 인프라 정비 * tests/integration/test_api_smoke.py: TestClient 구버전 starlette 호환을 위해 lifespan='off' 대신 app.router.lifespan_context = noop 패턴 적용. * tests/unit/test_convert_document.py, test_select_ontology.py: ontocast.agent __init__.py가 re-export한 함수가 서브모듈을 가리는 문제로 sys.modules에서 실제 모듈 객체 직접 추출. * tests/e2e/conftest.py: .env 자동 로드 + provider별 skip 조건 (Ollama는 LLM_API_KEY 불필요). * tests/e2e/test_phase0_full_pipeline.py: provider별 키 분기, HDBSCAN 클러스터링이 동작하도록 fixture 페이로드 16문장으로 확장. - vendored OntoCast 버그 수정 3건 (VENDORED_MODIFICATIONS.md 기록): * agent/render_ontology.py: render_ontology_fresh()의 .format() 호출에 누락된 ontology_prefix 인자 추가 (Bootstrap 단계에서 KeyError: 'ontology_prefix'). * stategraph/node_factories.py: render_ontology/render_facts 노드의 state.model_copy(deep=True)로 budget_tracker가 deep-copy되어 root state의 BudgetTracker가 영원히 0인 채로 남던 버그 수정. 원본 인스턴스 공유로 변경. - 문서 갱신 README.md (Phase 0.7 부분완료 + ont_platform 폴더 이름), docs/phases/PHASE0_ACCEPTANCE_GATE.md (검증 이력 + Ollama/LM Studio 옵션), .env.example (LM Studio/Ollama/OpenAI 세 옵션 명시). 검증 - unit + integration 26/26 통과. - e2e (LM Studio + Qwen3-8B / DeepSeek-R1-Distill-Qwen-7B): 워크플로우 끝까지 실행 + 5번 LLM 호출 + LangGraph 전 노드 traceable 확인. 7-8B 로컬 모델은 strict structured output(Turtle RDF in JSON) 한계로 ontology/facts TTL 자동 생성 부분 성공. 클라우드 LLM 환경에서 재검증 필요. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-05-14 09:05:24 +09:00
# [옵션 B] Ollama 로컬 (https://ollama.com)
# 사전: `ollama pull qwen2.5` 등
# LLM_PROVIDER=ollama
# LLM_MODEL_NAME=qwen2.5
# LLM_BASE_URL=http://localhost:11434
# LLM_API_KEY=
# LLM_TEMPERATURE=0.0
# [옵션 C] OpenAI 클라우드
# LLM_PROVIDER=openai
# LLM_MODEL_NAME=gpt-4o-mini
# LLM_BASE_URL=
# LLM_API_KEY=sk-...
# LLM_TEMPERATURE=0.0
2026-05-13 19:57:34 +09:00
# ─── Server ─────────────────────────────────────────────────────────
PORT=8000
HOST=0.0.0.0
LOG_LEVEL=info
# ─── Phase 3: Guardrails (Hub/telemetry 비활성화 필수) ──────────────
# 통합설계서 §10 리스크: Guardrails Hub 외부 통신 차단
GUARDRAILS_DISABLE_TRACING=true
GUARDRAILS_DISABLE_HUB=true
# ─── Phase 4: Neo4j ─────────────────────────────────────────────────
NEO4J_URI=bolt://localhost:7687
NEO4J_AUTH=neo4j/changeme
NEO4J_DATABASE=neo4j
# ─── Phase 4: Fuseki (Canonical RDF) ────────────────────────────────
FUSEKI_URI=http://localhost:3030
FUSEKI_AUTH=admin:changeme
FUSEKI_DATASET=facts
FUSEKI_ONTOLOGIES_DATASET=ontologies
# ─── 운영 인프라 ────────────────────────────────────────────────────
# Postgres (메타데이터)
DATABASE_URL=postgresql+asyncpg://platform:changeme@localhost:5432/ontology_platform
# Redis (Job Queue + Cache)
REDIS_URL=redis://localhost:6379/0
# Object Storage (MinIO 로컬 / S3 운영)
S3_ENDPOINT_URL=http://localhost:9000
S3_ACCESS_KEY=minioadmin
S3_SECRET_KEY=minioadmin
S3_BUCKET_RAW=ontology-platform-raw
S3_BUCKET_ARTIFACTS=ontology-platform-artifacts
# ─── 운영 정책 ──────────────────────────────────────────────────────
# robots.txt 준수: strict / respect / ignore
ROBOTS_POLICY=respect
# 일일 LLM 호출 한도 (BudgetTracker)
DAILY_LLM_CALL_LIMIT=10000
DAILY_LLM_TOKEN_LIMIT=10000000