mirror of
https://github.com/langgenius/dify.git
synced 2025-12-19 14:19:28 +00:00
refactor: split changes for api/controllers/console/explore/completio… (#29894)
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
This commit is contained in:
@@ -40,7 +40,7 @@ from .. import console_ns
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CompletionMessagePayload(BaseModel):
|
class CompletionMessageExplorePayload(BaseModel):
|
||||||
inputs: dict[str, Any]
|
inputs: dict[str, Any]
|
||||||
query: str = ""
|
query: str = ""
|
||||||
files: list[dict[str, Any]] | None = None
|
files: list[dict[str, Any]] | None = None
|
||||||
@@ -71,7 +71,7 @@ class ChatMessagePayload(BaseModel):
|
|||||||
raise ValueError("must be a valid UUID") from exc
|
raise ValueError("must be a valid UUID") from exc
|
||||||
|
|
||||||
|
|
||||||
register_schema_models(console_ns, CompletionMessagePayload, ChatMessagePayload)
|
register_schema_models(console_ns, CompletionMessageExplorePayload, ChatMessagePayload)
|
||||||
|
|
||||||
|
|
||||||
# define completion api for user
|
# define completion api for user
|
||||||
@@ -80,13 +80,13 @@ register_schema_models(console_ns, CompletionMessagePayload, ChatMessagePayload)
|
|||||||
endpoint="installed_app_completion",
|
endpoint="installed_app_completion",
|
||||||
)
|
)
|
||||||
class CompletionApi(InstalledAppResource):
|
class CompletionApi(InstalledAppResource):
|
||||||
@console_ns.expect(console_ns.models[CompletionMessagePayload.__name__])
|
@console_ns.expect(console_ns.models[CompletionMessageExplorePayload.__name__])
|
||||||
def post(self, installed_app):
|
def post(self, installed_app):
|
||||||
app_model = installed_app.app
|
app_model = installed_app.app
|
||||||
if app_model.mode != AppMode.COMPLETION:
|
if app_model.mode != AppMode.COMPLETION:
|
||||||
raise NotCompletionAppError()
|
raise NotCompletionAppError()
|
||||||
|
|
||||||
payload = CompletionMessagePayload.model_validate(console_ns.payload or {})
|
payload = CompletionMessageExplorePayload.model_validate(console_ns.payload or {})
|
||||||
args = payload.model_dump(exclude_none=True)
|
args = payload.model_dump(exclude_none=True)
|
||||||
|
|
||||||
streaming = payload.response_mode == "streaming"
|
streaming = payload.response_mode == "streaming"
|
||||||
|
|||||||
Reference in New Issue
Block a user