微信扫码
添加专属顾问
我要投稿
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+中大型企业
2025-08-29
AI提示词的四种学习姿势:让你的AI像朋友一样懂你
2025-08-25
如何让模型直接输出 JSON 格式的数据?
2025-08-24
Dify全链路实战:AI 应用开发中 Prompt 与 Context 协同及 Dify 落地技巧
2025-08-20
多轮对话总 “失忆”?5 个技巧让 AI 记住你的每句话
2025-08-20
使用 GPT-5 进行编程的六个技巧
2025-08-19
会提问的人,都在用这5个万能提示词结构,悄悄变大神
2025-08-19
7 个提示词公式,让 AI 从「答非所问」变「精准执行」|附可复制模板
2025-08-18
Dify实现爆款BiliBili视频技巧分析
2025-06-18
2025-06-23
2025-06-07
2025-07-15
2025-07-08
2025-06-11
2025-06-17
2025-07-06
2025-06-29
2025-06-08
2025-08-25
2025-06-17
2025-04-21
2025-03-31
2025-03-29
2025-03-17
2025-02-06
2025-01-10