prompt-poet 参考使用

主要是一个简单的功能体验,包含了include 以及简单的jinja2 逻辑判断

模版定义

  • app.yaml.j2
{% include 'system_instruction.yml.j2' %}
- name: system demo
  role: system
  content: |
    you are a system user
 
{% if username =="dalong" %}
- name: system audio 
  role: system
  content: |
    you are a system audio user
{% endif %}
  • system_instruction.yml.j2
- name: system demo
  role: system
  content: |
    demo contents
  • 应用使用
from prompt_poet import Prompt
 
template_data = {
  "character_name": "Character Assistant",
  "username": "dalong",
}
 
prompt = Prompt(
    template_path="app.yaml.j2",
    template_data=template_data
)
 
print(prompt.messages)
  • 效果

说明

基于prompt-poet的提示词模版管理机制上还是比较灵活的,值得尝试下,同时还提供了一个模版registry 的功能,后边可以详细研究下源码

参考资料

https://github.com/character-ai/prompt-poet/issues/18
https://github.com/character-ai/prompt-poet

posted on   荣锋亮  阅读(22)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-09-29 QRGen 一个灵活简单的java 二维码生成jar 包
2020-09-29 token模式请求图片资源
2020-09-29 扩展自定义spring boot prometheus metrics
2020-09-29 Managing PostgreSQL users and roles
2019-09-29 Cortex Architecture
2019-09-29 cortex 水平扩展试用
2019-09-29 cortex 基本试用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示