Spaces:
Runtime error
Runtime error
Commit
·
4598698
1
Parent(s):
7055ca8
Fixing dockerfile v5
Browse files- src/api.py +11 -10
src/api.py
CHANGED
@@ -27,16 +27,17 @@ class InferenceApi(LitAPI):
|
|
27 |
)
|
28 |
self.logger.info(f"Inference API setup completed on device: {device}")
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
40 |
|
41 |
def decode_request(self, request: Any, **kwargs) -> str:
|
42 |
"""Convert the request payload to input format."""
|
|
|
27 |
)
|
28 |
self.logger.info(f"Inference API setup completed on device: {device}")
|
29 |
|
30 |
+
async def predict(self, x: str, **kwargs) -> Union[str, Iterator[str]]:
|
31 |
+
"""
|
32 |
+
Main prediction method required by LitAPI.
|
33 |
+
If streaming is enabled, yields chunks; otherwise returns via yield.
|
34 |
+
"""
|
35 |
+
if self.stream:
|
36 |
+
async for chunk in self.generate_stream(x, **kwargs):
|
37 |
+
yield chunk
|
38 |
+
else:
|
39 |
+
response = await self.generate_response(x, **kwargs)
|
40 |
+
yield response
|
41 |
|
42 |
def decode_request(self, request: Any, **kwargs) -> str:
|
43 |
"""Convert the request payload to input format."""
|