MCPcopy Create free account
hub / github.com/pollinations/pollinations / parse_highlights_response

Function parse_highlights_response

social/scripts/generate_daily.py:104–116  ·  view source on GitHub ↗

Clean up AI response, removing code blocks if present

(response: str)

Source from the content-addressed store, hash-verified

102
103
104def parse_highlights_response(response: str) -> str:
105 """Clean up AI response, removing code blocks if present"""
106 message = response.strip()
107
108 if message.startswith('```'):
109 lines = message.split('\n')
110 if lines[0].strip() == '```' or lines[0].startswith('```'):
111 lines = lines[1:]
112 if lines and lines[-1].strip() == '```':
113 lines = lines[:-1]
114 message = '\n'.join(lines)
115
116 return message.strip()
117
118
119def merge_highlights(new_highlights: str, existing_highlights: str) -> str:

Callers 1

generate_highlightsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected