PromptCoder
1.0.0
由于语言模型(LMS)用于日益复杂的任务,因此制作提示变得充满挑战和麻烦,尤其是当任务涉及复杂的准则或多LM系统时。
pystcoder( procoder )是一个python软件包,旨在简化LM提示的创建。此用户友好的软件包允许编码模块化的LM提示,就像使用Python编程一样,可以轻松地创建复杂而复杂的提示系统。
此软件包的关键功能包括:
通过使用procoder软件包,我们开发并维护了一个提示系统,该系统在TooleMu项目中总共具有超过20K令牌,这是一个基于LM的工具仿真框架,用于评估LM代理的风险。
请注意,该软件包仍处于早期阶段,并且正在积极发展。
git clone https://github.com/dhh1995/PromptCoder
cd PromptCoder
pip install -e . 下面的示例显示了如何使用Inkstcoder代码提示。该示例使用procoder.prompt软件包中实现的模块。输出提示显示在代码下方。
from procoder . functional import format_prompt , replaced_submodule
from procoder . prompt import *
requirements = NamedBlock (
"Requirements" ,
Collection (
NamedVariable (
refname = "input_req" ,
name = "Input Requirement" ,
content = "The input should be two numbers." ,
),
NamedVariable (
refname = "output_req" ,
name = "Output Requirement" ,
content = Single (
"The output should be the sum of the two numbers."
). set_refname ( "output_req_content" ),
),
),
)
instruction = NamedBlock (
"Instruction" ,
"Write a function in {language} that satisfies the {input_req} and {output_req}." ,
)
prompt = (
Collection ( requirements , instruction )
. set_sep ( " n n " )
. set_indexing_method ( sharp2_indexing )
)
another_prompt = replaced_submodule (
prompt ,
"output_req_content" ,
Single ( "The output should be the multiplication of the two numbers." ),
)
inputs = { "language" : "python" }
print ( "First prompt:" )
print ( format_prompt ( prompt , inputs ))
print ( "" )
print ( "Second prompt:" )
print ( format_prompt ( another_prompt , inputs ))第一个提示的输出是:
## Requirements
1 . Input Requirement: The input should be two numbers.
2 . Output Requirement: The output should be the sum of the two numbers.
## Instruction
Write a function in python that satisfies the [ Input Requirement ] and [ Output Requirement ] .第二个提示的输出是:
## Requirements
1 . Input Requirement: The input should be two numbers.
2 . Output Requirement: The output should be the multiplication of the two numbers.
## Instruction
Write a function in python that satisfies the [ Input Requirement ] and [ Output Requirement ] .有关更多示例,请参阅使用procoder软件包开发的工具提示。