TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Are there any best practices for getting LLMs to return *only* code?

1 pointsby iknownthing6 months ago
When you ask some of the popular LLMs to generate code it seems like by default it returns something like "Sure!, here is the code below python```<some_python_code>```" but what if you only want the <some_python_code> part? I managed to make it work by including some example outputs in the prompt but I was wondering if there was a best practice for this?

1 comment

JojoFatsani6 months ago
Did you try telling it in the prompt: “Show me only the code I have requested in a markdown code block”?