mirror of
https://github.com/langgenius/dify.git
synced 2026-05-31 06:06:20 +08:00
Add a shared get_app_parameters() resolver that maps any app type to its webapp parameters, and route the web, service-API and explore /parameters endpoints through it. Agent Apps have neither a workflow nor a legacy app_model_config, so their presentation features (opening statement, suggestions, file upload, ...) default to disabled with a free-form chat input until a dedicated config surface lands. This unblocks the public web app and service API for Agent Apps: /parameters now returns a valid config instead of 500-ing on the missing app_model_config. Live-verified end-to-end via the web app entry (passport -> parameters -> streamed chat) and /v1/parameters. Unit tests cover all four resolver branches (workflow, easy-UI config, agent defaults, unavailable). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
from controllers.common import fields
|
|
from controllers.console import console_ns
|
|
from controllers.console.app.error import AppUnavailableError
|
|
from controllers.console.explore.wraps import InstalledAppResource
|
|
from core.app.app_config.common.parameters_mapping import AppParametersUnavailableError, get_app_parameters
|
|
from models.model import InstalledApp
|
|
from services.app_service import AppService
|
|
|
|
|
|
@console_ns.route("/installed-apps/<uuid:installed_app_id>/parameters", endpoint="installed_app_parameters")
|
|
class AppParameterApi(InstalledAppResource):
|
|
"""Resource for app variables."""
|
|
|
|
def get(self, installed_app: InstalledApp):
|
|
"""Retrieve app parameters."""
|
|
app_model = installed_app.app
|
|
|
|
if app_model is None:
|
|
raise AppUnavailableError()
|
|
|
|
try:
|
|
parameters = get_app_parameters(app_model)
|
|
except AppParametersUnavailableError:
|
|
raise AppUnavailableError()
|
|
return fields.Parameters.model_validate(parameters).model_dump(mode="json")
|
|
|
|
|
|
@console_ns.route("/installed-apps/<uuid:installed_app_id>/meta", endpoint="installed_app_meta")
|
|
class ExploreAppMetaApi(InstalledAppResource):
|
|
def get(self, installed_app: InstalledApp):
|
|
"""Get app meta"""
|
|
app_model = installed_app.app
|
|
if not app_model:
|
|
raise ValueError("App not found")
|
|
return AppService().get_app_meta(app_model)
|