跳转到主要内容

自2023年以来保持提示整洁

项目描述

Beautiful Prompt

更佳提示的简单工具。

安装

pip安装prettyprompt

用法

嗅探恶意意图

from prettyprompt import sniffers

# will this SQL statement write to my database?
sniffers.is_sql_write_statement(user_supplied_sql)

# is this a prompt injection attempt? ask ChatGPT
# (needs an OpenAI API key)
sniffers.is_prompt_injection(prompt, strategy="LLM")

# uses spaCy to indicate the imperative-ness of a string
# needs a trained pipeline e.g. `python -m spacy download en_core_web_sm`
sniffers.is_imperative(prompt)

转换输入

from prettyprompt import converters

# convert scraped HTML into plain text, maintaining some structure
converters.html_to_text(scraped_html)

# splits text into meaningful chunks, using GPT-3.5
converters.chunker(long_text, max_words_per_chunk, min_words_per_chunk)

清理输入

from prettyprompt import cleaners

# remove tags from HTML
cleaners.remove_tags(html)

# normalise spaces
cleaners.normalise_spaces(text)

# swap common 'smart' characters with ASCII equivalents
cleaners.simplify_text(text)

测试

  • pip install pytest pytest-mock
  • pytest

待办事项

项目详细信息


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

prettyprompt-0.1.5.tar.gz (7.9 kB 查看哈希值)

上传时间:

构建分布

prettyprompt-0.1.5-py2.py3-none-any.whl (5.1 kB 查看哈希值)

上传时间: Python 2 Python 3

由以下机构支持