微信扫码
添加专属顾问
我要投稿
01。
概述
02。
安装使用
安装
pip install prompt-poet
基础使用
import os
import getpass
from prompt_poet import Prompt
from langchain import ChatOpenAI
# Uncomment if you need to set OPENAI_API_KEY.
# os.environ["OPENAI_API_KEY"] = getpass.getpass()
raw_template = """
- name: system instructions
role: system
content: |
Your name is {{ character_name }} and you are meant to be helpful and never harmful to humans.
- name: user query
role: user
content: |
{{ username}}: {{ user_query }}
- name: response
role: user
content: |
{{ character_name }}:
"""
template_data = {
"character_name": "Character Assistant",
"username": "Jeff",
"user_query": "Can you help me with my homework?"
}
prompt = Prompt(
raw_template=raw_template,
template_data=template_data
)
model = ChatOpenAI(model="gpt-4o-mini")
response = model.invoke(prompt.messages)
03。
Prompt 模板
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费POC验证,效果达标后再合作。零风险落地应用大模型,已交付160+中大型企业
2026-05-09
Goal Mode 的 Prompt 怎么写才有效:任务拆分、约束条件与失败模式分析
2026-05-09
Anthropic 工程师发文:别用 Markdown 了,HTML 才是 AI 的终极语言!
2026-05-06
Claude Code 拥有 50 多个命令。大多数开发者只用到 5 个
2026-05-05
主流大模型系统提示词对比分析
2026-05-02
Codex 从入门到精通
2026-04-28
别再写 Prompt 了:Spec Mode 才是下一代 AI 编程范式
2026-04-25
我逆向了 329 条 GPT-Image2 提示词模板,全部开源!
2026-04-22
一招搞定:让 Cursor、Trae、VS Code 共享同一套 AI 技能库
2026-02-26
2026-02-24
2026-03-07
2026-03-13
2026-03-18
2026-02-24
2026-04-21
2026-02-28
2026-02-12
2026-02-12
2026-04-14
2026-02-28
2026-02-12
2026-02-12
2026-02-08
2026-02-05
2026-02-05
2026-01-23