Files
AI/ontology_platform/README.md
lasta ec4f9a64f6 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

4.0 KiB

Ontology Platform

범용 온톨로지 구축 플랫폼. OntoCast(RDF 코어) + Crawl4AI(크롤링) + Trafilatura(본문 추출) + Guardrails(LLM 검증) + Neo4j GraphRAG(검색) 통합.

핵심 문서

  • docs/통합설계서.md모든 작업의 기준 문서. 의사결정 근거, 단계별 로드맵, 기능 명세, 어디서 무엇을 가져올지 모두 여기 있음
  • 분석 자료 원본: C:\Users\lasta\MyProject\AI\오픈소스분석자료\ (8개)
  • 외부 소스 원본: C:\Users\lasta\MyProject\AI\참고\ (8개)

빠른 시작

# Python 3.12+ 필요
python --version

# 가상환경 (uv 권장)
uv venv
.venv\Scripts\activate

# 의존성 설치 (Phase별로 점진적 활성화)
uv pip install -e ".[dev]"

# Docker 의존 서비스 기동 (Phase별 점진적)
docker compose up -d fuseki postgres redis  # Phase 0~3
# docker compose up -d neo4j minio          # Phase 4+

현재 진행 Phase

Phase 0 — Base 안정화 (코드 작성 완료, 실 환경 검증 대기)

단계 상태 설명
0.1 완료 OntoCast vendored copy + LICENSE/NOTICE 처리
0.2 완료 select_ontology.py None 인덱스 버그 수정 + 회귀 테스트 4개
0.3 완료 convert_document.py 다중 파일 처리 확장 + 회귀 테스트 7개
0.4 완료 Robyn → FastAPI 재작성 (/health, /info, /process, /flush)
0.5 완료 Pydantic Settings 정리 (filesystem 모드 강제) + 테스트 5개
0.6 완료 통합 테스트(10개) + E2E 테스트(marker 분리) 작성
0.7 🟡 부분완료 Gate #2/#4 (unit 16/16, integration 10/10 통과). #1/#3 e2e 대기 (PHASE0_ACCEPTANCE_GATE.md)

Next: Acceptance Gate 0를 통과한 후 PHASE1_NEXT_STEPS.md로 진행.

Phase 진행 규칙

  1. 통합설계서 §0 사용 규칙을 반드시 준수. 본 README와 충돌 시 통합설계서가 우선.
  2. 이전 Phase의 Acceptance Gate를 통과하기 전까지 다음 Phase로 진행 금지.
  3. "그대로 사용" 모듈은 수정 금지 (통합설계서 §9 Module Map 참조).
  4. PR 설명에 어느 분석 자료의 어느 절을 근거로 했는지 명시.

폴더 구조

ontology_platform/
├── docs/
│   ├── 통합설계서.md            ← 최우선 문서
│   └── phases/                  ← Phase별 작업 로그
├── vendored/
│   └── ontocast/                ← Phase 0.1에서 추가
├── ont_platform/                ← 우리가 작성하는 코드 (※ Python 내장 `platform` 모듈과 이름 충돌을 피하기 위해 `platform/`에서 변경됨)
│   ├── api/                     ← Phase 0.4 (FastAPI)
│   ├── core/
│   │   ├── extractors/          ← Phase 1 (Trafilatura)
│   │   ├── crawler/             ← Phase 2 (Crawl4AI)
│   │   ├── validation/          ← Phase 3 (Guardrails)
│   │   └── projection/          ← Phase 4 (Neo4j GraphRAG)
│   ├── workflow/                ← Phase 5 (LangGraph 노드)
│   ├── models/                  ← Pydantic 모델
│   ├── storage/                 ← Fuseki/Neo4j/Postgres 클라이언트
│   └── config.py
├── tests/{unit,integration,e2e}/
├── scripts/                     ← DB 마이그레이션, 초기화
├── pyproject.toml
├── docker-compose.yml           ← Phase 0.4 작업 시 생성
├── .env.example
└── NOTICE                       ← Third-party license 고지

라이선스

본 프로젝트는 다음 Apache 2.0 라이선스 컴포넌트를 통합한다. 자세한 내용은 NOTICE 참고.

  • OntoCast (Apache 2.0) — vendored
  • Crawl4AI (Apache 2.0) — pip dependency
  • Trafilatura (Apache 2.0) — pip dependency
  • Guardrails (Apache 2.0) — pip dependency
  • Neo4j GraphRAG (Apache 2.0) — pip dependency

본 프로젝트 자체의 라이선스는 추후 결정.