INNER CODE UNIT · Python
sanitize_text
cognitivetech/ollama-ebook-summary · sum.py:133
def sanitize_text(text: str) -> str:
"""Sanitize the input text by replacing unwanted characters."""
#text = re.sub(r'!', '.', text)
#text = re.sub(r'%', ' percent', text)
return text.strip()
# -----------------------------
# Title Generation and Uniqueness
# -----------------------------
def generate_title(api_base: str, model: str, clean_text: str, title_prompt: str, config: Config) -> Optional[str]:
"""Generate a unique title using the specified API and return only the first line."""
payload = {
"model": model,
"prompt": f"```{clean_text}```\n\n{title_prompt}",
"stream": False
}
result = make_api_request(api_base, "generate", payload)