ZTWHHH commited on
Commit
e12449e
·
verified ·
1 Parent(s): f6b2501

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. videollama2/lib/python3.10/site-packages/setuptools/command/__pycache__/install_scripts.cpython-310.pyc +0 -0
  3. vllm/lib/python3.10/site-packages/fastapi/__pycache__/__init__.cpython-310.pyc +0 -0
  4. vllm/lib/python3.10/site-packages/fastapi/__pycache__/__main__.cpython-310.pyc +0 -0
  5. vllm/lib/python3.10/site-packages/fastapi/__pycache__/_compat.cpython-310.pyc +0 -0
  6. vllm/lib/python3.10/site-packages/fastapi/__pycache__/applications.cpython-310.pyc +0 -0
  7. vllm/lib/python3.10/site-packages/fastapi/__pycache__/background.cpython-310.pyc +0 -0
  8. vllm/lib/python3.10/site-packages/fastapi/__pycache__/cli.cpython-310.pyc +0 -0
  9. vllm/lib/python3.10/site-packages/fastapi/__pycache__/concurrency.cpython-310.pyc +0 -0
  10. vllm/lib/python3.10/site-packages/fastapi/__pycache__/datastructures.cpython-310.pyc +0 -0
  11. vllm/lib/python3.10/site-packages/fastapi/__pycache__/encoders.cpython-310.pyc +0 -0
  12. vllm/lib/python3.10/site-packages/fastapi/__pycache__/exception_handlers.cpython-310.pyc +0 -0
  13. vllm/lib/python3.10/site-packages/fastapi/__pycache__/exceptions.cpython-310.pyc +0 -0
  14. vllm/lib/python3.10/site-packages/fastapi/__pycache__/logger.cpython-310.pyc +0 -0
  15. vllm/lib/python3.10/site-packages/fastapi/__pycache__/param_functions.cpython-310.pyc +0 -0
  16. vllm/lib/python3.10/site-packages/fastapi/__pycache__/params.cpython-310.pyc +0 -0
  17. vllm/lib/python3.10/site-packages/fastapi/__pycache__/requests.cpython-310.pyc +0 -0
  18. vllm/lib/python3.10/site-packages/fastapi/__pycache__/responses.cpython-310.pyc +0 -0
  19. vllm/lib/python3.10/site-packages/fastapi/__pycache__/routing.cpython-310.pyc +0 -0
  20. vllm/lib/python3.10/site-packages/fastapi/__pycache__/staticfiles.cpython-310.pyc +0 -0
  21. vllm/lib/python3.10/site-packages/fastapi/__pycache__/templating.cpython-310.pyc +0 -0
  22. vllm/lib/python3.10/site-packages/fastapi/__pycache__/testclient.cpython-310.pyc +0 -0
  23. vllm/lib/python3.10/site-packages/fastapi/__pycache__/types.cpython-310.pyc +0 -0
  24. vllm/lib/python3.10/site-packages/fastapi/__pycache__/utils.cpython-310.pyc +0 -0
  25. vllm/lib/python3.10/site-packages/fastapi/__pycache__/websockets.cpython-310.pyc +0 -0
  26. vllm/lib/python3.10/site-packages/fastapi/dependencies/__init__.py +0 -0
  27. vllm/lib/python3.10/site-packages/fastapi/dependencies/__pycache__/__init__.cpython-310.pyc +0 -0
  28. vllm/lib/python3.10/site-packages/fastapi/dependencies/__pycache__/models.cpython-310.pyc +0 -0
  29. vllm/lib/python3.10/site-packages/fastapi/dependencies/__pycache__/utils.cpython-310.pyc +0 -0
  30. vllm/lib/python3.10/site-packages/fastapi/dependencies/models.py +37 -0
  31. vllm/lib/python3.10/site-packages/fastapi/dependencies/utils.py +972 -0
  32. vllm/lib/python3.10/site-packages/fastapi/middleware/__init__.py +1 -0
  33. vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/__init__.cpython-310.pyc +0 -0
  34. vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/cors.cpython-310.pyc +0 -0
  35. vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/gzip.cpython-310.pyc +0 -0
  36. vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/httpsredirect.cpython-310.pyc +0 -0
  37. vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/trustedhost.cpython-310.pyc +0 -0
  38. vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/wsgi.cpython-310.pyc +0 -0
  39. vllm/lib/python3.10/site-packages/fastapi/middleware/cors.py +1 -0
  40. vllm/lib/python3.10/site-packages/fastapi/middleware/gzip.py +1 -0
  41. vllm/lib/python3.10/site-packages/fastapi/middleware/httpsredirect.py +3 -0
  42. vllm/lib/python3.10/site-packages/fastapi/middleware/trustedhost.py +3 -0
  43. vllm/lib/python3.10/site-packages/fastapi/middleware/wsgi.py +1 -0
  44. vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/__init__.cpython-310.pyc +0 -0
  45. vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/constants.cpython-310.pyc +0 -0
  46. vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/docs.cpython-310.pyc +0 -0
  47. vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/models.cpython-310.pyc +0 -0
  48. vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/utils.cpython-310.pyc +0 -0
  49. vllm/lib/python3.10/site-packages/fastapi/openapi/constants.py +3 -0
  50. vllm/lib/python3.10/site-packages/fastapi/openapi/docs.py +344 -0
.gitattributes CHANGED
@@ -923,3 +923,5 @@ vllm/lib/python3.10/site-packages/pip/_vendor/distlib/w64.exe filter=lfs diff=lf
923
  vllm/lib/python3.10/site-packages/pip/_vendor/distlib/t64.exe filter=lfs diff=lfs merge=lfs -text
924
  vllm/lib/python3.10/site-packages/pip/_vendor/distlib/t64-arm.exe filter=lfs diff=lfs merge=lfs -text
925
  vllm/lib/python3.10/site-packages/pip/_vendor/distlib/w64-arm.exe filter=lfs diff=lfs merge=lfs -text
 
 
 
923
  vllm/lib/python3.10/site-packages/pip/_vendor/distlib/t64.exe filter=lfs diff=lfs merge=lfs -text
924
  vllm/lib/python3.10/site-packages/pip/_vendor/distlib/t64-arm.exe filter=lfs diff=lfs merge=lfs -text
925
  vllm/lib/python3.10/site-packages/pip/_vendor/distlib/w64-arm.exe filter=lfs diff=lfs merge=lfs -text
