Skip to content
Open
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: 6 additions & 0 deletions apps/api/src/cortex_api/middleware/request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,10 @@ async def request_context_middleware(
response.headers[X_REQUEST_ID_HEADER] = request_id
if trace_context["trace_id"]:
response.headers[X_TRACE_ID_HEADER] = str(trace_context["trace_id"])

# Security headers
response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains"
response.headers["X-Frame-Options"] = "DENY"
response.headers["X-Content-Type-Options"] = "nosniff"

return response
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def _collect_total_success_failed(
else:
numbers = []
if len(numbers) >= 3 and all(number is not None for number in numbers[:3]):
output["perf.total_requests"] = float(numbers[0])
output["perf.success_requests"] = float(numbers[1])
output["perf.failed_requests"] = float(numbers[2])
output["perf.total_requests"] = float(numbers[0]) # type: ignore[arg-type]
output["perf.success_requests"] = float(numbers[1]) # type: ignore[arg-type]
output["perf.failed_requests"] = float(numbers[2]) # type: ignore[arg-type]

def _collect_percentile_row(
self,
Expand Down
18 changes: 9 additions & 9 deletions packages/knowledge/src/cortex_knowledge/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,13 @@ def _cognee_stable_data_id(
source_parts = [
str(dataset),
input_type,
_strip_optional_string(raw_input.get("label")) or "",
_strip_optional_string(metadata.get("source_url")) or "",
_strip_optional_string(metadata.get("source_name")) or "",
_strip_optional_string(metadata.get("engine_id")) or "",
_strip_optional_string(metadata.get("object_id")) or "",
_strip_optional_string(metadata.get("document_id")) or "",
_strip_optional_string(metadata.get("markdown_sha256")) or "",
_strip_optional_string(raw_input.get("label") if raw_input else None) or "",
_strip_optional_string(metadata.get("source_url") if metadata else None) or "",
_strip_optional_string(metadata.get("source_name") if metadata else None) or "",
_strip_optional_string(metadata.get("engine_id") if metadata else None) or "",
_strip_optional_string(metadata.get("object_id") if metadata else None) or "",
_strip_optional_string(metadata.get("document_id") if metadata else None) or "",
_strip_optional_string(metadata.get("markdown_sha256") if metadata else None) or "",
hashlib.sha256(value.encode("utf-8")).hexdigest(),
]
return uuid5(NAMESPACE_URL, "cortex:cognee-data:" + "\x1f".join(source_parts))
Expand Down Expand Up @@ -801,7 +801,7 @@ def _init_with_fallback(
self,
model=model,
max_completion_tokens=max_completion_tokens,
)
) # type: ignore[call-overload]
except Exception as exc:
if not _is_tiktoken_unknown_model_error(exc):
raise
Expand All @@ -811,7 +811,7 @@ def _init_with_fallback(
str(_COGNEE_EMBEDDING_TOKENIZER_OPTIONS.get("encoding") or "cl100k_base")
)

tokenizer_class.__init__ = _init_with_fallback
tokenizer_class.__init__ = _init_with_fallback # type: ignore[method-assign]
tokenizer_class._cortex_unknown_model_fallback = True


Expand Down
4 changes: 3 additions & 1 deletion packages/parse/src/cortex_parse/adapters/docling.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def __init__(self, config: dict[str, object] | None = None) -> None:
display_name="Docling",
engine_family="document_local",
deployment_mode=ParseEngineDeploymentMode.LOCAL,
status=ParseEngineStatus.ACTIVE if enabled else ParseEngineStatus.DISABLED,
status=ParseEngineStatus.ACTIVE
if (enabled and self._local_available)
else ParseEngineStatus.DISABLED,
supported_source_types=[
ParseInputKind.URI.value,
ParseInputKind.URL.value,
Expand Down
Loading
Loading