Skip to content

Commit ac5d761

Browse files
committed
Merge branch '323-endpoint-for-list-custom-services-and-custom-mcp-s' into 'main'
Resolve "Endpoint for list custom services and custom mcp-s" Closes #323 See merge request df/deepfellow-infra!195
2 parents 55925b7 + 16e5968 commit ac5d761

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

server/api/openai.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ async def on_rerank(
164164
return await endpoint_registry.execute_rerank(body, request)
165165

166166

167+
@router.get("/custom")
168+
async def get_custom_prefixes(
169+
request: Request, # noqa: ARG001
170+
_: Annotated[str, Depends(auth_server)],
171+
endpoint_registry: Annotated[EndpointRegistry, Depends(get_endpoint_registry)],
172+
) -> list[str]:
173+
"""Process custom endpoint request."""
174+
return [model.props.prefix for model in endpoint_registry.custom_endpoints.list_models() if model.props.prefix]
175+
176+
167177
# Replacement from router.api_route which is kind bugged in swagger.
168178
# Also FastAPI creators doesn't recommend using api_route method.
169179
@router.get("/custom/{full_path:path}")
@@ -183,6 +193,16 @@ async def on_custom_endpoint(
183193
return await endpoint_registry.execute_custom_endpoints(full_path, request)
184194

185195

196+
@router.get("/mcp")
197+
async def get_mcp_prefixes(
198+
request: Request, # noqa: ARG001
199+
_: Annotated[str, Depends(auth_server)],
200+
endpoint_registry: Annotated[EndpointRegistry, Depends(get_endpoint_registry)],
201+
) -> list[str]:
202+
"""Process custom endpoint request."""
203+
return [model.props.prefix for model in endpoint_registry.mcp_endpoints.list_models() if model.props.prefix]
204+
205+
186206
# Replacement from router.api_route which is kind bugged in swagger.
187207
# Also FastAPI creators doesn't recommend using api_route method.
188208
@router.get("/mcp/{full_path:path}")

server/models/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ class ModelProps(BaseModel):
362362
endpoints: list[str]
363363
context_window: int | None = None
364364
max_context_window: int | None = None
365+
prefix: str | None = None
365366

366367

367368
ModelType = Literal[

server/services/custom_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ async def _install_model(
384384
options.spec = {}
385385
if "prefix" not in options.spec:
386386
options.spec["prefix"] = model.default_prefix
387+
model.model_props.prefix = options.spec["prefix"]
387388
parsed_model_options = try_parse_pydantic(CustomModelOptions, options.spec)
388389
await self._verify_docker_image(model.options.image, options.ignore_warnings)
389390

server/services/mcp_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ async def _install_model(
494494
options.spec = {}
495495
if "prefix" not in options.spec:
496496
options.spec["prefix"] = model.default_prefix
497+
model.model_props.prefix = options.spec["prefix"]
497498
parsed_model_options = try_parse_pydantic(McpModelOptions, options.spec)
498499

499500
self.check_envs(model.required_envs, parsed_model_options.envs)

0 commit comments

Comments
 (0)