mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
* style: remove necessary imports * style: fix F841 * style: fix F401 * style: fix F811 * style: fix E402 * style: fix E721 * style: fix E722 * style: fix E722 * style: fix F541 * style: ruff format * style: all passed * style: add ruff in deps * style: more ignores in ruff.toml * style: add pre-commit
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
import quart
|
|
|
|
from ... import group
|
|
|
|
|
|
@group.group_class('adapters', '/api/v1/platform/adapters')
|
|
class AdaptersRouterGroup(group.RouterGroup):
|
|
async def initialize(self) -> None:
|
|
@self.route('', methods=['GET'])
|
|
async def _() -> str:
|
|
return self.success(
|
|
data={'adapters': self.ap.platform_mgr.get_available_adapters_info()}
|
|
)
|
|
|
|
@self.route('/<adapter_name>', methods=['GET'])
|
|
async def _(adapter_name: str) -> str:
|
|
adapter_info = self.ap.platform_mgr.get_available_adapter_info_by_name(
|
|
adapter_name
|
|
)
|
|
|
|
if adapter_info is None:
|
|
return self.http_status(404, -1, 'adapter not found')
|
|
|
|
return self.success(data={'adapter': adapter_info})
|
|
|
|
@self.route('/<adapter_name>/icon', methods=['GET'])
|
|
async def _(adapter_name: str) -> quart.Response:
|
|
adapter_manifest = (
|
|
self.ap.platform_mgr.get_available_adapter_manifest_by_name(
|
|
adapter_name
|
|
)
|
|
)
|
|
|
|
if adapter_manifest is None:
|
|
return self.http_status(404, -1, 'adapter not found')
|
|
|
|
icon_path = adapter_manifest.icon_rel_path
|
|
|
|
if icon_path is None:
|
|
return self.http_status(404, -1, 'icon not found')
|
|
|
|
return await quart.send_file(icon_path)
|