Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -27,19 +27,15 @@ class HuggingFaceInferenceWrapper:
|
|
27 |
self.inference_api = inference_api
|
28 |
|
29 |
def generate(self, prompt: str, **kwargs) -> str:
|
30 |
-
#
|
31 |
-
response = self.inference_api(inputs=prompt
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
return result_json["outputs"].strip()
|
40 |
-
|
41 |
-
# If unknown format, fallback
|
42 |
-
return str(result_json)
|
43 |
|
44 |
|
45 |
|
|
|
27 |
self.inference_api = inference_api
|
28 |
|
29 |
def generate(self, prompt: str, **kwargs) -> str:
|
30 |
+
# Call inference API - returns string directly
|
31 |
+
response = self.inference_api(inputs=prompt)
|
32 |
+
if isinstance(response, str):
|
33 |
+
return response.strip()
|
34 |
+
elif hasattr(response, 'text'):
|
35 |
+
return response.text.strip()
|
36 |
+
else:
|
37 |
+
# Handle JSON response
|
38 |
+
return str(response)
|
|
|
|
|
|
|
|
|
39 |
|
40 |
|
41 |
|