INNER CODE UNIT · Python
process_entry
cognitivetech/ollama-ebook-summary · sum.py:240
def process_entry(clean_text: str, title: str, config: Config, previous_original_title: str, api_base: str, model: str, prompt_alias: str, ptitle: str) -> Tuple[str, bool, str, float, int, str]:
"""Process a single text entry and return the processed data."""
unique_title, was_generated = get_unique_title(title, clean_text, previous_original_title, api_base, ptitle, config)
# Choose the appropriate prompt based on text length
if len(clean_text) < 1000:
prompt = config.get_prompt("concise")
model = config.defaults.get('general', model) # Falls back to passed model if 'general' not found
else:
prompt = config.get_prompt(prompt_alias)
payload = {
"model": model,
"prompt": f"```{clean_text}```\n\n{prompt}",
"stream": False
}
start_time = time.time()