forked from jlcoo/infraAIService
-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
80 additions
and
70 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -142,3 +142,4 @@ dmypy.json | |
cython_debug/ | ||
|
||
.python-version | ||
infra_ai_service.egg-info |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
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.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.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(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
from fastapi import HTTPException | ||
from fastembed.embedding import DefaultEmbedding | ||
from qdrant_client import QdrantClient | ||
from qdrant_client.http.models import Distance, VectorParams | ||
# infra_ai_service/common/utils.py | ||
|
||
from infra_ai_service.config.config import settings | ||
|
||
|
||
async def setup_database(pool): | ||
async with pool.connection() as conn: | ||
await conn.execute("CREATE EXTENSION IF NOT EXISTS vector") | ||
# 创建扩展名,使用配置项 | ||
await conn.execute( | ||
""" | ||
CREATE TABLE IF NOT EXISTS documents ( | ||
f"CREATE EXTENSION IF NOT EXISTS {settings.VECTOR_EXTENSION}" | ||
) | ||
# 创建表,使用配置项 | ||
await conn.execute( | ||
f""" | ||
CREATE TABLE IF NOT EXISTS {settings.TABLE_NAME} ( | ||
id bigserial PRIMARY KEY, | ||
content text, | ||
embedding vector(384) | ||
embedding vector({settings.VECTOR_DIMENSION}) | ||
) | ||
""" | ||
""" | ||
) | ||
# 创建索引,使用配置项 | ||
await conn.execute( | ||
f""" | ||
CREATE INDEX IF NOT EXISTS {settings.TABLE_NAME}_content_idx | ||
ON {settings.TABLE_NAME} | ||
USING GIN (to_tsvector('{settings.LANGUAGE}', content)) | ||
""" | ||
CREATE INDEX IF NOT EXISTS documents_content_idx | ||
ON documents USING GIN (to_tsvector('english', content)) | ||
""" | ||
) |
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
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
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