- LanceDB로 MD 문서 252개 청크 인덱싱 - /api/animal-chat에 벡터 검색 컨텍스트 주입 - 마지막 사용자 메시지로 관련 문서 검색 (top 3) - ChromaDB Windows crash로 LanceDB 채택
22 lines
659 B
Python
22 lines
659 B
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
from dotenv import load_dotenv
|
|
load_dotenv()
|
|
|
|
import chromadb
|
|
|
|
print('1. creating client...', flush=True)
|
|
client = chromadb.PersistentClient(path='./db/chroma_test3')
|
|
print('2. client created', flush=True)
|
|
|
|
# 임베딩 없이 컬렉션 생성
|
|
col = client.get_or_create_collection('test3')
|
|
print('3. collection created (no ef)', flush=True)
|
|
|
|
col.add(ids=['1'], documents=['hello world'], embeddings=[[0.1]*384])
|
|
print('4. document added with manual embedding', flush=True)
|
|
|
|
result = col.query(query_embeddings=[[0.1]*384], n_results=1)
|
|
print(f'5. query result: {len(result["documents"][0])} docs', flush=True)
|
|
print('Done!')
|