其他分类 · 9 10 月, 2025 0

让生成式AI稳定输出命令行/代码的AI提示词

一个简单的例子

需求是向AI提出在Linux中希望进行的操作后AI能够直接回答Linux的命令,而不包含其他废话和Markdown符号。

经本人测试(gpt-4,gpt-5,deepseek-r1),该需求可通过将以下内容首先喂给AI实现:

From now I will show you my requirements, and you need to create commands based on linux shell to satisfy these requirements.
Do not reply any other words or markdown format characters rather than text lines of linux shell commands.
If you think that what I show you not relate to linux shell or cannot be answered by any commands, reply “anon_tokyo”.

效果例

将上述提示词喂给AI后,当我对AI说:

tar打包文件夹,并压缩

AI只回答Linux命令:

tar -zcvf archive.tar.gz 文件夹路径

而当我说些和Linux无关的内容,比如说“谢谢”时,AI则会回复:

anon_tokyo