Spaces:
Sleeping
Sleeping
Fix: LLM summarization failed: string indices must be integers
Browse files
app.py
CHANGED
|
@@ -36,8 +36,18 @@ def brief_text_in_n_sentences(text:str, n:int)-> str: #it's import to specify th
|
|
| 36 |
)
|
| 37 |
|
| 38 |
try:
|
|
|
|
|
|
|
| 39 |
response = model(prompt)
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
except Exception as e:
|
| 42 |
return f"LLM summarization failed: {str(e)}"
|
| 43 |
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
try:
|
| 39 |
+
# response = model(prompt)
|
| 40 |
+
# return response
|
| 41 |
response = model(prompt)
|
| 42 |
+
# If model returns a dictionary or list, handle accordingly
|
| 43 |
+
if isinstance(response, dict) and "generated_text" in response:
|
| 44 |
+
return response["generated_text"]
|
| 45 |
+
elif isinstance(response, list) and "generated_text" in response[0]:
|
| 46 |
+
return response[0]["generated_text"]
|
| 47 |
+
elif isinstance(response, str):
|
| 48 |
+
return response # Already a string, nothing to do
|
| 49 |
+
else:
|
| 50 |
+
return f"Unexpected response format: {response}"
|
| 51 |
except Exception as e:
|
| 52 |
return f"LLM summarization failed: {str(e)}"
|
| 53 |
|