-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathsettings_router.py
More file actions
39 lines (27 loc) · 1.26 KB
/
settings_router.py
File metadata and controls
39 lines (27 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from functools import lru_cache
from fastapi import APIRouter
from openhands.sdk.settings import (
ConversationSettings,
SettingsSchema,
export_agent_settings_schema,
)
settings_router = APIRouter(prefix="/settings", tags=["Settings"])
@lru_cache(maxsize=1)
def _get_agent_settings_schema() -> SettingsSchema:
# ``AgentSettings`` is now a discriminated union over
# ``LLMAgentSettings`` and ``ACPAgentSettings``; the combined
# schema tags sections with a ``variant`` so the frontend can
# show LLM-only or ACP-only sections based on the active
# ``agent_kind`` value.
return export_agent_settings_schema()
@lru_cache(maxsize=1)
def _get_conversation_settings_schema() -> SettingsSchema:
return ConversationSettings.export_schema()
@settings_router.get("/agent-schema", response_model=SettingsSchema)
async def get_agent_settings_schema() -> SettingsSchema:
"""Return the schema used to render AgentSettings-based settings forms."""
return _get_agent_settings_schema()
@settings_router.get("/conversation-schema", response_model=SettingsSchema)
async def get_conversation_settings_schema() -> SettingsSchema:
"""Return the schema used to render ConversationSettings-based forms."""
return _get_conversation_settings_schema()