Spaces:
Sleeping
Sleeping
Commit ·
2fabcd9
1
Parent(s): f62b5cf
Added proper handling of the ChatMessage response at BlogGenerator
Browse files- tools/blog_generator.py +9 -3
tools/blog_generator.py
CHANGED
|
@@ -49,8 +49,14 @@ class BlogGeneratorTool(Tool):
|
|
| 49 |
# Call the model with properly formatted messages
|
| 50 |
response = self.model(messages)
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
return {
|
| 55 |
"status": "error",
|
| 56 |
"message": "Generated content too short or empty"
|
|
@@ -58,7 +64,7 @@ class BlogGeneratorTool(Tool):
|
|
| 58 |
|
| 59 |
return {
|
| 60 |
"status": "success",
|
| 61 |
-
"content":
|
| 62 |
}
|
| 63 |
|
| 64 |
except Exception as e:
|
|
|
|
| 49 |
# Call the model with properly formatted messages
|
| 50 |
response = self.model(messages)
|
| 51 |
|
| 52 |
+
# Extract content from ChatMessage response
|
| 53 |
+
if hasattr(response, 'content'):
|
| 54 |
+
content = response.content
|
| 55 |
+
else:
|
| 56 |
+
content = str(response)
|
| 57 |
+
|
| 58 |
+
# Validate the content
|
| 59 |
+
if not content or len(content) < 100:
|
| 60 |
return {
|
| 61 |
"status": "error",
|
| 62 |
"message": "Generated content too short or empty"
|
|
|
|
| 64 |
|
| 65 |
return {
|
| 66 |
"status": "success",
|
| 67 |
+
"content": content
|
| 68 |
}
|
| 69 |
|
| 70 |
except Exception as e:
|