ami-praha/ai-text-tool 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ami-praha/ai-text-tool

最新稳定版本:v0.0.2

Composer 安装命令:

composer require ami-praha/ai-text-tool

包简介

OpenAI-powered text operations for Laravel with multilingual language packs.

README 文档

README

AmiPraha\AiTextTool is a Laravel package for OpenAI-powered text operations with multilingual language packs.

Features

  • Text summarization with requested output length.
  • Headline generation with requested max length.
  • Translation using the same output language resolution as all other operations.
  • Text repair (grammar, punctuation, readability improvements).
  • Native language packs for multiple languages to improve output quality with non-English source text.

Supported Languages

Languages are defined by the AmiPraha\AiTextTool\Language enum:

  • Language::English
  • Language::Czech
  • Language::Slovak
  • Language::German
  • Language::Spanish

Installation

composer require ami-praha/ai-text-tool

Publish package config:

php artisan vendor:publish --tag=ai-text-tool-config

Optional: publish language files so you can customize them:

php artisan vendor:publish --tag=ai-text-tool-languages

Configuration

File: config/ai-text-tool.php

  • default_language: default language used by package (must match a Language enum value).
  • custom_language_path: optional directory with language files that override package language files.
  • openai_api_key: OpenAI API key used for chat completion requests.
  • openai_model: OpenAI model used by package operations.
  • openai_base_url: optional OpenAI-compatible base URL (useful for gateways/proxies).
  • timeout: HTTP timeout in seconds.

Example:

return [
    'default_language' => 'english',
    'custom_language_path' => resource_path('ai-text-tool/languages'),
    'openai_api_key' => env('OPENAI_API_KEY'),
    'openai_model' => 'gpt-4.1-mini',
    'openai_base_url' => 'https://api.openai.com/v1',
    'timeout' => 60,
];

Environment variables:

OPENAI_API_KEY=your-api-key
AI_TEXT_TOOL_LANGUAGE=english
AI_TEXT_TOOL_LANGUAGE_PATH=/full/path/to/language/files
AI_TEXT_TOOL_OPENAI_MODEL=gpt-4.1-mini
AI_TEXT_TOOL_OPENAI_BASE_URL=https://api.openai.com/v1
AI_TEXT_TOOL_TIMEOUT=60

Usage

use AmiPraha\AiTextTool\Facades\AiTextTool;
use AmiPraha\AiTextTool\Language;

$summary = AiTextTool::summarize($sourceText, 450);
$headline = AiTextTool::headline($sourceText, 50);
$translation = AiTextTool::translate($sourceText);
$repaired = AiTextTool::repair($sourceText);

Fluent per-call output language override

All operations use the configured default_language for output. Use usingLanguage() to override the output language per call:

$summary = AiTextTool::usingLanguage(Language::Czech)->summarize($sourceText, 450);
$headline = AiTextTool::usingLanguage(Language::German)->headline($sourceText, 50);
$translation = AiTextTool::usingLanguage(Language::Slovak)->translate($sourceText);

The override is immutable and per-call, so it does not change global config defaults.

Optional source language hint

Use fromLanguage() to tell the LLM what language the source text is written in. This is optional -- when not provided, the model detects the source language automatically.

$translation = AiTextTool::usingLanguage(Language::German)->fromLanguage(Language::Czech)->translate($sourceText);
$summary = AiTextTool::fromLanguage(Language::Czech)->summarize($sourceText, 300);

Both usingLanguage() and fromLanguage() are immutable and can be chained in any order.

Requirements

  • PHP 8.2+
  • Laravel 12+
  • OpenAI API key.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固