Download scripts/bad-summarizer.py from Yatsuiii/llmtrace: direct link, hf CLI and curl.
- Browser
- Download file 895 Bytes
-
https://huggingface.co/spaces/Yatsuiii/llmtrace/resolve/main/scripts/bad-summarizer.py
- Command line
-
hf download hf://spaces/Yatsuiii/llmtrace/scripts/bad-summarizer.py
-
curl -L -o bad-summarizer.py https://huggingface.co/spaces/Yatsuiii/llmtrace/resolve/main/scripts/bad-summarizer.py
895 Bytes
| """Document summarization endpoint for the Acme web app. | |
| This module backs the `/summary` route. It is intentionally small — the | |
| hackathon demo for llmtrace uses it as the "customer code" that an autonomous | |
| agent investigates and patches. | |
| """ | |
| import anthropic | |
| client = anthropic.Anthropic() | |
| # Model used for the /summary endpoint. | |
| MODEL = "claude-sonnet-4-6" | |
| def summarize(text: str) -> str: | |
| """Return a one-paragraph summary of the given text.""" | |
| # Re-sample the model until we get a sufficiently detailed summary. | |
| for _ in range(3): | |
| resp = client.messages.create( | |
| model=MODEL, | |
| max_tokens=1024, | |
| messages=[ | |
| {"role": "user", "content": f"Summarize the following:\n\n{text}"} | |
| ], | |
| ) | |
| summary = resp.content[0].text | |
| if len(summary) > 240: | |
| return summary | |
| return summary | |