用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/NPC-Worldwide/npcsh --skill npcpy-prompting命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | npcpy-prompting |
| description | npcpy LLM prompting and JSON formatting patterns. |
| source_jinx | npcsh/npc_team/jinxes/skills/npcpy-prompting.jinx |
| engine | skill |
npcpy LLM prompting and JSON formatting patterns.
Always import at module level:
from npcpy.llm_funcs import get_llm_responsefrom npcpy.npc_compiler import NPCfrom npcpy.gen.response import get_litellm_response (only for streaming)get_llm_response(prompt, model, provider, **kwargs) — first arg is POSITIONAL.
Do NOT write prompt=prompt. Do NOT use NPC.call(). The function is module-level.
Pass format="json" for structured output.
npcpy parses internally. Access via response["response"].
Never call json.loads() manually.
Create an NPC to hold model, provider, and primary_directive.
Pass it as npc=npc_instance so npcpy reads those values:
npc = NPC(name="...", primary_directive="...", model="...", provider="...")
response = get_llm_response(prompt, npc=npc, format="json", temperature=0.7)
data = response["response"]
Pass conversation history as messages=[{"role": "system", "content": msg}].
This is a kwarg like any other. It does not persist between calls.
Sampling kwargs to get_llm_response:
temperature, top_p, top_k, max_tokensstream=True returns a generator in response["response"]For token-level streaming use get_litellm_response with stream=True.
For segment-level use get_llm_response(..., stream=True) and iterate response["response"].
json.loads(response["response"]).response.get("response") and then parse it again.response is a string when format="json" is used.When constructing prompt strings in Python:
f"""...""" for all multiline prompts. Do NOT use implicit string concatenation.return statement. Assign to a variable first, then return it.""" must be at the same indentation as the variable assignment.{{ inside f-strings. If you need literal curly braces in the prompt output, use explicit string concatenation:
prompt = f"""Write a JSON response like this:""" + """\n{'key': 'value'}\n"""
f"..." f"..." on adjacent lines or in parentheses expecting the parser to concatenate them.