926
+ vllm/lib/python3.10/site-packages/pip/_vendor/__pycache__/typing_extensions.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
927
+ vllm/lib/python3.10/site-packages/pip/_vendor/rich/__pycache__/_emoji_codes.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
videollama2/lib/python3.10/site-packages/setuptools/command/__pycache__/install_scripts.cpython-310.pyc ADDED
Binary file (2.58 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.05 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/__main__.cpython-310.pyc ADDED
Binary file (205 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/_compat.cpython-310.pyc ADDED
Binary file (18.6 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/applications.cpython-310.pyc ADDED
Binary file (68.3 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/background.cpython-310.pyc ADDED
Binary file (2.14 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/cli.cpython-310.pyc ADDED
Binary file (533 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/concurrency.cpython-310.pyc ADDED
Binary file (1.03 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/datastructures.cpython-310.pyc ADDED
Binary file (6.5 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/encoders.cpython-310.pyc ADDED
Binary file (7.76 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/exception_handlers.cpython-310.pyc ADDED
Binary file (1.53 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (6.22 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/logger.cpython-310.pyc ADDED
Binary file (214 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/param_functions.cpython-310.pyc ADDED
Binary file (23.5 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/params.cpython-310.pyc ADDED
Binary file (15.2 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/requests.cpython-310.pyc ADDED
Binary file (244 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/responses.cpython-310.pyc ADDED
Binary file (1.92 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/routing.cpython-310.pyc ADDED
Binary file (57.6 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/staticfiles.cpython-310.pyc ADDED
Binary file (217 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/templating.cpython-310.pyc ADDED
Binary file (219 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/testclient.cpython-310.pyc ADDED
Binary file (214 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/types.cpython-310.pyc ADDED
Binary file (575 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/utils.cpython-310.pyc ADDED
Binary file (5.54 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/__pycache__/websockets.cpython-310.pyc ADDED
Binary file (292 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/dependencies/__init__.py ADDED
File without changes
vllm/lib/python3.10/site-packages/fastapi/dependencies/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (170 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/dependencies/__pycache__/models.cpython-310.pyc ADDED
Binary file (2.01 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/dependencies/__pycache__/utils.cpython-310.pyc ADDED
Binary file (21.6 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/dependencies/models.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass, field
2
+ from typing import Any, Callable, List, Optional, Sequence, Tuple
3
+
4
+ from fastapi._compat import ModelField
5
+ from fastapi.security.base import SecurityBase
6
+
7
+
8
+ @dataclass
9
+ class SecurityRequirement:
10
+ security_scheme: SecurityBase
11
+ scopes: Optional[Sequence[str]] = None
12
+
13
+
14
+ @dataclass
15
+ class Dependant:
16
+ path_params: List[ModelField] = field(default_factory=list)
17
+ query_params: List[ModelField] = field(default_factory=list)
18
+ header_params: List[ModelField] = field(default_factory=list)
19
+ cookie_params: List[ModelField] = field(default_factory=list)
20
+ body_params: List[ModelField] = field(default_factory=list)
21
+ dependencies: List["Dependant"] = field(default_factory=list)
22
+ security_requirements: List[SecurityRequirement] = field(default_factory=list)
23
+ name: Optional[str] = None
24
+ call: Optional[Callable[..., Any]] = None
25
+ request_param_name: Optional[str] = None
26
+ websocket_param_name: Optional[str] = None
27
+ http_connection_param_name: Optional[str] = None
28
+ response_param_name: Optional[str] = None
29
+ background_tasks_param_name: Optional[str] = None
30
+ security_scopes_param_name: Optional[str] = None
31
+ security_scopes: Optional[List[str]] = None
32
+ use_cache: bool = True
33
+ path: Optional[str] = None
34
+ cache_key: Tuple[Optional[Callable[..., Any]], Tuple[str, ...]] = field(init=False)
35
+
36
+ def __post_init__(self) -> None:
37
+ self.cache_key = (self.call, tuple(sorted(set(self.security_scopes or []))))
vllm/lib/python3.10/site-packages/fastapi/dependencies/utils.py ADDED
@@ -0,0 +1,972 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import inspect
2
+ from contextlib import AsyncExitStack, contextmanager
3
+ from copy import copy, deepcopy
4
+ from dataclasses import dataclass
5
+ from typing import (
6
+ Any,
7
+ Callable,
8
+ Coroutine,
9
+ Dict,
10
+ ForwardRef,
11
+ List,
12
+ Mapping,
13
+ Optional,
14
+ Sequence,
15
+ Tuple,
16
+ Type,
17
+ Union,
18
+ cast,
19
+ )
20
+
21
+ import anyio
22
+ from fastapi import params
23
+ from fastapi._compat import (
24
+ PYDANTIC_V2,
25
+ ErrorWrapper,
26
+ ModelField,
27
+ RequiredParam,
28
+ Undefined,
29
+ _regenerate_error_with_loc,
30
+ copy_field_info,
31
+ create_body_model,
32
+ evaluate_forwardref,
33
+ field_annotation_is_scalar,
34
+ get_annotation_from_field_info,
35
+ get_cached_model_fields,
36
+ get_missing_field_error,
37
+ is_bytes_field,
38
+ is_bytes_sequence_field,
39
+ is_scalar_field,
40
+ is_scalar_sequence_field,
41
+ is_sequence_field,
42
+ is_uploadfile_or_nonable_uploadfile_annotation,
43
+ is_uploadfile_sequence_annotation,
44
+ lenient_issubclass,
45
+ sequence_types,
46
+ serialize_sequence_value,
47
+ value_is_sequence,
48
+ )
49
+ from fastapi.background import BackgroundTasks
50
+ from fastapi.concurrency import (
51
+ asynccontextmanager,
52
+ contextmanager_in_threadpool,
53
+ )
54
+ from fastapi.dependencies.models import Dependant, SecurityRequirement
55
+ from fastapi.logger import logger
56
+ from fastapi.security.base import SecurityBase
57
+ from fastapi.security.oauth2 import OAuth2, SecurityScopes
58
+ from fastapi.security.open_id_connect_url import OpenIdConnect
59
+ from fastapi.utils import create_model_field, get_path_param_names
60
+ from pydantic import BaseModel
61
+ from pydantic.fields import FieldInfo
62
+ from starlette.background import BackgroundTasks as StarletteBackgroundTasks
63
+ from starlette.concurrency import run_in_threadpool
64
+ from starlette.datastructures import (
65
+ FormData,
66
+ Headers,
67
+ ImmutableMultiDict,
68
+ QueryParams,
69
+ UploadFile,
70
+ )
71
+ from starlette.requests import HTTPConnection, Request
72
+ from starlette.responses import Response
73
+ from starlette.websockets import WebSocket
74
+ from typing_extensions import Annotated, get_args, get_origin
75
+
76
+ multipart_not_installed_error = (
77
+ 'Form data requires "python-multipart" to be installed. \n'
78
+ 'You can install "python-multipart" with: \n\n'
79
+ "pip install python-multipart\n"
80
+ )
81
+ multipart_incorrect_install_error = (
82
+ 'Form data requires "python-multipart" to be installed. '
83
+ 'It seems you installed "multipart" instead. \n'
84
+ 'You can remove "multipart" with: \n\n'
85
+ "pip uninstall multipart\n\n"
86
+ 'And then install "python-multipart" with: \n\n'
87
+ "pip install python-multipart\n"
88
+ )
89
+
90
+
91
+ def ensure_multipart_is_installed() -> None:
92
+ try:
93
+ from python_multipart import __version__
94
+
95
+ # Import an attribute that can be mocked/deleted in testing
96
+ assert __version__ > "0.0.12"
97
+ except (ImportError, AssertionError):
98
+ try:
99
+ # __version__ is available in both multiparts, and can be mocked
100
+ from multipart import __version__ # type: ignore[no-redef,import-untyped]
101
+
102
+ assert __version__
103
+ try:
104
+ # parse_options_header is only available in the right multipart
105
+ from multipart.multipart import ( # type: ignore[import-untyped]
106
+ parse_options_header,
107
+ )
108
+
109
+ assert parse_options_header
110
+ except ImportError:
111
+ logger.error(multipart_incorrect_install_error)
112
+ raise RuntimeError(multipart_incorrect_install_error) from None
113
+ except ImportError:
114
+ logger.error(multipart_not_installed_error)
115
+ raise RuntimeError(multipart_not_installed_error) from None
116
+
117
+
118
+ def get_param_sub_dependant(
119
+ *,
120
+ param_name: str,
121
+ depends: params.Depends,
122
+ path: str,
123
+ security_scopes: Optional[List[str]] = None,
124
+ ) -> Dependant:
125
+ assert depends.dependency
126
+ return get_sub_dependant(
127
+ depends=depends,
128
+ dependency=depends.dependency,
129
+ path=path,
130
+ name=param_name,
131
+ security_scopes=security_scopes,
132
+ )
133
+
134
+
135
+ def get_parameterless_sub_dependant(*, depends: params.Depends, path: str) -> Dependant:
136
+ assert callable(
137
+ depends.dependency
138
+ ), "A parameter-less dependency must have a callable dependency"
139
+ return get_sub_dependant(depends=depends, dependency=depends.dependency, path=path)
140
+
141
+
142
+ def get_sub_dependant(
143
+ *,
144
+ depends: params.Depends,
145
+ dependency: Callable[..., Any],
146
+ path: str,
147
+ name: Optional[str] = None,
148
+ security_scopes: Optional[List[str]] = None,
149
+ ) -> Dependant:
150
+ security_requirement = None
151
+ security_scopes = security_scopes or []
152
+ if isinstance(depends, params.Security):
153
+ dependency_scopes = depends.scopes
154
+ security_scopes.extend(dependency_scopes)
155
+ if isinstance(dependency, SecurityBase):
156
+ use_scopes: List[str] = []
157
+ if isinstance(dependency, (OAuth2, OpenIdConnect)):
158
+ use_scopes = security_scopes
159
+ security_requirement = SecurityRequirement(
160
+ security_scheme=dependency, scopes=use_scopes
161
+ )
162
+ sub_dependant = get_dependant(
163
+ path=path,
164
+ call=dependency,
165
+ name=name,
166
+ security_scopes=security_scopes,
167
+ use_cache=depends.use_cache,
168
+ )
169
+ if security_requirement:
170
+ sub_dependant.security_requirements.append(security_requirement)
171
+ return sub_dependant
172
+
173
+
174
+ CacheKey = Tuple[Optional[Callable[..., Any]], Tuple[str, ...]]
175
+
176
+
177
+ def get_flat_dependant(
178
+ dependant: Dependant,
179
+ *,
180
+ skip_repeats: bool = False,
181
+ visited: Optional[List[CacheKey]] = None,
182
+ ) -> Dependant:
183
+ if visited is None:
184
+ visited = []
185
+ visited.append(dependant.cache_key)
186
+
187
+ flat_dependant = Dependant(
188
+ path_params=dependant.path_params.copy(),
189
+ query_params=dependant.query_params.copy(),
190
+ header_params=dependant.header_params.copy(),
191
+ cookie_params=dependant.cookie_params.copy(),
192
+ body_params=dependant.body_params.copy(),
193
+ security_requirements=dependant.security_requirements.copy(),
194
+ use_cache=dependant.use_cache,
195
+ path=dependant.path,
196
+ )
197
+ for sub_dependant in dependant.dependencies:
198
+ if skip_repeats and sub_dependant.cache_key in visited:
199
+ continue
200
+ flat_sub = get_flat_dependant(
201
+ sub_dependant, skip_repeats=skip_repeats, visited=visited
202
+ )
203
+ flat_dependant.path_params.extend(flat_sub.path_params)
204
+ flat_dependant.query_params.extend(flat_sub.query_params)
205
+ flat_dependant.header_params.extend(flat_sub.header_params)
206
+ flat_dependant.cookie_params.extend(flat_sub.cookie_params)
207
+ flat_dependant.body_params.extend(flat_sub.body_params)
208
+ flat_dependant.security_requirements.extend(flat_sub.security_requirements)
209
+ return flat_dependant
210
+
211
+
212
+ def _get_flat_fields_from_params(fields: List[ModelField]) -> List[ModelField]:
213
+ if not fields:
214
+ return fields
215
+ first_field = fields[0]
216
+ if len(fields) == 1 and lenient_issubclass(first_field.type_, BaseModel):
217
+ fields_to_extract = get_cached_model_fields(first_field.type_)
218
+ return fields_to_extract
219
+ return fields
220
+
221
+
222
+ def get_flat_params(dependant: Dependant) -> List[ModelField]:
223
+ flat_dependant = get_flat_dependant(dependant, skip_repeats=True)
224
+ path_params = _get_flat_fields_from_params(flat_dependant.path_params)
225
+ query_params = _get_flat_fields_from_params(flat_dependant.query_params)
226
+ header_params = _get_flat_fields_from_params(flat_dependant.header_params)
227
+ cookie_params = _get_flat_fields_from_params(flat_dependant.cookie_params)
228
+ return path_params + query_params + header_params + cookie_params
229
+
230
+
231
+ def get_typed_signature(call: Callable[..., Any]) -> inspect.Signature:
232
+ signature = inspect.signature(call)
233
+ globalns = getattr(call, "__globals__", {})
234
+ typed_params = [
235
+ inspect.Parameter(
236
+ name=param.name,
237
+ kind=param.kind,
238
+ default=param.default,
239
+ annotation=get_typed_annotation(param.annotation, globalns),
240
+ )
241
+ for param in signature.parameters.values()
242
+ ]
243
+ typed_signature = inspect.Signature(typed_params)
244
+ return typed_signature
245
+
246
+
247
+ def get_typed_annotation(annotation: Any, globalns: Dict[str, Any]) -> Any:
248
+ if isinstance(annotation, str):
249
+ annotation = ForwardRef(annotation)
250
+ annotation = evaluate_forwardref(annotation, globalns, globalns)
251
+ return annotation
252
+
253
+
254
+ def get_typed_return_annotation(call: Callable[..., Any]) -> Any:
255
+ signature = inspect.signature(call)
256
+ annotation = signature.return_annotation
257
+
258
+ if annotation is inspect.Signature.empty:
259
+ return None
260
+
261
+ globalns = getattr(call, "__globals__", {})
262
+ return get_typed_annotation(annotation, globalns)
263
+
264
+
265
+ def get_dependant(
266
+ *,
267
+ path: str,
268
+ call: Callable[..., Any],
269
+ name: Optional[str] = None,
270
+ security_scopes: Optional[List[str]] = None,
271
+ use_cache: bool = True,
272
+ ) -> Dependant:
273
+ path_param_names = get_path_param_names(path)
274
+ endpoint_signature = get_typed_signature(call)
275
+ signature_params = endpoint_signature.parameters
276
+ dependant = Dependant(
277
+ call=call,
278
+ name=name,
279
+ path=path,
280
+ security_scopes=security_scopes,
281
+ use_cache=use_cache,
282
+ )
283
+ for param_name, param in signature_params.items():
284
+ is_path_param = param_name in path_param_names
285
+ param_details = analyze_param(
286
+ param_name=param_name,
287
+ annotation=param.annotation,
288
+ value=param.default,
289
+ is_path_param=is_path_param,
290
+ )
291
+ if param_details.depends is not None:
292
+ sub_dependant = get_param_sub_dependant(
293
+ param_name=param_name,
294
+ depends=param_details.depends,
295
+ path=path,
296
+ security_scopes=security_scopes,
297
+ )
298
+ dependant.dependencies.append(sub_dependant)
299
+ continue
300
+ if add_non_field_param_to_dependency(
301
+ param_name=param_name,
302
+ type_annotation=param_details.type_annotation,
303
+ dependant=dependant,
304
+ ):
305
+ assert (
306
+ param_details.field is None
307
+ ), f"Cannot specify multiple FastAPI annotations for {param_name!r}"
308
+ continue
309
+ assert param_details.field is not None
310
+ if isinstance(param_details.field.field_info, params.Body):
311
+ dependant.body_params.append(param_details.field)
312
+ else:
313
+ add_param_to_fields(field=param_details.field, dependant=dependant)
314
+ return dependant
315
+
316
+
317
+ def add_non_field_param_to_dependency(
318
+ *, param_name: str, type_annotation: Any, dependant: Dependant
319
+ ) -> Optional[bool]:
320
+ if lenient_issubclass(type_annotation, Request):
321
+ dependant.request_param_name = param_name
322
+ return True
323
+ elif lenient_issubclass(type_annotation, WebSocket):
324
+ dependant.websocket_param_name = param_name
325
+ return True
326
+ elif lenient_issubclass(type_annotation, HTTPConnection):
327
+ dependant.http_connection_param_name = param_name
328
+ return True
329
+ elif lenient_issubclass(type_annotation, Response):
330
+ dependant.response_param_name = param_name
331
+ return True
332
+ elif lenient_issubclass(type_annotation, StarletteBackgroundTasks):
333
+ dependant.background_tasks_param_name = param_name
334
+ return True
335
+ elif lenient_issubclass(type_annotation, SecurityScopes):
336
+ dependant.security_scopes_param_name = param_name
337
+ return True
338
+ return None
339
+
340
+
341
+ @dataclass
342
+ class ParamDetails:
343
+ type_annotation: Any
344
+ depends: Optional[params.Depends]
345
+ field: Optional[ModelField]
346
+
347
+
348
+ def analyze_param(
349
+ *,
350
+ param_name: str,
351
+ annotation: Any,
352
+ value: Any,
353
+ is_path_param: bool,
354
+ ) -> ParamDetails:
355
+ field_info = None
356
+ depends = None
357
+ type_annotation: Any = Any
358
+ use_annotation: Any = Any
359
+ if annotation is not inspect.Signature.empty:
360
+ use_annotation = annotation
361
+ type_annotation = annotation
362
+ # Extract Annotated info
363
+ if get_origin(use_annotation) is Annotated:
364
+ annotated_args = get_args(annotation)
365
+ type_annotation = annotated_args[0]
366
+ fastapi_annotations = [
367
+ arg
368
+ for arg in annotated_args[1:]
369
+ if isinstance(arg, (FieldInfo, params.Depends))
370
+ ]
371
+ fastapi_specific_annotations = [
372
+ arg
373
+ for arg in fastapi_annotations
374
+ if isinstance(arg, (params.Param, params.Body, params.Depends))
375
+ ]
376
+ if fastapi_specific_annotations:
377
+ fastapi_annotation: Union[FieldInfo, params.Depends, None] = (
378
+ fastapi_specific_annotations[-1]
379
+ )
380
+ else:
381
+ fastapi_annotation = None
382
+ # Set default for Annotated FieldInfo
383
+ if isinstance(fastapi_annotation, FieldInfo):
384
+ # Copy `field_info` because we mutate `field_info.default` below.
385
+ field_info = copy_field_info(
386
+ field_info=fastapi_annotation, annotation=use_annotation
387
+ )
388
+ assert (
389
+ field_info.default is Undefined or field_info.default is RequiredParam
390
+ ), (
391
+ f"`{field_info.__class__.__name__}` default value cannot be set in"
392
+ f" `Annotated` for {param_name!r}. Set the default value with `=` instead."
393
+ )
394
+ if value is not inspect.Signature.empty:
395
+ assert not is_path_param, "Path parameters cannot have default values"
396
+ field_info.default = value
397
+ else:
398
+ field_info.default = RequiredParam
399
+ # Get Annotated Depends
400
+ elif isinstance(fastapi_annotation, params.Depends):
401
+ depends = fastapi_annotation
402
+ # Get Depends from default value
403
+ if isinstance(value, params.Depends):
404
+ assert depends is None, (
405
+ "Cannot specify `Depends` in `Annotated` and default value"
406
+ f" together for {param_name!r}"
407
+ )
408
+ assert field_info is None, (
409
+ "Cannot specify a FastAPI annotation in `Annotated` and `Depends` as a"
410
+ f" default value together for {param_name!r}"
411
+ )
412
+ depends = value
413
+ # Get FieldInfo from default value
414
+ elif isinstance(value, FieldInfo):
415
+ assert field_info is None, (
416
+ "Cannot specify FastAPI annotations in `Annotated` and default value"
417
+ f" together for {param_name!r}"
418
+ )
419
+ field_info = value
420
+ if PYDANTIC_V2:
421
+ field_info.annotation = type_annotation
422
+
423
+ # Get Depends from type annotation
424
+ if depends is not None and depends.dependency is None:
425
+ # Copy `depends` before mutating it
426
+ depends = copy(depends)
427
+ depends.dependency = type_annotation
428
+
429
+ # Handle non-param type annotations like Request
430
+ if lenient_issubclass(
431
+ type_annotation,
432
+ (
433
+ Request,
434
+ WebSocket,
435
+ HTTPConnection,
436
+ Response,
437
+ StarletteBackgroundTasks,
438
+ SecurityScopes,
439
+ ),
440
+ ):
441
+ assert depends is None, f"Cannot specify `Depends` for type {type_annotation!r}"
442
+ assert (
443
+ field_info is None
444
+ ), f"Cannot specify FastAPI annotation for type {type_annotation!r}"
445
+ # Handle default assignations, neither field_info nor depends was not found in Annotated nor default value
446
+ elif field_info is None and depends is None:
447
+ default_value = value if value is not inspect.Signature.empty else RequiredParam
448
+ if is_path_param:
449
+ # We might check here that `default_value is RequiredParam`, but the fact is that the same
450
+ # parameter might sometimes be a path parameter and sometimes not. See
451
+ # `tests/test_infer_param_optionality.py` for an example.
452
+ field_info = params.Path(annotation=use_annotation)
453
+ elif is_uploadfile_or_nonable_uploadfile_annotation(
454
+ type_annotation
455
+ ) or is_uploadfile_sequence_annotation(type_annotation):
456
+ field_info = params.File(annotation=use_annotation, default=default_value)
457
+ elif not field_annotation_is_scalar(annotation=type_annotation):
458
+ field_info = params.Body(annotation=use_annotation, default=default_value)
459
+ else:
460
+ field_info = params.Query(annotation=use_annotation, default=default_value)
461
+
462
+ field = None
463
+ # It's a field_info, not a dependency
464
+ if field_info is not None:
465
+ # Handle field_info.in_
466
+ if is_path_param:
467
+ assert isinstance(field_info, params.Path), (
468
+ f"Cannot use `{field_info.__class__.__name__}` for path param"
469
+ f" {param_name!r}"
470
+ )
471
+ elif (
472
+ isinstance(field_info, params.Param)
473
+ and getattr(field_info, "in_", None) is None
474
+ ):
475
+ field_info.in_ = params.ParamTypes.query
476
+ use_annotation_from_field_info = get_annotation_from_field_info(
477
+ use_annotation,
478
+ field_info,
479
+ param_name,
480
+ )
481
+ if isinstance(field_info, params.Form):
482
+ ensure_multipart_is_installed()
483
+ if not field_info.alias and getattr(field_info, "convert_underscores", None):
484
+ alias = param_name.replace("_", "-")
485
+ else:
486
+ alias = field_info.alias or param_name
487
+ field_info.alias = alias
488
+ field = create_model_field(
489
+ name=param_name,
490
+ type_=use_annotation_from_field_info,
491
+ default=field_info.default,
492
+ alias=alias,
493
+ required=field_info.default in (RequiredParam, Undefined),
494
+ field_info=field_info,
495
+ )
496
+ if is_path_param:
497
+ assert is_scalar_field(
498
+ field=field
499
+ ), "Path params must be of one of the supported types"
500
+ elif isinstance(field_info, params.Query):
501
+ assert (
502
+ is_scalar_field(field)
503
+ or is_scalar_sequence_field(field)
504
+ or (
505
+ lenient_issubclass(field.type_, BaseModel)
506
+ # For Pydantic v1
507
+ and getattr(field, "shape", 1) == 1
508
+ )
509
+ )
510
+
511
+ return ParamDetails(type_annotation=type_annotation, depends=depends, field=field)
512
+
513
+
514
+ def add_param_to_fields(*, field: ModelField, dependant: Dependant) -> None:
515
+ field_info = field.field_info
516
+ field_info_in = getattr(field_info, "in_", None)
517
+ if field_info_in == params.ParamTypes.path:
518
+ dependant.path_params.append(field)
519
+ elif field_info_in == params.ParamTypes.query:
520
+ dependant.query_params.append(field)
521
+ elif field_info_in == params.ParamTypes.header:
522
+ dependant.header_params.append(field)
523
+ else:
524
+ assert (
525
+ field_info_in == params.ParamTypes.cookie
526
+ ), f"non-body parameters must be in path, query, header or cookie: {field.name}"
527
+ dependant.cookie_params.append(field)
528
+
529
+
530
+ def is_coroutine_callable(call: Callable[..., Any]) -> bool:
531
+ if inspect.isroutine(call):
532
+ return inspect.iscoroutinefunction(call)
533
+ if inspect.isclass(call):
534
+ return False
535
+ dunder_call = getattr(call, "__call__", None) # noqa: B004
536
+ return inspect.iscoroutinefunction(dunder_call)
537
+
538
+
539
+ def is_async_gen_callable(call: Callable[..., Any]) -> bool:
540
+ if inspect.isasyncgenfunction(call):
541
+ return True
542
+ dunder_call = getattr(call, "__call__", None) # noqa: B004
543
+ return inspect.isasyncgenfunction(dunder_call)
544
+
545
+
546
+ def is_gen_callable(call: Callable[..., Any]) -> bool:
547
+ if inspect.isgeneratorfunction(call):
548
+ return True
549
+ dunder_call = getattr(call, "__call__", None) # noqa: B004
550
+ return inspect.isgeneratorfunction(dunder_call)
551
+
552
+
553
+ async def solve_generator(
554
+ *, call: Callable[..., Any], stack: AsyncExitStack, sub_values: Dict[str, Any]
555
+ ) -> Any:
556
+ if is_gen_callable(call):
557
+ cm = contextmanager_in_threadpool(contextmanager(call)(**sub_values))
558
+ elif is_async_gen_callable(call):
559
+ cm = asynccontextmanager(call)(**sub_values)
560
+ return await stack.enter_async_context(cm)
561
+
562
+
563
+ @dataclass
564
+ class SolvedDependency:
565
+ values: Dict[str, Any]
566
+ errors: List[Any]
567
+ background_tasks: Optional[StarletteBackgroundTasks]
568
+ response: Response
569
+ dependency_cache: Dict[Tuple[Callable[..., Any], Tuple[str]], Any]
570
+
571
+
572
+ async def solve_dependencies(
573
+ *,
574
+ request: Union[Request, WebSocket],
575
+ dependant: Dependant,
576
+ body: Optional[Union[Dict[str, Any], FormData]] = None,
577
+ background_tasks: Optional[StarletteBackgroundTasks] = None,
578
+ response: Optional[Response] = None,
579
+ dependency_overrides_provider: Optional[Any] = None,
580
+ dependency_cache: Optional[Dict[Tuple[Callable[..., Any], Tuple[str]], Any]] = None,
581
+ async_exit_stack: AsyncExitStack,
582
+ embed_body_fields: bool,
583
+ ) -> SolvedDependency:
584
+ values: Dict[str, Any] = {}
585
+ errors: List[Any] = []
586
+ if response is None:
587
+ response = Response()
588
+ del response.headers["content-length"]
589
+ response.status_code = None # type: ignore
590
+ dependency_cache = dependency_cache or {}
591
+ sub_dependant: Dependant
592
+ for sub_dependant in dependant.dependencies:
593
+ sub_dependant.call = cast(Callable[..., Any], sub_dependant.call)
594
+ sub_dependant.cache_key = cast(
595
+ Tuple[Callable[..., Any], Tuple[str]], sub_dependant.cache_key
596
+ )
597
+ call = sub_dependant.call
598
+ use_sub_dependant = sub_dependant
599
+ if (
600
+ dependency_overrides_provider
601
+ and dependency_overrides_provider.dependency_overrides
602
+ ):
603
+ original_call = sub_dependant.call
604
+ call = getattr(
605
+ dependency_overrides_provider, "dependency_overrides", {}
606
+ ).get(original_call, original_call)
607
+ use_path: str = sub_dependant.path # type: ignore
608
+ use_sub_dependant = get_dependant(
609
+ path=use_path,
610
+ call=call,
611
+ name=sub_dependant.name,
612
+ security_scopes=sub_dependant.security_scopes,
613
+ )
614
+
615
+ solved_result = await solve_dependencies(
616
+ request=request,
617
+ dependant=use_sub_dependant,
618
+ body=body,
619
+ background_tasks=background_tasks,
620
+ response=response,
621
+ dependency_overrides_provider=dependency_overrides_provider,
622
+ dependency_cache=dependency_cache,
623
+ async_exit_stack=async_exit_stack,
624
+ embed_body_fields=embed_body_fields,
625
+ )
626
+ background_tasks = solved_result.background_tasks
627
+ dependency_cache.update(solved_result.dependency_cache)
628
+ if solved_result.errors:
629
+ errors.extend(solved_result.errors)
630
+ continue
631
+ if sub_dependant.use_cache and sub_dependant.cache_key in dependency_cache:
632
+ solved = dependency_cache[sub_dependant.cache_key]
633
+ elif is_gen_callable(call) or is_async_gen_callable(call):
634
+ solved = await solve_generator(
635
+ call=call, stack=async_exit_stack, sub_values=solved_result.values
636
+ )
637
+ elif is_coroutine_callable(call):
638
+ solved = await call(**solved_result.values)
639
+ else:
640
+ solved = await run_in_threadpool(call, **solved_result.values)
641
+ if sub_dependant.name is not None:
642
+ values[sub_dependant.name] = solved
643
+ if sub_dependant.cache_key not in dependency_cache:
644
+ dependency_cache[sub_dependant.cache_key] = solved
645
+ path_values, path_errors = request_params_to_args(
646
+ dependant.path_params, request.path_params
647
+ )
648
+ query_values, query_errors = request_params_to_args(
649
+ dependant.query_params, request.query_params
650
+ )
651
+ header_values, header_errors = request_params_to_args(
652
+ dependant.header_params, request.headers
653
+ )
654
+ cookie_values, cookie_errors = request_params_to_args(
655
+ dependant.cookie_params, request.cookies
656
+ )
657
+ values.update(path_values)
658
+ values.update(query_values)
659
+ values.update(header_values)
660
+ values.update(cookie_values)
661
+ errors += path_errors + query_errors + header_errors + cookie_errors
662
+ if dependant.body_params:
663
+ (
664
+ body_values,
665
+ body_errors,
666
+ ) = await request_body_to_args( # body_params checked above
667
+ body_fields=dependant.body_params,
668
+ received_body=body,
669
+ embed_body_fields=embed_body_fields,
670
+ )
671
+ values.update(body_values)
672
+ errors.extend(body_errors)
673
+ if dependant.http_connection_param_name:
674
+ values[dependant.http_connection_param_name] = request
675
+ if dependant.request_param_name and isinstance(request, Request):
676
+ values[dependant.request_param_name] = request
677
+ elif dependant.websocket_param_name and isinstance(request, WebSocket):
678
+ values[dependant.websocket_param_name] = request
679
+ if dependant.background_tasks_param_name:
680
+ if background_tasks is None:
681
+ background_tasks = BackgroundTasks()
682
+ values[dependant.background_tasks_param_name] = background_tasks
683
+ if dependant.response_param_name:
684
+ values[dependant.response_param_name] = response
685
+ if dependant.security_scopes_param_name:
686
+ values[dependant.security_scopes_param_name] = SecurityScopes(
687
+ scopes=dependant.security_scopes
688
+ )
689
+ return SolvedDependency(
690
+ values=values,
691
+ errors=errors,
692
+ background_tasks=background_tasks,
693
+ response=response,
694
+ dependency_cache=dependency_cache,
695
+ )
696
+
697
+
698
+ def _validate_value_with_model_field(
699
+ *, field: ModelField, value: Any, values: Dict[str, Any], loc: Tuple[str, ...]
700
+ ) -> Tuple[Any, List[Any]]:
701
+ if value is None:
702
+ if field.required:
703
+ return None, [get_missing_field_error(loc=loc)]
704
+ else:
705
+ return deepcopy(field.default), []
706
+ v_, errors_ = field.validate(value, values, loc=loc)
707
+ if isinstance(errors_, ErrorWrapper):
708
+ return None, [errors_]
709
+ elif isinstance(errors_, list):
710
+ new_errors = _regenerate_error_with_loc(errors=errors_, loc_prefix=())
711
+ return None, new_errors
712
+ else:
713
+ return v_, []
714
+
715
+
716
+ def _get_multidict_value(
717
+ field: ModelField, values: Mapping[str, Any], alias: Union[str, None] = None
718
+ ) -> Any:
719
+ alias = alias or field.alias
720
+ if is_sequence_field(field) and isinstance(values, (ImmutableMultiDict, Headers)):
721
+ value = values.getlist(alias)
722
+ else:
723
+ value = values.get(alias, None)
724
+ if (
725
+ value is None
726
+ or (
727
+ isinstance(field.field_info, params.Form)
728
+ and isinstance(value, str) # For type checks
729
+ and value == ""
730
+ )
731
+ or (is_sequence_field(field) and len(value) == 0)
732
+ ):
733
+ if field.required:
734
+ return
735
+ else:
736
+ return deepcopy(field.default)
737
+ return value
738
+
739
+
740
+ def request_params_to_args(
741
+ fields: Sequence[ModelField],
742
+ received_params: Union[Mapping[str, Any], QueryParams, Headers],
743
+ ) -> Tuple[Dict[str, Any], List[Any]]:
744
+ values: Dict[str, Any] = {}
745
+ errors: List[Dict[str, Any]] = []
746
+
747
+ if not fields:
748
+ return values, errors
749
+
750
+ first_field = fields[0]
751
+ fields_to_extract = fields
752
+ single_not_embedded_field = False
753
+ if len(fields) == 1 and lenient_issubclass(first_field.type_, BaseModel):
754
+ fields_to_extract = get_cached_model_fields(first_field.type_)
755
+ single_not_embedded_field = True
756
+
757
+ params_to_process: Dict[str, Any] = {}
758
+
759
+ processed_keys = set()
760
+
761
+ for field in fields_to_extract:
762
+ alias = None
763
+ if isinstance(received_params, Headers):
764
+ # Handle fields extracted from a Pydantic Model for a header, each field
765
+ # doesn't have a FieldInfo of type Header with the default convert_underscores=True
766
+ convert_underscores = getattr(field.field_info, "convert_underscores", True)
767
+ if convert_underscores:
768
+ alias = (
769
+ field.alias
770
+ if field.alias != field.name
771
+ else field.name.replace("_", "-")
772
+ )
773
+ value = _get_multidict_value(field, received_params, alias=alias)
774
+ if value is not None:
775
+ params_to_process[field.name] = value
776
+ processed_keys.add(alias or field.alias)
777
+ processed_keys.add(field.name)
778
+
779
+ for key, value in received_params.items():
780
+ if key not in processed_keys:
781
+ params_to_process[key] = value
782
+
783
+ if single_not_embedded_field:
784
+ field_info = first_field.field_info
785
+ assert isinstance(
786
+ field_info, params.Param
787
+ ), "Params must be subclasses of Param"
788
+ loc: Tuple[str, ...] = (field_info.in_.value,)
789
+ v_, errors_ = _validate_value_with_model_field(
790
+ field=first_field, value=params_to_process, values=values, loc=loc
791
+ )
792
+ return {first_field.name: v_}, errors_
793
+
794
+ for field in fields:
795
+ value = _get_multidict_value(field, received_params)
796
+ field_info = field.field_info
797
+ assert isinstance(
798
+ field_info, params.Param
799
+ ), "Params must be subclasses of Param"
800
+ loc = (field_info.in_.value, field.alias)
801
+ v_, errors_ = _validate_value_with_model_field(
802
+ field=field, value=value, values=values, loc=loc
803
+ )
804
+ if errors_:
805
+ errors.extend(errors_)
806
+ else:
807
+ values[field.name] = v_
808
+ return values, errors
809
+
810
+
811
+ def _should_embed_body_fields(fields: List[ModelField]) -> bool:
812
+ if not fields:
813
+ return False
814
+ # More than one dependency could have the same field, it would show up as multiple
815
+ # fields but it's the same one, so count them by name
816
+ body_param_names_set = {field.name for field in fields}
817
+ # A top level field has to be a single field, not multiple
818
+ if len(body_param_names_set) > 1:
819
+ return True
820
+ first_field = fields[0]
821
+ # If it explicitly specifies it is embedded, it has to be embedded
822
+ if getattr(first_field.field_info, "embed", None):
823
+ return True
824
+ # If it's a Form (or File) field, it has to be a BaseModel to be top level
825
+ # otherwise it has to be embedded, so that the key value pair can be extracted
826
+ if isinstance(first_field.field_info, params.Form) and not lenient_issubclass(
827
+ first_field.type_, BaseModel
828
+ ):
829
+ return True
830
+ return False
831
+
832
+
833
+ async def _extract_form_body(
834
+ body_fields: List[ModelField],
835
+ received_body: FormData,
836
+ ) -> Dict[str, Any]:
837
+ values = {}
838
+ first_field = body_fields[0]
839
+ first_field_info = first_field.field_info
840
+
841
+ for field in body_fields:
842
+ value = _get_multidict_value(field, received_body)
843
+ if (
844
+ isinstance(first_field_info, params.File)
845
+ and is_bytes_field(field)
846
+ and isinstance(value, UploadFile)
847
+ ):
848
+ value = await value.read()
849
+ elif (
850
+ is_bytes_sequence_field(field)
851
+ and isinstance(first_field_info, params.File)
852
+ and value_is_sequence(value)
853
+ ):
854
+ # For types
855
+ assert isinstance(value, sequence_types) # type: ignore[arg-type]
856
+ results: List[Union[bytes, str]] = []
857
+
858
+ async def process_fn(
859
+ fn: Callable[[], Coroutine[Any, Any, Any]],
860
+ ) -> None:
861
+ result = await fn()
862
+ results.append(result) # noqa: B023
863
+
864
+ async with anyio.create_task_group() as tg:
865
+ for sub_value in value:
866
+ tg.start_soon(process_fn, sub_value.read)
867
+ value = serialize_sequence_value(field=field, value=results)
868
+ if value is not None:
869
+ values[field.alias] = value
870
+ for key, value in received_body.items():
871
+ if key not in values:
872
+ values[key] = value
873
+ return values
874
+
875
+
876
+ async def request_body_to_args(
877
+ body_fields: List[ModelField],
878
+ received_body: Optional[Union[Dict[str, Any], FormData]],
879
+ embed_body_fields: bool,
880
+ ) -> Tuple[Dict[str, Any], List[Dict[str, Any]]]:
881
+ values: Dict[str, Any] = {}
882
+ errors: List[Dict[str, Any]] = []
883
+ assert body_fields, "request_body_to_args() should be called with fields"
884
+ single_not_embedded_field = len(body_fields) == 1 and not embed_body_fields
885
+ first_field = body_fields[0]
886
+ body_to_process = received_body
887
+
888
+ fields_to_extract: List[ModelField] = body_fields
889
+
890
+ if single_not_embedded_field and lenient_issubclass(first_field.type_, BaseModel):
891
+ fields_to_extract = get_cached_model_fields(first_field.type_)
892
+
893
+ if isinstance(received_body, FormData):
894
+ body_to_process = await _extract_form_body(fields_to_extract, received_body)
895
+
896
+ if single_not_embedded_field:
897
+ loc: Tuple[str, ...] = ("body",)
898
+ v_, errors_ = _validate_value_with_model_field(
899
+ field=first_field, value=body_to_process, values=values, loc=loc
900
+ )
901
+ return {first_field.name: v_}, errors_
902
+ for field in body_fields:
903
+ loc = ("body", field.alias)
904
+ value: Optional[Any] = None
905
+ if body_to_process is not None:
906
+ try:
907
+ value = body_to_process.get(field.alias)
908
+ # If the received body is a list, not a dict
909
+ except AttributeError:
910
+ errors.append(get_missing_field_error(loc))
911
+ continue
912
+ v_, errors_ = _validate_value_with_model_field(
913
+ field=field, value=value, values=values, loc=loc
914
+ )
915
+ if errors_:
916
+ errors.extend(errors_)
917
+ else:
918
+ values[field.name] = v_
919
+ return values, errors
920
+
921
+
922
+ def get_body_field(
923
+ *, flat_dependant: Dependant, name: str, embed_body_fields: bool
924
+ ) -> Optional[ModelField]:
925
+ """
926
+ Get a ModelField representing the request body for a path operation, combining
927
+ all body parameters into a single field if necessary.
928
+
929
+ Used to check if it's form data (with `isinstance(body_field, params.Form)`)
930
+ or JSON and to generate the JSON Schema for a request body.
931
+
932
+ This is **not** used to validate/parse the request body, that's done with each
933
+ individual body parameter.
934
+ """
935
+ if not flat_dependant.body_params:
936
+ return None
937
+ first_param = flat_dependant.body_params[0]
938
+ if not embed_body_fields:
939
+ return first_param
940
+ model_name = "Body_" + name
941
+ BodyModel = create_body_model(
942
+ fields=flat_dependant.body_params, model_name=model_name
943
+ )
944
+ required = any(True for f in flat_dependant.body_params if f.required)
945
+ BodyFieldInfo_kwargs: Dict[str, Any] = {
946
+ "annotation": BodyModel,
947
+ "alias": "body",
948
+ }
949
+ if not required:
950
+ BodyFieldInfo_kwargs["default"] = None
951
+ if any(isinstance(f.field_info, params.File) for f in flat_dependant.body_params):
952
+ BodyFieldInfo: Type[params.Body] = params.File
953
+ elif any(isinstance(f.field_info, params.Form) for f in flat_dependant.body_params):
954
+ BodyFieldInfo = params.Form
955
+ else:
956
+ BodyFieldInfo = params.Body
957
+
958
+ body_param_media_types = [
959
+ f.field_info.media_type
960
+ for f in flat_dependant.body_params
961
+ if isinstance(f.field_info, params.Body)
962
+ ]
963
+ if len(set(body_param_media_types)) == 1:
964
+ BodyFieldInfo_kwargs["media_type"] = body_param_media_types[0]
965
+ final_field = create_model_field(
966
+ name="body",
967
+ type_=BodyModel,
968
+ required=required,
969
+ alias="body",
970
+ field_info=BodyFieldInfo(**BodyFieldInfo_kwargs),
971
+ )
972
+ return final_field
vllm/lib/python3.10/site-packages/fastapi/middleware/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from starlette.middleware import Middleware as Middleware
vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (223 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/cors.cpython-310.pyc ADDED
Binary file (228 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/gzip.cpython-310.pyc ADDED
Binary file (228 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/httpsredirect.cpython-310.pyc ADDED
Binary file (255 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/trustedhost.cpython-310.pyc ADDED
Binary file (249 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/middleware/__pycache__/wsgi.cpython-310.pyc ADDED
Binary file (228 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/middleware/cors.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from starlette.middleware.cors import CORSMiddleware as CORSMiddleware # noqa
vllm/lib/python3.10/site-packages/fastapi/middleware/gzip.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from starlette.middleware.gzip import GZipMiddleware as GZipMiddleware # noqa
vllm/lib/python3.10/site-packages/fastapi/middleware/httpsredirect.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from starlette.middleware.httpsredirect import ( # noqa
2
+ HTTPSRedirectMiddleware as HTTPSRedirectMiddleware,
3
+ )
vllm/lib/python3.10/site-packages/fastapi/middleware/trustedhost.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from starlette.middleware.trustedhost import ( # noqa
2
+ TrustedHostMiddleware as TrustedHostMiddleware,
3
+ )
vllm/lib/python3.10/site-packages/fastapi/middleware/wsgi.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from starlette.middleware.wsgi import WSGIMiddleware as WSGIMiddleware # noqa
vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (165 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/constants.cpython-310.pyc ADDED
Binary file (323 Bytes). View file
 
vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/docs.cpython-310.pyc ADDED
Binary file (9.56 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/models.cpython-310.pyc ADDED
Binary file (16.7 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/openapi/__pycache__/utils.cpython-310.pyc ADDED
Binary file (12 kB). View file
 
vllm/lib/python3.10/site-packages/fastapi/openapi/constants.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ METHODS_WITH_BODY = {"GET", "HEAD", "POST", "PUT", "DELETE", "PATCH"}
2
+ REF_PREFIX = "#/components/schemas/"
3
+ REF_TEMPLATE = "#/components/schemas/{model}"
vllm/lib/python3.10/site-packages/fastapi/openapi/docs.py ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from typing import Any, Dict, Optional
3
+
4
+ from fastapi.encoders import jsonable_encoder
5
+ from starlette.responses import HTMLResponse
6
+ from typing_extensions import Annotated, Doc
7
+
8
+ swagger_ui_default_parameters: Annotated[
9
+ Dict[str, Any],
10
+ Doc(
11
+ """
12
+ Default configurations for Swagger UI.
13
+
14
+ You can use it as a template to add any other configurations needed.
15
+ """
16
+ ),
17
+ ] = {
18
+ "dom_id": "#swagger-ui",
19
+ "layout": "BaseLayout",
20
+ "deepLinking": True,
21
+ "showExtensions": True,
22
+ "showCommonExtensions": True,
23
+ }
24
+
25
+
26
+ def get_swagger_ui_html(
27
+ *,
28
+ openapi_url: Annotated[
29
+ str,
30
+ Doc(
31
+ """
32
+ The OpenAPI URL that Swagger UI should load and use.
33
+
34
+ This is normally done automatically by FastAPI using the default URL
35
+ `/openapi.json`.
36
+ """
37
+ ),
38
+ ],
39
+ title: Annotated[
40
+ str,
41
+ Doc(
42
+ """
43
+ The HTML `<title>` content, normally shown in the browser tab.
44
+ """
45
+ ),
46
+ ],
47
+ swagger_js_url: Annotated[
48
+ str,
49
+ Doc(
50
+ """
51
+ The URL to use to load the Swagger UI JavaScript.
52
+
53
+ It is normally set to a CDN URL.
54
+ """
55
+ ),
56
+ ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js",
57
+ swagger_css_url: Annotated[
58
+ str,
59
+ Doc(
60
+ """
61
+ The URL to use to load the Swagger UI CSS.
62
+
63
+ It is normally set to a CDN URL.
64
+ """
65
+ ),
66
+ ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css",
67
+ swagger_favicon_url: Annotated[
68
+ str,
69
+ Doc(
70
+ """
71
+ The URL of the favicon to use. It is normally shown in the browser tab.
72
+ """
73
+ ),
74
+ ] = "https://fastapi.tiangolo.com/img/favicon.png",
75
+ oauth2_redirect_url: Annotated[
76
+ Optional[str],
77
+ Doc(
78
+ """
79
+ The OAuth2 redirect URL, it is normally automatically handled by FastAPI.
80
+ """
81
+ ),
82
+ ] = None,
83
+ init_oauth: Annotated[
84
+ Optional[Dict[str, Any]],
85
+ Doc(
86
+ """
87
+ A dictionary with Swagger UI OAuth2 initialization configurations.
88
+ """
89
+ ),
90
+ ] = None,
91
+ swagger_ui_parameters: Annotated[
92
+ Optional[Dict[str, Any]],
93
+ Doc(
94
+ """
95
+ Configuration parameters for Swagger UI.
96
+
97
+ It defaults to [swagger_ui_default_parameters][fastapi.openapi.docs.swagger_ui_default_parameters].
98
+ """
99
+ ),
100
+ ] = None,
101
+ ) -> HTMLResponse:
102
+ """
103
+ Generate and return the HTML that loads Swagger UI for the interactive
104
+ API docs (normally served at `/docs`).
105
+
106
+ You would only call this function yourself if you needed to override some parts,
107
+ for example the URLs to use to load Swagger UI's JavaScript and CSS.
108
+
109
+ Read more about it in the
110
+ [FastAPI docs for Configure Swagger UI](https://fastapi.tiangolo.com/how-to/configure-swagger-ui/)
111
+ and the [FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
112
+ """
113
+ current_swagger_ui_parameters = swagger_ui_default_parameters.copy()
114
+ if swagger_ui_parameters:
115
+ current_swagger_ui_parameters.update(swagger_ui_parameters)
116
+
117
+ html = f"""
118
+ <!DOCTYPE html>
119
+ <html>
120
+ <head>
121
+ <link type="text/css" rel="stylesheet" href="{swagger_css_url}">
122
+ <link rel="shortcut icon" href="{swagger_favicon_url}">
123
+ <title>{title}</title>
124
+ </head>
125
+ <body>
126
+ <div id="swagger-ui">
127
+ </div>
128
+ <script src="{swagger_js_url}"></script>
129
+ <!-- `SwaggerUIBundle` is now available on the page -->
130
+ <script>
131
+ const ui = SwaggerUIBundle({{
132
+ url: '{openapi_url}',
133
+ """
134
+
135
+ for key, value in current_swagger_ui_parameters.items():
136
+ html += f"{json.dumps(key)}: {json.dumps(jsonable_encoder(value))},\n"
137
+
138
+ if oauth2_redirect_url:
139
+ html += f"oauth2RedirectUrl: window.location.origin + '{oauth2_redirect_url}',"
140
+
141
+ html += """
142
+ presets: [
143
+ SwaggerUIBundle.presets.apis,
144
+ SwaggerUIBundle.SwaggerUIStandalonePreset
145
+ ],
146
+ })"""
147
+
148
+ if init_oauth:
149
+ html += f"""
150
+ ui.initOAuth({json.dumps(jsonable_encoder(init_oauth))})
151
+ """
152
+
153
+ html += """
154
+ </script>
155
+ </body>
156
+ </html>
157
+ """
158
+ return HTMLResponse(html)
159
+
160
+
161
+ def get_redoc_html(
162
+ *,
163
+ openapi_url: Annotated[
164
+ str,
165
+ Doc(
166
+ """
167
+ The OpenAPI URL that ReDoc should load and use.
168
+
169
+ This is normally done automatically by FastAPI using the default URL
170
+ `/openapi.json`.
171
+ """
172
+ ),
173
+ ],
174
+ title: Annotated[
175
+ str,
176
+ Doc(
177
+ """
178
+ The HTML `<title>` content, normally shown in the browser tab.
179
+ """
180
+ ),
181
+ ],
182
+ redoc_js_url: Annotated[
183
+ str,
184
+ Doc(
185
+ """
186
+ The URL to use to load the ReDoc JavaScript.
187
+
188
+ It is normally set to a CDN URL.
189
+ """
190
+ ),
191
+ ] = "https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js",
192
+ redoc_favicon_url: Annotated[
193
+ str,
194
+ Doc(
195
+ """
196
+ The URL of the favicon to use. It is normally shown in the browser tab.
197
+ """
198
+ ),
199
+ ] = "https://fastapi.tiangolo.com/img/favicon.png",
200
+ with_google_fonts: Annotated[
201
+ bool,
202
+ Doc(
203
+ """
204
+ Load and use Google Fonts.
205
+ """
206
+ ),
207
+ ] = True,
208
+ ) -> HTMLResponse:
209
+ """
210
+ Generate and return the HTML response that loads ReDoc for the alternative
211
+ API docs (normally served at `/redoc`).
212
+
213
+ You would only call this function yourself if you needed to override some parts,
214
+ for example the URLs to use to load ReDoc's JavaScript and CSS.
215
+
216
+ Read more about it in the
217
+ [FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
218
+ """
219
+ html = f"""
220
+ <!DOCTYPE html>
221
+ <html>
222
+ <head>
223
+ <title>{title}</title>
224
+ <!-- needed for adaptive design -->
225
+ <meta charset="utf-8"/>
226
+ <meta name="viewport" content="width=device-width, initial-scale=1">
227
+ """
228
+ if with_google_fonts:
229
+ html += """
230
+ <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
231
+ """
232
+ html += f"""
233
+ <link rel="shortcut icon" href="{redoc_favicon_url}">
234
+ <!--
235
+ ReDoc doesn't change outer page styles
236
+ -->
237
+ <style>
238
+ body {{
239
+ margin: 0;
240
+ padding: 0;
241
+ }}
242
+ </style>
243
+ </head>
244
+ <body>
245
+ <noscript>
246
+ ReDoc requires Javascript to function. Please enable it to browse the documentation.
247
+ </noscript>
248
+ <redoc spec-url="{openapi_url}"></redoc>
249
+ <script src="{redoc_js_url}"> </script>
250
+ </body>
251
+ </html>
252
+ """
253
+ return HTMLResponse(html)
254
+
255
+
256
+ def get_swagger_ui_oauth2_redirect_html() -> HTMLResponse:
257
+ """
258
+ Generate the HTML response with the OAuth2 redirection for Swagger UI.
259
+
260
+ You normally don't need to use or change this.
261
+ """
262
+ # copied from https://github.com/swagger-api/swagger-ui/blob/v4.14.0/dist/oauth2-redirect.html
263
+ html = """
264
+ <!doctype html>
265
+ <html lang="en-US">
266
+ <head>
267
+ <title>Swagger UI: OAuth2 Redirect</title>
268
+ </head>
269
+ <body>
270
+ <script>
271
+ 'use strict';
272
+ function run () {
273
+ var oauth2 = window.opener.swaggerUIRedirectOauth2;
274
+ var sentState = oauth2.state;
275
+ var redirectUrl = oauth2.redirectUrl;
276
+ var isValid, qp, arr;
277
+
278
+ if (/code|token|error/.test(window.location.hash)) {
279
+ qp = window.location.hash.substring(1).replace('?', '&');
280
+ } else {
281
+ qp = location.search.substring(1);
282
+ }
283
+
284
+ arr = qp.split("&");
285
+ arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';});
286
+ qp = qp ? JSON.parse('{' + arr.join() + '}',
287
+ function (key, value) {
288
+ return key === "" ? value : decodeURIComponent(value);
289
+ }
290
+ ) : {};
291
+
292
+ isValid = qp.state === sentState;
293
+
294
+ if ((
295
+ oauth2.auth.schema.get("flow") === "accessCode" ||
296
+ oauth2.auth.schema.get("flow") === "authorizationCode" ||
297
+ oauth2.auth.schema.get("flow") === "authorization_code"
298
+ ) && !oauth2.auth.code) {
299
+ if (!isValid) {
300
+ oauth2.errCb({
301
+ authId: oauth2.auth.name,
302
+ source: "auth",
303
+ level: "warning",
304
+ message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server."
305
+ });
306
+ }
307
+
308
+ if (qp.code) {
309
+ delete oauth2.state;
310
+ oauth2.auth.code = qp.code;
311
+ oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
312
+ } else {
313
+ let oauthErrorMsg;
314
+ if (qp.error) {
315
+ oauthErrorMsg = "["+qp.error+"]: " +
316
+ (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
317
+ (qp.error_uri ? "More info: "+qp.error_uri : "");
318
+ }
319
+
320
+ oauth2.errCb({
321
+ authId: oauth2.auth.name,
322
+ source: "auth",
323
+ level: "error",
324
+ message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server."
325
+ });
326
+ }
327
+ } else {
328
+ oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
329
+ }
330
+ window.close();
331
+ }
332
+
333
+ if (document.readyState !== 'loading') {
334
+ run();
335
+ } else {
336
+ document.addEventListener('DOMContentLoaded', function () {
337
+ run();
338
+ });
339
+ }
340
+ </script>
341
+ </body>
342
+ </html>
343
+ """
344
+ return HTMLResponse(content=html)