迁移服务器;分开开发端与生产端;去除废弃接口;对象存储、Kong网关使用SSL;修改所有使用内网地址的代码;切换域名;更新Ktor、ws-scrcpy启动服务;修改Prometheus配置;
This commit is contained in:
Generated
+3
@@ -6,4 +6,7 @@
|
||||
<option name="sdkName" value="bbit_ai_lab" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="bbit_ai_lab" project-jdk-type="Python SDK" />
|
||||
<component name="PyPackaging">
|
||||
<option name="earlyReleasesAsUpgrades" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
+1
-5
@@ -4,7 +4,6 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from routers.Bot import botRouter
|
||||
from routers.Chat import chatRouter
|
||||
from routers.Datasource import reportDataRouter
|
||||
from routers.F8 import f8Router
|
||||
from routers.Knowledge import knowledgeRouter
|
||||
from routers.Public import publicRouter
|
||||
from routers.RabbitMQ import rqRouter
|
||||
@@ -18,8 +17,7 @@ app = FastAPI(title="BBIT_AI")
|
||||
|
||||
origins = [
|
||||
"http://localhost:8090", # Vite dev 默认端口
|
||||
"http://127.0.0.1:5173",
|
||||
"http://s1.ronsunny.cn:8089",
|
||||
"https://ai.ronsunny.cn:8090",
|
||||
"*", # ⚠️ 生产环境不要用
|
||||
]
|
||||
|
||||
@@ -44,8 +42,6 @@ routers = [
|
||||
for r in routers:
|
||||
app.include_router(r, prefix="/llm", tags=["llm"])
|
||||
|
||||
app.include_router(f8Router, prefix="/f8", tags=["f8"])
|
||||
|
||||
app.include_router(publicRouter, prefix="/api/public", tags=["api"])
|
||||
|
||||
MyUtils.async_new_task(mq_pull_analysis)
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
SERVER_PATH_OSS = "s1.ronsunny.cn"
|
||||
|
||||
F8_SERVER_USER_ID = "da33efb9-776a-443b-b1ec-dbbbf08793d7"
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
from langchain_milvus import BM25BuiltInFunction, Milvus
|
||||
from langchain_milvus import Milvus
|
||||
|
||||
from config.llm import llmEmbeddings
|
||||
|
||||
URI = "http://10.10.10.9:19530"
|
||||
URI = "http://ce_milvus:19530"
|
||||
|
||||
knVectorstore = Milvus(
|
||||
embedding_function=llmEmbeddings,
|
||||
@@ -10,12 +11,11 @@ knVectorstore = Milvus(
|
||||
index_params={"index_type": "FLAT", "metric_type": "L2"},
|
||||
consistency_level="Strong",
|
||||
auto_id=True,
|
||||
|
||||
primary_field = "id",
|
||||
primary_field="id",
|
||||
text_field="text",
|
||||
vector_field="vector",
|
||||
partition_key_field = "kn_id",
|
||||
enable_dynamic_field = True,
|
||||
partition_key_field="kn_id",
|
||||
enable_dynamic_field=True,
|
||||
drop_old=False, # set to True if seeking to drop the collection with that name if it exists
|
||||
)
|
||||
memVectorstore = Milvus(
|
||||
@@ -25,11 +25,10 @@ memVectorstore = Milvus(
|
||||
index_params={"index_type": "FLAT", "metric_type": "L2"},
|
||||
consistency_level="Strong",
|
||||
auto_id=True,
|
||||
|
||||
primary_field = "id",
|
||||
primary_field="id",
|
||||
text_field="text",
|
||||
vector_field="vector",
|
||||
partition_key_field = "ai_id",
|
||||
enable_dynamic_field = True,
|
||||
partition_key_field="ai_id",
|
||||
enable_dynamic_field=True,
|
||||
drop_old=False, # set to True if seeking to drop the collection with that name if it exists
|
||||
)
|
||||
)
|
||||
|
||||
@@ -4,10 +4,11 @@ from minio import Minio
|
||||
|
||||
# MinIO 客户端初始化
|
||||
minio_client = Minio(
|
||||
"s1.ronsunny.cn:9000",
|
||||
"ai.ronsunny.cn:9000",
|
||||
access_key="minioadmin",
|
||||
secret_key="minioadmin",
|
||||
secure=False,
|
||||
region="Chengdu",
|
||||
secure=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import logging
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from typing import Optional
|
||||
|
||||
import psycopg
|
||||
from psycopg_pool import ConnectionPool
|
||||
|
||||
logger = logging.getLogger("PGPool")
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
|
||||
class PGPool:
|
||||
"""
|
||||
PostgreSQL 连接池封装
|
||||
@@ -62,8 +63,10 @@ class PGPool:
|
||||
logger.error(f"SQL执行异常: {e}")
|
||||
raise
|
||||
raise psycopg.OperationalError("无法获取数据库连接,多次重试失败")
|
||||
|
||||
|
||||
pg_pool = PGPool(
|
||||
uri="postgresql://postgres:123456@10.10.10.9/ktor2",
|
||||
uri="postgresql://postgres:123456@ce_postgres/ktor2",
|
||||
min_size=1,
|
||||
max_size=20,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
RABBIT_HOST = "10.10.10.9"
|
||||
RABBIT_HOST = "ce_rabbitmq"
|
||||
RABBIT_VHOST = "/bbit_ai"
|
||||
RABBIT_USER = "bbit_ai"
|
||||
RABBIT_PASSWORD = "123456"
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import base64
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from config.app import F8_SERVER_USER_ID
|
||||
from models.BaseResponse import BaseResponse
|
||||
from models.F8ImageRequest import F8ImageRequest
|
||||
from models.F8ImageRequestV2 import F8ImageRequestV2
|
||||
from service.vision import process_ticket_image
|
||||
from utils import MyUtils
|
||||
|
||||
f8Router = APIRouter()
|
||||
|
||||
|
||||
@f8Router.post("/createTicketImageTask")
|
||||
async def cocoonTicket(data: F8ImageRequest):
|
||||
input_data = data.image
|
||||
if "," in input_data:
|
||||
input_data = input_data.split(",")[1]
|
||||
try:
|
||||
img_bytes = base64.b64decode(input_data)
|
||||
json_data = await MyUtils.async_task(
|
||||
process_ticket_image,
|
||||
1,
|
||||
True,
|
||||
img_bytes,
|
||||
f"{data.title}.jpg",
|
||||
data.title,
|
||||
F8_SERVER_USER_ID,
|
||||
)
|
||||
return BaseResponse(data=json_data)
|
||||
except Exception as e:
|
||||
return BaseResponse(status=False, message=f"解析失败: {str(e)}", data=None)
|
||||
|
||||
|
||||
@f8Router.post("/createTicketImageTaskV2")
|
||||
async def cocoonTicket(data: F8ImageRequestV2):
|
||||
input_data = data.image
|
||||
if "," in input_data:
|
||||
input_data = input_data.split(",")[1]
|
||||
try:
|
||||
img_bytes = base64.b64decode(input_data)
|
||||
json_data = await MyUtils.async_task(
|
||||
process_ticket_image,
|
||||
2,
|
||||
data.needBarcode,
|
||||
img_bytes,
|
||||
f"{data.title}.jpg",
|
||||
data.title,
|
||||
F8_SERVER_USER_ID,
|
||||
)
|
||||
return BaseResponse(data=json_data)
|
||||
except Exception as e:
|
||||
return BaseResponse(status=False, message=f"解析失败: {str(e)}", data=None)
|
||||
@@ -0,0 +1,45 @@
|
||||
# 使用官方 Python 镜像
|
||||
FROM python:3.10-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libpq5 \
|
||||
unixodbc \
|
||||
curl \
|
||||
gnupg \
|
||||
apt-transport-https \
|
||||
lsb-release && \
|
||||
# 导入微软 GPG key(使用 keyrings 方式)
|
||||
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /usr/share/keyrings/microsoft.gpg && \
|
||||
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/ubuntu/22.04/prod jammy main" > /etc/apt/sources.list.d/mssql-release.list && \
|
||||
apt-get update && \
|
||||
ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY ./bbit_ai/docker/requirements.txt .
|
||||
# 安装 Python 依赖
|
||||
RUN pip install --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
|
||||
|
||||
# 复制并解压 JRE
|
||||
COPY ./bbit_ai/docker/OpenJDK17U-jre_x64_linux_hotspot_17.0.16_8.tar.gz /opt/
|
||||
RUN tar -xzf /opt/OpenJDK17U-jre_x64_linux_hotspot_17.0.16_8.tar.gz -C /opt/ && \
|
||||
rm /opt/OpenJDK17U-jre_x64_linux_hotspot_17.0.16_8.tar.gz
|
||||
|
||||
# 配置 Java 环境
|
||||
ENV JAVA_HOME=/opt/jdk-17.0.16+8-jre
|
||||
ENV PATH="$JAVA_HOME/bin:$PATH"
|
||||
|
||||
|
||||
# 复制项目代码
|
||||
COPY ./bbit_ai/app/ .
|
||||
# 复制 pyzxing 的 jar 文件到默认路径
|
||||
COPY ./bbit_ai/docker/javase-3.4.1-SNAPSHOT-jar-with-dependencies.jar /root/.local/pyzxing/javase-3.4.1-SNAPSHOT-jar-with-dependencies.jar
|
||||
|
||||
EXPOSE 13011
|
||||
|
||||
# 启动命令(使用 uvicorn 启动 FastAPI)
|
||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "13011", "--reload"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user