Spaces:
Runtime error
Runtime error
Commit
·
0cbf645
1
Parent(s):
0752952
Fixed await issue
Browse files- main/api.py +3 -6
main/api.py
CHANGED
|
@@ -63,14 +63,11 @@ class InferenceApi(LitAPI):
|
|
| 63 |
stream: bool = False
|
| 64 |
) -> Any:
|
| 65 |
"""Make an authenticated request to the LLM Server."""
|
| 66 |
-
base_url = self.llm_config.get('host', 'http://localhost:8002')
|
| 67 |
-
full_endpoint = f"{base_url.rstrip('/')}/{self._get_endpoint(endpoint).lstrip('/')}"
|
| 68 |
-
|
| 69 |
try:
|
| 70 |
-
self.logger.info(f"Making {method} request to: {full_endpoint}")
|
| 71 |
async with await self._get_client() as client:
|
| 72 |
if stream:
|
| 73 |
-
|
|
|
|
| 74 |
method,
|
| 75 |
self._get_endpoint(endpoint),
|
| 76 |
params=params,
|
|
@@ -87,7 +84,7 @@ class InferenceApi(LitAPI):
|
|
| 87 |
return response
|
| 88 |
|
| 89 |
except Exception as e:
|
| 90 |
-
self.logger.error(f"Error in request to {
|
| 91 |
raise
|
| 92 |
|
| 93 |
def predict(self, x: str, **kwargs) -> Iterator[str]:
|
|
|
|
| 63 |
stream: bool = False
|
| 64 |
) -> Any:
|
| 65 |
"""Make an authenticated request to the LLM Server."""
|
|
|
|
|
|
|
|
|
|
| 66 |
try:
|
|
|
|
| 67 |
async with await self._get_client() as client:
|
| 68 |
if stream:
|
| 69 |
+
# Return the context manager directly, don't await it
|
| 70 |
+
return client.stream(
|
| 71 |
method,
|
| 72 |
self._get_endpoint(endpoint),
|
| 73 |
params=params,
|
|
|
|
| 84 |
return response
|
| 85 |
|
| 86 |
except Exception as e:
|
| 87 |
+
self.logger.error(f"Error in request to {endpoint}: {str(e)}")
|
| 88 |
raise
|
| 89 |
|
| 90 |
def predict(self, x: str, **kwargs) -> Iterator[str]:
|