martink/chatgpt-site-assistant 问题修复 & 功能扩展

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

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

martink/chatgpt-site-assistant

最新稳定版本:v1.0.4

Composer 安装命令:

composer require martink/chatgpt-site-assistant

包简介

A Laravel package to scan website routes and connect to ChatGPT as a smart assistant.

README 文档

README

Latest Version on Packagist Total Downloads License

A Laravel package that scans your website's sitemap, extracts content, and connects to OpenAI's ChatGPT API to create an intelligent assistant that understands your site's actual content.

📦 Installation

composer require martink/chatgpt-site-assistant

Publish Config and Migrations

php artisan vendor:publish --tag=config
php artisan vendor:publish --tag=migrations

Then run:

php artisan migrate

⚙️ Configuration

Add your OpenAI API settings to your .env file:

OPENAI_API_KEY=your-openai-api-key
OPENAI_MODEL=gpt-3.5-turbo
OPENAI_BASE_URI=https://api.openai.com/v1
OPENAI_MAX_RETRIES=3
OPENAI_TIMEOUT=30
OPENAI_SYSTEM_MESSAGE="You are a helpful assistant for a wedding planning website. Use the following context to answer the user's question."

You can override these in the published config file:

config/chatgpt-site-assistant.php

🧠 Usage

Step 1: Scan Your Website's Sitemap

php artisan chatgpt:scan-sitemap http://localhost/sitemap.xml

This command will:

  • Read your sitemap.

  • Visit each route listed.

  • Extract the textual content.

  • Store it in the website_contents table for future use.

Step 2: Query the Assistant

Make a POST request to:

POST /api/chat

Example JSON body:

{
  "question": "What are your opening hours?"
}

The assistant uses your site's content to respond contextually via ChatGPT.

🧩 Components

  • Service: ChatGptService.php – handles OpenAI API interaction.

  • Command: chatgpt:scan-sitemap – crawls and stores your site's content.

  • Controller: ChatGptController.php – exposes the assistant via API.

  • Model: WebsiteContent.php – stores extracted text per URL.

✅ Laravel Compatibility

Laravel 8, 9, 10, and 12 supported.

PHP 8.0 – 8.4 supported.

📄 License

This package is open-source software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-02