mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-03 11:11:58 +00:00
The backend import package is now docsgpt, the name it will carry on PyPI; application was far too generic to install into anyone's site-packages. git mv plus a mechanical rewrite of every import, dotted string and path reference: 734 Python files, the compose files, Dockerfile, workflows, docs, setup scripts, devcontainer, k8s manifests, vscode config, pytest and coverage config, .gitignore. Behaviour is unchanged. Kept for one release: - A top-level application package whose meta-path finder resolves application.x.y to the already-imported docsgpt.x.y object, so old imports and entry points (celery -A application.app.celery, uvicorn application.asgi:asgi_app) keep working with a FutureWarning. - Celery registers every application.* task name as an alias of its docsgpt.* task on start-up, so messages queued by the previous release still run. The redbeat key prefix moves to redbeat:docsgpt:v2: so schedule entries the previous release wrote are left unread instead of firing twice. The backend image builds from the repository root (docker build -f docsgpt/Dockerfile .) so it can ship the alias package; a root .dockerignore allow-lists docsgpt/ and application/ and keeps caches, local data, .env files, the sample index files and the Dockerfile out. Compose and the image workflows point at the new context.
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from typing import Any, Dict, Optional
|
|
|
|
|
|
class JsonSchemaValidationError(ValueError):
|
|
"""Raised when a JSON schema payload is invalid."""
|
|
|
|
|
|
def normalize_json_schema_payload(json_schema: Any) -> Optional[Dict[str, Any]]:
|
|
"""
|
|
Normalize accepted JSON schema payload shapes to a plain schema object.
|
|
|
|
Accepted inputs:
|
|
- None
|
|
- A raw schema object with a top-level "type"
|
|
- A wrapped payload with a top-level "schema" object
|
|
"""
|
|
if json_schema is None:
|
|
return None
|
|
|
|
if not isinstance(json_schema, dict):
|
|
raise JsonSchemaValidationError("must be a valid JSON object")
|
|
|
|
wrapped_schema = json_schema.get("schema")
|
|
if wrapped_schema is not None:
|
|
if not isinstance(wrapped_schema, dict):
|
|
raise JsonSchemaValidationError('field "schema" must be a valid JSON object')
|
|
return wrapped_schema
|
|
|
|
if "type" not in json_schema:
|
|
raise JsonSchemaValidationError(
|
|
'must include either a "type" or "schema" field'
|
|
)
|
|
|
|
return json_schema
|