Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for docker deploy #15

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.pyc
*.pyo
.git/
16 changes: 0 additions & 16 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,3 @@ SPECBOT_AI_MODEL=gpt-4-0613
REPAIR_PRO_AI_MODEL=claude-3-5-sonnet-20240620
OPENAI_API_KEY=*** Provide your API Key ***
OPENAI_BASE_URL=*** Provide your Base url ***

# 数据库配置
DB_NAME=
DB_USER=
DB_PASSWORD=
DB_HOST=
DB_PORT=

# 模型名称配置
MODEL_NAME=

# 配置项
VECTOR_EXTENSION=
TABLE_NAME=
VECTOR_DIMENSION=
LANGUAGE=
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 使用 openEuler 22.03 基础镜像
FROM openeuler/openeuler:22.03

# 设置工作目录为 /app
WORKDIR /app

# 更新系统并安装必要的软件包
RUN yum update -y && \
yum install -y \
python3 \
python3-pip \
python3-devel \
gcc \
make \
&& yum clean all

# 创建符号链接,仅为 python 创建
RUN ln -s /usr/bin/python3 /usr/bin/python

# 复制 requirements.txt 到容器中
COPY requirements.txt .

# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt

# 复制当前目录下的所有文件到容器中
COPY . .

# 按照模块安装
RUN pip install .

# 暴露容器的8000端口
EXPOSE 8000

# 启动FastAPI应用
CMD ["python", "infra_ai_service/server.py"]
22 changes: 10 additions & 12 deletions README.CN.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
# 注意事项

## 前置条件
- 需要安装qdrant本地服务
```shell
# docker环境准备
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
# 安装
sudo docker run -p 6333:6333 -d --name qdrant qdrant/qdrant
# 测试
curl http://localhost:6333
```
- 需要安装数据库postgresql及其pgvector插件
- 需要新增.env文件,将数据库配置,外部服务配置等添加,并将MODEL_NAME设置为multi-qa-MiniLM-L6-cos-v1

## 本地启动
```shell
Expand All @@ -25,6 +15,14 @@ pytest .
python infra_ai_service/server.py
```

# 容器化部署
```shell
# 构建容器
docker build -t infra_ai_service .
# 运行ai_service服务
docker run -p 8001:8000 -d --name infra_ai_service_imp ai_service

```

## 访问spec-repair API

Expand Down
3 changes: 1 addition & 2 deletions infra_ai_service/api/ai_enhance/embedding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from fastapi import APIRouter

from infra_ai_service.api.ai_enhance.text_process import TextInput
from infra_ai_service.model.model import EmbeddingOutput
from infra_ai_service.model.model import EmbeddingOutput, TextInput
from infra_ai_service.service.embedding_service import create_embedding

router = APIRouter()
Expand Down
11 changes: 0 additions & 11 deletions infra_ai_service/api/ai_enhance/text_process.py

This file was deleted.

6 changes: 2 additions & 4 deletions infra_ai_service/api/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@
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.system.status import router as status_router

api_router = APIRouter()
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(status_router, prefix="/status", tags=["status"])
Empty file.
8 changes: 8 additions & 0 deletions infra_ai_service/api/system/status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from fastapi import APIRouter, Response, status

router = APIRouter()


@router.get("/status/", status_code=status.HTTP_200_OK)
async def status():
return Response(content="", media_type="application/json")
28 changes: 0 additions & 28 deletions infra_ai_service/service/text_service.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ deps =
coverage
{[testenv]deps}
commands =
pytest tests/ --cov=infra_ai_service --cov-report=term-missing
pytest tests/ --cov=infra_ai_service --cov-report=term-missing --disable-warnings
coverage report --fail-under=50
coverage html

Expand Down
Loading