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

Function load_shared

social/scripts/common.py:151–184  ·  view source on GitHub ↗

Load a brand prompt component from prompts/brand/{name}.md Args: name: 'about', 'visual', 'bee', 'links' Returns: The brand prompt content

(name: str)

Source from the content-addressed store, hash-verified

149
150
151def load_shared(name: str) -> str:
152 """Load a brand prompt component from prompts/brand/{name}.md
153
154 Args:
155 name: 'about', 'visual', 'bee', 'links'
156
157 Returns:
158 The brand prompt content
159 """
160 if name in _shared_prompts_cache:
161 return _shared_prompts_cache[name]
162
163 shared_path = BRAND_DIR / f"{name}.md"
164
165 if not shared_path.exists():
166 print(f"Warning: Brand prompt not found: {shared_path}")
167 return ""
168
169 with open(shared_path, "r", encoding="utf-8") as f:
170 content = f.read()
171
172 # Remove markdown title and HTML comments
173 lines = content.split("\n")
174 filtered_lines = []
175 for line in lines:
176 if line.startswith("#") and not filtered_lines:
177 continue # Skip first heading
178 if line.strip().startswith("<!--") and line.strip().endswith("-->"):
179 continue # Skip single-line HTML comments
180 filtered_lines.append(line)
181
182 content = "\n".join(filtered_lines).strip()
183 _shared_prompts_cache[name] = content
184 return content
185
186
187def _inject_shared_prompts(content: str) -> str:

Callers 2

_inject_shared_promptsFunction · 0.85
generate_imageFunction · 0.85

Calls 1

appendMethod · 0.65

Tested by

no test coverage detected