Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def _get_app(
add_exception_handlers(app)

instrumentator = Instrumentator(
excluded_handlers=["/docs", "/redoc", "/metrics", "/openapi.json", "/favicon.ico", "none"]
excluded_handlers=["/docs", "/redoc", "/metrics", "/openapi.json", "/favicon.png", "none"]
).instrument(app)

if msd_overwritten is not None:
Expand Down Expand Up @@ -309,7 +309,7 @@ async def swagger_doc(req: Request) -> HTMLResponse:
title="CogStack ModelServe",
oauth2_redirect_url=oauth2_redirect_url,
init_oauth=app.swagger_ui_init_oauth,
swagger_favicon_url="/static/images/favicon.ico",
swagger_favicon_url="/static/images/favicon.png",
swagger_ui_parameters=app.swagger_ui_parameters,
)

Expand All @@ -320,7 +320,7 @@ async def redoc_doc(req: Request) -> HTMLResponse:
return get_redoc_html(
openapi_url=openapi_url,
title="CogStack ModelServe",
redoc_favicon_url="/static/images/favicon.ico",
redoc_favicon_url="/static/images/favicon.png",
)

@app.get("/", include_in_schema=False)
Expand Down
12 changes: 6 additions & 6 deletions app/api/routers/invocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
PATH_PROCESS_BULK_FILE = "/process_bulk_file"
PATH_REDACT = "/redact"
PATH_REDACT_WITH_ENCRYPTION = "/redact_with_encryption"
PATH_OPENAI_EMBEDDINGS = "/v1/embeddings"
PATH_EMBEDDINGS = "/embeddings"

router = APIRouter()
config = get_settings()
Expand Down Expand Up @@ -359,13 +359,13 @@ def get_redacted_text_with_encryption(


@router.post(
PATH_OPENAI_EMBEDDINGS,
tags=[Tags.OpenAICompatible.name],
PATH_EMBEDDINGS,
tags=[Tags.Embeddings.name],
response_model=None,
dependencies=[Depends(cms_globals.props.current_active_user)],
description="Create embeddings based on text(s), similar to OpenAI's /v1/embeddings endpoint",
description="Create embeddings based on text(s)",
)
def embed_texts(
def get_text_embeddings(
request: Request,
request_data: Annotated[OpenAIEmbeddingsRequest, Body(
description="Text(s) to be embedded", media_type="application/json"
Expand All @@ -374,7 +374,7 @@ def embed_texts(
model_service: AbstractModelService = Depends(cms_globals.model_service_dep)
) -> JSONResponse:
"""
Embeds text or a list of texts, mimicking OpenAI's /v1/embeddings endpoint.
Embeds text or a list of texts.

Args:
request (Request): The request object.
Expand Down
Binary file removed app/api/static/images/favicon.ico
Binary file not shown.
Binary file added app/api/static/images/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Tags(str, Enum):
Redaction = "Redact the extracted NER entities"
Rendering = "Preview embeddable annotation snippet in HTML"
Training = "Trigger model training on input annotations"
Embeddings = "Generate embeddings for input texts"
Evaluating = "Evaluate the deployed model with trainer export"
Authentication = "Authenticate registered users"
Generative = "Generate text based on the input prompt"
Expand Down
2 changes: 1 addition & 1 deletion app/mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def create_server() -> Starlette:
oauth_manager=oauth_manager,
public_paths=[
"/authorize",
"/favicon.ico",
"/favicon.png",
"/oauth/",
"/.well-known",
"/.well-known/",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- 28202:28202 # grafana
- 28203:28203 # graylog
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/health"]
test: ["CMD", "curl", "-f", "-k", "https://localhost/health"]
interval: 60s
timeout: 20s
retries: 3
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/features/serving.feature
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ Feature:
| /redact_with_encryption | {"text": "Spinal stenosis", "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3ITkTP8Tm/5FygcwY2EQ7LgVsuCF0OH7psUqvlXnOPNCfX86CobHBiSFjG9o5ZeajPtTXaf1thUodgpJZVZSqpVTXwGKo8r0COMO87IcwYigkZZgG/WmZgoZART+AA0+JvjFGxflJAxSv7puGlf82E+u5Wz2psLBSDO5qrnmaDZTvPh5eX84cocahVVI7X09/kI+sZiKauM69yoy1bdx16YIIeNm0M9qqS3tTrjouQiJfZ8jUKSZ44Na/81LMVw5O46+5GvwD+OsR43kQ0TexMwgtHxQQsiXLWHCDNy2ZzkzukDYRwA3V2lwVjtQN0WjxHg24BTBDBM+v7iQ7cbweQIDAQAB\n-----END PUBLIC KEY-----"} | application/json |
Then the response should contain encrypted labels

@embeddings
Scenario: Generate embeddings for a single text
Given CMS app is up and running
When I send a POST request with the following content
| endpoint | data | content_type |
| /embeddings | {"input": "Spinal stenosis", "model": "cms-model"} | application/json |
Then the response should contain embeddings

@preview
Scenario: Extract and preview entities
Given CMS app is up and running
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/steps/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,15 @@ def check_response_annotation_stats(context):
assert len(response_lines) > 1
assert "concept,anno_count,anno_unique_counts,anno_ignorance_counts" == response_lines[0]
context["response"].close()

@then("the response should contain embeddings")
def check_response_embeddings(context):
assert context["response"].status_code == 200
assert context["response"].headers["Content-Type"] == "application/json"
response_json = context["response"].json()
assert "data" in response_json
assert isinstance(response_json["data"], list)
assert len(response_json["data"]) > 0
assert "embedding" in response_json["data"][0]
assert isinstance(response_json["data"][0]["embedding"], list)
context["response"].close()
Loading