promptu
v1.0.0
เขียนพร้อมท์ LLM แบบไดนามิกเป็นภาษาธรรมชาติ
Promptu จัดเตรียมชุดโปรแกรมอรรถประโยชน์ในการสร้างภาษาธรรมชาติสำหรับวิศวกรที่มีความพร้อม เช่น การตัดทอน พหูพจน์ และการจัดรูปแบบรายการภาษาธรรมชาติ
pip install promptu
from promptu import join
def find_matching_color ( existing_colors ):
return f'What color goes well with { join ( items = existing_colors , conjunction = "and" ) } ?'
# Prints "What color goes well with blue, purple and white?"
print ( find_matching_color ([ 'blue' , 'purple' , 'white' ]))
runnable = (
{ 'prompt' : RunnableLambda ( find_matching_color )}
| PromptTemplate . from_template ( '{prompt}' )
| model
)
runnable . invoke ([ 'blue' , 'purple' , 'white' ])
join()
จัดรูปแบบรายการเป็นรายการภาษาธรรมชาติ
ไวยากรณ์:
join ( items : Sequence , conjunction : str ) - > str
pluralize()
เลือกรูปแบบเอกพจน์หรือพหูพจน์ของคำตามจำนวนรายการ
ไวยากรณ์:
pluralize ( singular : str , plural : str , items : Sized ) - > str
truncate()
ตัดทอนสตริงให้มีความยาวสูงสุด หากข้อความยาวเกินความยาวสูงสุด อักขระทั้งหมดหลังจากความยาวสูงสุดจะถูกแทนที่ด้วยส่วนต่อท้าย
ไวยากรณ์:
truncate (
text : str , max_length : int , mode = TruncateMode . CHARACTER , suffix = "..."
) - > str
PR ยินดีต้อนรับ! โปรดเพิ่มหรืออัปเดตการทดสอบหน่วยที่เกี่ยวข้องและจัดรูปแบบโครงการด้วย black .