galloverdedev / smart-textify
使用 OpenAI 修改文本
0.4
2023-08-28 08:32 UTC
Requires
- openai-php/client: ^0.6.4
- symfony/http-client: ^6.2
Requires (Dev)
- orchestra/testbench: ^6.33
- phpunit/phpunit: ^9.6
This package is auto-updated.
Last update: 2024-09-28 14:27:48 UTC
README
SmartTextify 通过使用 OpenAI ChatGPT 聊天完成 API 对您的文本进行智能编辑。它提供了一套便捷的方法来轻松缩短、扩展等您的文本。
简介
SmartTextify 提供以下方法来编辑您的文本
- 缩短:将您的文本缩短至 50%
- 扩展:将您的文本扩展 50%
- 正式化:使用更正式的语言
- 非正式化:使用更非正式的语言
- 关键词:提取一系列关键词
- 总结:创建摘要
- 翻译:翻译成其他语言
- 术语表:提取所有缩写及其完整版本
安装
使用 composer 安装 SmartTextify
composer require galloverdedev/smart-textify
配置
您需要在 .env 文件中提供您的 OpenAI 访问密钥,如下所示
ST_OPENAI_API_KEY = 'mykey'
要获取 SmartTextify 的配置文件,您需要运行以下命令
php artisan smarttextify:install
这将在一个配置文件夹中放置一个 smarttextify.php 配置文件。
以下是您可以调整的内容
return [ // Your OpenAI API key 'api_key' => env('ST_OPENAI_API_KEY'), // The chat model to be used 'chat_model' => 'gpt-3.5-turbo-16k-0613', // Sample temperatire (between 0=strict and 2=innovative) 'sample_temperature' => 0.5, // The maximum number of input and output tokens per request 'max_tokens' => 2048, ];
测试
通过 composer 运行测试
composer test
使用方法
使用外观
use GalloVerdeDev\SmartTextify\Facades\SmartTextEditor; ... $textsample = 'Excepteur fugiat tempor nisi esse tempor proident excepteur ea enim esse aliqua. Minim dolore adipisicing culpa enim nulla aliquip deserunt enim sint. Aute cillum incididunt eu dolor sint qui ut elit ea qui qui aliqua in consectetur.'; $shortText = SmartTextEditor::shorten($textsample); $expandedText = SmartTextEditor::expand($textsample); $summary = SmartTextEditor::summarize($textsample); $formalText = SmartTextEditor::formalize($textsample); $casualText = SmartTextEditor::casualize($textsample); $keywordlist = SmartTextEditor::keywords($textsample, 3); $translatedText = SmartTextEditor::translate($textsample, 'latin', 'german'); $glossary = SmartTextEditor::glossary($textsample);