Spaces:
Runtime error
Runtime error
Update utils/optimizer.py
Browse files- utils/optimizer.py +17 -17
utils/optimizer.py
CHANGED
|
@@ -180,28 +180,28 @@ class ContentOptimizer:
|
|
| 180 |
# Use dedicated rewrite prompt for optimization
|
| 181 |
prompt_text = self.optimization_rewrite_prompt
|
| 182 |
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
|
| 188 |
-
|
| 189 |
-
|
| 190 |
|
| 191 |
-
|
| 192 |
-
|
| 193 |
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
|
| 201 |
-
|
| 202 |
|
| 203 |
-
|
| 204 |
-
|
| 205 |
def _seo_style_optimization(self, content: str, analyze_only: bool) -> Dict[str, Any]:
|
| 206 |
"""SEO-focused optimization for AI search engines"""
|
| 207 |
try:
|
|
|
|
| 180 |
# Use dedicated rewrite prompt for optimization
|
| 181 |
prompt_text = self.optimization_rewrite_prompt
|
| 182 |
|
| 183 |
+
prompt_template = ChatPromptTemplate.from_messages([
|
| 184 |
+
SystemMessagePromptTemplate.from_template(prompt_text),
|
| 185 |
+
HumanMessagePromptTemplate.from_template(content[:6000])
|
| 186 |
+
])
|
| 187 |
|
| 188 |
+
chain = prompt_template | self.llm
|
| 189 |
+
result = chain.invoke({})
|
| 190 |
|
| 191 |
+
result_content = result.content if hasattr(result, 'content') else str(result)
|
| 192 |
+
parsed_result = self._parse_optimization_result(result_content)
|
| 193 |
|
| 194 |
+
parsed_result.update({
|
| 195 |
+
'optimization_type': 'standard',
|
| 196 |
+
'analyze_only': analyze_only,
|
| 197 |
+
'original_length': len(content),
|
| 198 |
+
'original_word_count': len(content.split())
|
| 199 |
+
})
|
| 200 |
|
| 201 |
+
return parsed_result
|
| 202 |
|
| 203 |
+
except Exception as e:
|
| 204 |
+
return {'error': f"Standard optimization failed: {str(e)}"}
|
| 205 |
def _seo_style_optimization(self, content: str, analyze_only: bool) -> Dict[str, Any]:
|
| 206 |
"""SEO-focused optimization for AI search engines"""
|
| 207 |
try:
|