-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
452 additions
and
396 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +0,0 @@ | ||
from fastapi import HTTPException | ||
from fastembed.embedding import DefaultEmbedding | ||
from qdrant_client import QdrantClient | ||
from qdrant_client.http.models import Distance, VectorParams | ||
|
||
|
||
def setup_qdrant_environment(): | ||
# 初始化FastEmbed模型和Qdrant客户端 | ||
fastembed_model = DefaultEmbedding() | ||
qdrant_client = QdrantClient(url="http://localhost:6333") | ||
collection_name = 'test_simi' | ||
|
||
# 检查集合是否存在,如果不存在则创建 | ||
try: | ||
qdrant_client.get_collection(collection_name) | ||
print(f"Collection {collection_name} already exists") | ||
except Exception as e: | ||
# 获取向量维度 | ||
sample_embedding = next(fastembed_model.embed(["Sample text"])) | ||
vector_size = len(sample_embedding) | ||
|
||
# 创建集合 | ||
qdrant_client.create_collection( | ||
collection_name=collection_name, | ||
vectors_config=VectorParams(size=vector_size, | ||
distance=Distance.COSINE), | ||
) | ||
print(f"Created collection: {collection_name}") | ||
return fastembed_model, qdrant_client, collection_name | ||
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
from fastapi.routing import APIRouter | ||
|
||
from infra_ai_service.api.ai_enhance.embedding import \ | ||
router as embedding_router | ||
from infra_ai_service.api.ai_enhance.spec_repair_process import \ | ||
router as spec_repair_process | ||
from infra_ai_service.api.ai_enhance.text_process import \ | ||
router as text_process_router | ||
from infra_ai_service.api.ai_enhance.vector_search import \ | ||
router as vector_search_router | ||
from infra_ai_service.api.ai_enhance.embedding import ( | ||
router as embedding_router, | ||
) | ||
from infra_ai_service.api.ai_enhance.spec_repair_process import ( | ||
router as spec_repair_process, | ||
) | ||
from infra_ai_service.api.ai_enhance.text_process import ( | ||
router as text_process_router, | ||
) | ||
from infra_ai_service.api.ai_enhance.vector_search import ( | ||
router as vector_search_router, | ||
) | ||
|
||
api_router = APIRouter() | ||
api_router.include_router(spec_repair_process, prefix="/spec-repair", | ||
tags=["repair"]) | ||
api_router.include_router( | ||
spec_repair_process, prefix="/spec-repair", tags=["repair"] | ||
) | ||
api_router.include_router(text_process_router, prefix="/text", tags=["text"]) | ||
api_router.include_router(embedding_router, prefix="/embedding", | ||
tags=["embedding"]) | ||
api_router.include_router(vector_search_router, prefix="/search", | ||
tags=["search"]) | ||
api_router.include_router( | ||
embedding_router, prefix="/embedding", tags=["embedding"] | ||
) | ||
api_router.include_router( | ||
vector_search_router, prefix="/search", tags=["search"] | ||
) |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.