jack 1 tháng trước cách đây
mục cha
commit
dc7e3cdb43

+ 5 - 0
app/core/runner/llm_backend.py

@@ -39,6 +39,11 @@ class LLMBackend:
                 if "n" in model_params:
                 if "n" in model_params:
                     raise ValueError("n is not allowed in model_params")
                     raise ValueError("n is not allowed in model_params")
                 chat_params.update(model_params)
                 chat_params.update(model_params)
+            stream_options_params = extra_body.get("stream_options")
+            if stream_options_params:
+                chat_params["stream_options"] = {
+                    "include_usage": bool(stream_options_params["include_usage"])
+                }
         if stream_options:
         if stream_options:
             if isinstance(stream_options, dict):
             if isinstance(stream_options, dict):
                 if "include_usage" in stream_options:
                 if "include_usage" in stream_options:

+ 2 - 0
app/providers/database.py

@@ -24,6 +24,7 @@ engine = create_engine(
     pool_size=db_settings.DB_POOL_SIZE,
     pool_size=db_settings.DB_POOL_SIZE,
     pool_recycle=db_settings.DB_POOL_RECYCLE,
     pool_recycle=db_settings.DB_POOL_RECYCLE,
     echo=settings.DEBUG,
     echo=settings.DEBUG,
+    max_overflow=db_settings.DB_OVERLOW,
 )
 )
 session = scoped_session(sessionmaker(bind=engine))
 session = scoped_session(sessionmaker(bind=engine))
 
 
@@ -35,6 +36,7 @@ async_engine = create_async_engine(
     pool_size=db_settings.DB_POOL_SIZE,
     pool_size=db_settings.DB_POOL_SIZE,
     pool_recycle=db_settings.DB_POOL_RECYCLE,
     pool_recycle=db_settings.DB_POOL_RECYCLE,
     echo=settings.DEBUG,
     echo=settings.DEBUG,
+    max_overflow=db_settings.DB_OVERLOW,
 )
 )
 
 
 # 创建session元类
 # 创建session元类

+ 23 - 0
app/services/file/impl/r2r_file.py

@@ -21,6 +21,29 @@ nest_asyncio.apply()
 
 
 
 
 class R2RFileService(OSSFileService):
 class R2RFileService(OSSFileService):
+
+'''
+    @staticmethod
+    def get_file_list_by_ids(*, session: Session, file_ids: List[str]) -> List[File]:
+        if not file_ids:
+            return []
+        statement = select(File).where(col(File.id).in_(file_ids))
+        return session.execute(statement).scalars().all()
+
+    @staticmethod
+    async def get_file_list(
+        *, session: AsyncSession, purpose: str, file_ids: List[str]
+    ) -> List[File]:
+        statement = select(File)
+        if purpose is not None and len(purpose) > 0:
+            statement = statement.where(File.purpose == purpose)
+        if file_ids is not None:
+            statement = statement.where(File.id.in_(file_ids))
+        statement = statement.order_by(desc(File.created_at))
+        result = await session.execute(statement)
+        return result.scalars().all()
+'''
+
     @staticmethod
     @staticmethod
     async def create_file(
     async def create_file(
         *, session: AsyncSession, purpose: str, file: UploadFile
         *, session: AsyncSession, purpose: str, file: UploadFile

+ 1 - 0
config/database.py

@@ -13,6 +13,7 @@ class Settings(BaseSettings):
     DB_PASSWORD: str = "123456"
     DB_PASSWORD: str = "123456"
     DB_POOL_SIZE: int = 20
     DB_POOL_SIZE: int = 20
     DB_POOL_RECYCLE: int = 3600
     DB_POOL_RECYCLE: int = 3600
+    DB_OVERLOW: int = 10000
 
 
     @property
     @property
     def database_url(self):
     def database_url(self):

+ 2 - 2
docker-compose.yml

@@ -21,7 +21,7 @@ services:
       APP_SERVER_WORKERS: 40
       APP_SERVER_WORKERS: 40
       APP_API_PREFIX: /api
       APP_API_PREFIX: /api
 
 
-      APP_AUTH_ENABLE: false
+      APP_AUTH_ENABLE: true
       APP_AUTH_ADMIN_TOKEN: cocorobo-xjw-admin
       APP_AUTH_ADMIN_TOKEN: cocorobo-xjw-admin
 
 
       LOG_LEVEL: DEBUG
       LOG_LEVEL: DEBUG
@@ -89,7 +89,7 @@ services:
       APP_DEBUG: true
       APP_DEBUG: true
       APP_ENV: prod
       APP_ENV: prod
 
 
-      APP_AUTH_ENABLE: false
+      APP_AUTH_ENABLE: true
       APP_AUTH_ADMIN_TOKEN: cocorobo-xjw-admin
       APP_AUTH_ADMIN_TOKEN: cocorobo-xjw-admin
 
 
       LOG_LEVEL: DEBUG
       LOG_LEVEL: DEBUG