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 .