From e2f44e3a7aebb3193ebe7703b033d42cdc3b3805 Mon Sep 17 00:00:00 2001 From: Hakam <206649095+s3cr1z@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:03:33 +0000 Subject: [PATCH 1/3] feat: Add Lingo.Dev AI localization setup - Add GitHub Actions workflow for automated AI translations - Configure English (en-US) as source language - Target languages: Chinese, Japanese, Korean, Spanish, French, German - Add comprehensive documentation and setup guide - Enable pull request workflow for translation review - Support for Vue.js i18n files, Chrome extension locales, and docs --- .github/workflows/localization.yml | 57 ++++++++++++++ LOCALIZATION_SETUP.md | 50 ++++++++++++ docs/localization.md | 121 +++++++++++++++++++++++++++++ lingo.config.json | 17 ++++ 4 files changed, 245 insertions(+) create mode 100644 .github/workflows/localization.yml create mode 100644 LOCALIZATION_SETUP.md create mode 100644 docs/localization.md create mode 100644 lingo.config.json diff --git a/.github/workflows/localization.yml b/.github/workflows/localization.yml new file mode 100644 index 000000000..8cbd57e27 --- /dev/null +++ b/.github/workflows/localization.yml @@ -0,0 +1,57 @@ +name: Lingo.Dev AI Localization + +on: + push: + branches: [ main, master ] + paths: + - 'packages/ui/src/i18n/locales/**' + - 'packages/extension/public/_locales/**' + - '**.md' + - 'docs/**' + pull_request: + branches: [ main, master ] + paths: + - 'packages/ui/src/i18n/locales/**' + - 'packages/extension/public/_locales/**' + - '**.md' + - 'docs/**' + workflow_dispatch: # Allow manual triggering + +jobs: + lingo-localization: + runs-on: ubuntu-latest + + steps: + - name: 检出代码 + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch full history for better localization context + + - name: Lingo.Dev AI Localization + uses: lingodotdev/lingo.dev@0.99.4 + with: + # Required: Lingo.dev API key (set in repository secrets) + api-key: ${{ secrets.LINGODOTDEV_API_KEY }} + + # Optional: Version of Lingo.dev CLI to use + version: "latest" + + # Optional: Create pull request for translation updates + pull-request: true + + # Optional: Custom commit message + commit-message: "🌐 Update translations via Lingo.Dev AI" + + # Optional: Custom pull request title + pull-request-title: "🌐 Automated AI Translation Updates" + + # Optional: Working directory (useful for monorepos) + working-directory: "." + + # Optional: Process own commits (avoid infinite loops) + process-own-commits: false + + # Optional: Enable parallel processing for faster execution + parallel: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LOCALIZATION_SETUP.md b/LOCALIZATION_SETUP.md new file mode 100644 index 000000000..ef65fa4de --- /dev/null +++ b/LOCALIZATION_SETUP.md @@ -0,0 +1,50 @@ +# Lingo.Dev AI Localization Setup Summary + +## ✅ Files Created/Modified + +### 1. GitHub Workflow +- **Created**: `.github/workflows/localization.yml` +- **Purpose**: Automated AI-powered localization workflow +- **Triggers**: Push/PR to main/master, manual dispatch + +### 2. Configuration File +- **Created**: `lingo.config.json` +- **Purpose**: Lingo.Dev configuration for translation behavior +- **Features**: Source language (zh-CN), target languages, file patterns + +### 3. Documentation +- **Created**: `docs/localization.md` +- **Purpose**: Comprehensive guide for the localization setup +- **Contents**: Configuration, workflow, best practices + +## 🚀 What's Now Enabled + +1. **Automatic Translation**: AI translates your English content to Chinese and other languages +2. **Smart Context**: Understanding of your Vue.js i18n structure and Chrome extension locales +3. **Pull Request Workflow**: Creates PRs for review before merging translations +4. **Multiple Formats**: Handles TypeScript, JSON, and Markdown files +5. **Manual Control**: Can trigger localization manually via GitHub Actions + +## 🎯 Target Languages Configured + +- �� Chinese (zh-CN) - Auto-generated +- 🇯🇵 Japanese (ja-JP) +- 🇰🇷 Korean (ko-KR) +- 🇪🇸 Spanish (es-ES) +- 🇫🇷 French (fr-FR) +- 🇩🇪 German (de-DE) + +## 📂 Files Being Localized + +- `packages/ui/src/i18n/locales/**/*.ts` - Vue.js i18n files +- `packages/extension/public/_locales/**/*.json` - Chrome extension +- `README*.md` & `docs/**/*.md` - Documentation + +## 🔄 Next Steps + +1. **Commit & Push**: These files to trigger the first localization run +2. **Review PRs**: Check AI-generated translations for accuracy +3. **Merge**: Approved translations to enable multi-language support +4. **Test**: Verify translations work in your application + +The setup is complete and ready to use! 🎉 diff --git a/docs/localization.md b/docs/localization.md new file mode 100644 index 000000000..0d64c9e2c --- /dev/null +++ b/docs/localization.md @@ -0,0 +1,121 @@ +# Lingo.Dev AI Localization Setup + +This project uses [Lingo.Dev](https://lingo.dev) AI-powered localization to automatically manage translations for multiple languages. + +## 🚀 Features + +- **Automated Translation**: AI-powered translations for multiple languages +- **Smart Context Awareness**: Understands your project context for better translations +- **Pull Request Integration**: Creates PRs for translation updates +- **Multi-Format Support**: Handles TypeScript i18n files, JSON locales, and Markdown docs + +## 📁 Localized Files + +The following files are automatically localized: + +### UI Components +- `packages/ui/src/i18n/locales/*.ts` - Vue.js i18n translation files +- Currently supports: Chinese (zh-CN), English (en-US) + +### Browser Extension +- `packages/extension/public/_locales/*/messages.json` - Chrome extension locales +- Currently supports: Chinese (zh_CN), English (en) + +### Documentation +- `README*.md` - Project documentation +- `docs/**/*.md` - All documentation files + +## ⚙️ Configuration + +The localization behavior is configured in `lingo.config.json`: + +```json +{ + "version": "1.0", + "localization": { + "source_language": "en-US", + "target_languages": ["zh-CN", "ja-JP", "ko-KR", "es-ES", "fr-FR", "de-DE"], + "file_patterns": [ + "packages/ui/src/i18n/locales/**/*.ts", + "packages/extension/public/_locales/**/*.json", + "README*.md", + "docs/**/*.md" + ] + } +} +``` + +### Supported Target Languages + +- �� **Chinese (zh-CN)** - Auto-generated +- 🇯🇵 **Japanese (ja-JP)** - Auto-generated +- 🇰🇷 **Korean (ko-KR)** - Auto-generated +- 🇪🇸 **Spanish (es-ES)** - Auto-generated +- 🇫🇷 **French (fr-FR)** - Auto-generated +- 🇩🇪 **German (de-DE)** - Auto-generated + +## 🔄 Workflow Triggers + +The localization workflow runs automatically when: + +1. **Push to main/master**: Changes to localization files or documentation +2. **Pull Requests**: For review of localization changes +3. **Manual Trigger**: Via GitHub Actions interface + +### Trigger Paths +- `packages/ui/src/i18n/locales/**` - UI translation files +- `packages/extension/public/_locales/**` - Extension locales +- `**.md` - Markdown documentation +- `docs/**` - Documentation folder + +## 📝 How It Works + +1. **Source Detection**: Lingo.Dev scans configured file patterns +2. **Context Analysis**: AI analyzes your codebase for translation context +3. **Translation Generation**: Creates contextually appropriate translations +4. **Pull Request**: Submits changes via automated PR +5. **Review & Merge**: Review AI-generated translations before merging + +## 🛠️ Customization + +To customize the localization: + +1. **Edit `lingo.config.json`** to modify: + - Target languages + - File patterns + - Translation settings + - Output preferences + +2. **Update `.github/workflows/localization.yml`** to modify: + - Trigger conditions + - Workflow timing + - Additional steps + +## 📋 Best Practices + +- **Review AI Translations**: Always review before merging +- **Maintain Context**: Keep translation keys descriptive +- **Test Locally**: Verify translations work in your application +- **Consistent Terminology**: Use project-specific terms consistently + +## 🚫 Excluded Files + +The following are automatically excluded: +- `node_modules/**` +- `dist/**`, `build/**` +- Test files (`*.test.ts`, `*.spec.ts`) + +## 🔧 Manual Operation + +To run localization manually: + +1. Go to **Actions** tab in GitHub +2. Select **Lingo.Dev AI Localization** workflow +3. Click **Run workflow** +4. Select branch and click **Run workflow** + +## 📚 Resources + +- [Lingo.Dev Documentation](https://lingo.dev/docs) +- [GitHub Action Repository](https://github.com/lingodotdev/lingo.dev) +- [Project i18n Guide](packages/ui/src/i18n/README.md) diff --git a/lingo.config.json b/lingo.config.json new file mode 100644 index 000000000..98b86788a --- /dev/null +++ b/lingo.config.json @@ -0,0 +1,17 @@ +{ + "source": "en-US", + "targets": ["zh-CN", "ja-JP", "ko-KR", "es-ES", "fr-FR", "de-DE"], + "include": [ + "packages/ui/src/i18n/locales/**/*.ts", + "packages/extension/public/_locales/**/*.json", + "README*.md", + "docs/**/*.md" + ], + "exclude": [ + "node_modules/**", + "dist/**", + "build/**", + "*.test.ts", + "*.spec.ts" + ] +} From 40a248e8dff882591b3b7bda6a4a95cb832f4c9e Mon Sep 17 00:00:00 2001 From: Hakam <206649095+s3cr1z@users.noreply.github.com> Date: Tue, 17 Jun 2025 16:13:28 +0000 Subject: [PATCH 2/3] feat: Ensure all localization sources are in English - Update GitHub workflow step names to English - Add English description and metadata to package.json - Update engine messages to English - Configure lingo.config.json to prioritize English sources - Focus on README_EN.md as primary documentation source - Include package.json for metadata localization --- .github/workflows/localization.yml | 2 +- lingo.config.json | 20 ++++++++++++++------ package.json | 23 +++++++++++++++++++++-- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.github/workflows/localization.yml b/.github/workflows/localization.yml index 8cbd57e27..10657563a 100644 --- a/.github/workflows/localization.yml +++ b/.github/workflows/localization.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - - name: 检出代码 + - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 # Fetch full history for better localization context diff --git a/lingo.config.json b/lingo.config.json index 98b86788a..2e82ed221 100644 --- a/lingo.config.json +++ b/lingo.config.json @@ -1,11 +1,19 @@ { "source": "en-US", - "targets": ["zh-CN", "ja-JP", "ko-KR", "es-ES", "fr-FR", "de-DE"], + "targets": [ + "zh-CN", + "ja-JP", + "ko-KR", + "es-ES", + "fr-FR", + "de-DE" + ], "include": [ - "packages/ui/src/i18n/locales/**/*.ts", - "packages/extension/public/_locales/**/*.json", - "README*.md", - "docs/**/*.md" + "README_EN.md", + "packages/ui/src/i18n/locales/en-US.ts", + "packages/extension/public/_locales/en/messages.json", + "docs/**/*.md", + "package.json" ], "exclude": [ "node_modules/**", @@ -14,4 +22,4 @@ "*.test.ts", "*.spec.ts" ] -} +} \ No newline at end of file diff --git a/package.json b/package.json index ed31bf503..787f99a64 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,31 @@ { "name": "prompt-optimizer", "version": "1.0.7", + "description": "AI-powered prompt optimization tool with multi-round iteration and version tracking. Supports major AI models with client-side processing for data security.", + "author": "linshenkx", + "repository": { + "type": "git", + "url": "https://github.com/linshenkx/prompt-optimizer.git" + }, + "homepage": "https://prompt.always200.com", + "keywords": [ + "prompt", + "optimization", + "ai", + "llm", + "openai", + "gemini", + "deepseek", + "client-side", + "privacy" + ], + "license": "MIT", "private": true, "packageManager": "pnpm@10.6.1", "engines": { "node": "^18.0.0 || ^20.0.0 || ^22.0.0", - "npm": "请使用pnpm代替npm", - "yarn": "请使用pnpm代替yarn" + "npm": "Please use pnpm instead of npm", + "yarn": "Please use pnpm instead of yarn" }, "scripts": { "build:core": "pnpm -F @prompt-optimizer/core build", From 3b37a1184f1742403e31630cc255a15c48ecbf38 Mon Sep 17 00:00:00 2001 From: Hakam <206649095+s3cr1z@users.noreply.github.com> Date: Wed, 18 Jun 2025 00:56:05 +0000 Subject: [PATCH 3/3] docs: update all user-facing docs and metadata to English for Lingo.Dev AI Localization --- README.md | 283 ++++++++++++++++++++++++------------------------- dev.md | 154 +++++++++++++-------------- docs/README.md | 77 +++++++------- package.json | 2 +- 4 files changed, 256 insertions(+), 260 deletions(-) diff --git a/README.md b/README.md index fb8b1de73..c7a42f145 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Prompt Optimizer (提示词优化器) 🚀 +# Prompt Optimizer 🚀
@@ -12,104 +12,103 @@ ![GitHub forks](https://img.shields.io/github/forks/linshenkx/prompt-optimizer?style=flat) [![Deploy with Vercel](https://img.shields.io/badge/Vercel-indigo?style=flat&logo=vercel)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer) -[在线体验](https://prompt.always200.com) | [快速开始](#快速开始) | [常见问题](#常见问题) | [开发文档](dev.md) | [Vercel部署指南](docs/vercel.md) | [Chrome插件](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) +[Live Demo](https://prompt.always200.com) | [Quick Start](#quick-start) | [FAQ](#faq) | [Development Docs](dev.md) | [Vercel Deployment Guide](docs/vercel_en.md) | [Chrome Extension](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna)
-## 📖 项目简介 +## 📖 Project Introduction -Prompt Optimizer是一个强大的AI提示词优化工具,帮助你编写更好的AI提示词,提升AI输出质量。支持Web应用和Chrome插件两种使用方式。 +Prompt Optimizer is a powerful AI prompt optimization tool that helps you write better AI prompts and improve the quality of AI outputs. It supports both web application and Chrome extension usage. -### 🎥 功能演示 +### 🎥 Feature Demonstration
- 功能演示 + Feature Demonstration
-## ✨ 核心特性 +## ✨ Core Features -- 🎯 **智能优化**:一键优化提示词,支持多轮迭代改进,提升AI回复准确度 -- 🔄 **对比测试**:支持原始提示词和优化后提示词的实时对比,直观展示优化效果 -- 🤖 **多模型集成**:支持OpenAI、Gemini、DeepSeek、智谱AI、SiliconFlow等主流AI模型 -- ⚙️ **高级参数配置**:支持为每个模型单独配置temperature、max_tokens等LLM参数 -- 🔒 **安全架构**:纯客户端处理,数据直接与AI服务商交互,不经过中间服务器 -- 💾 **隐私保护**:本地加密存储历史记录和API密钥,支持数据导入导出 -- 📱 **多端支持**:同时提供Web应用和Chrome插件两种使用方式 -- 🎨 **用户体验**:简洁直观的界面设计,响应式布局和流畅交互动效 -- 🌐 **跨域支持**:Vercel部署时支持使用Edge Runtime代理解决跨域问题 -- 🔐 **访问控制**:支持密码保护功能,保障部署安全 +- 🎯 **Intelligent Optimization**: One-click prompt optimization with multi-round iterative improvements to enhance AI response accuracy +- 🔄 **Comparison Testing**: Real-time comparison between original and optimized prompts for intuitive demonstration of optimization effects +- 🤖 **Multi-model Integration**: Support for mainstream AI models including OpenAI, Gemini, DeepSeek, Zhipu AI, SiliconFlow, etc. +- ⚙️ **Advanced Parameter Configuration**: Support for individual LLM parameter configuration (temperature, max_tokens, etc.) for each model +- 🔒 **Secure Architecture**: Pure client-side processing with direct data interaction with AI service providers, bypassing intermediate servers +- 💾 **Privacy Protection**: Local encrypted storage of history records and API keys with data import/export support +- 📱 **Multi-platform Support**: Available as both a web application and Chrome extension +- 🎨 **User Experience**: Clean and intuitive interface design with responsive layout and smooth interaction effects +- 🌐 **Cross-domain Support**: Edge Runtime proxy for cross-domain issues when deployed on Vercel +- 🔐 **Access Control**: Password protection feature for secure deployment -## 快速开始 +## Quick Start -### 1. 使用在线版本(推荐) +### 1. Use Online Version (Recommended) -直接访问:[https://prompt.always200.com](https://prompt.always200.com) +Direct access: [https://prompt.always200.com](https://prompt.always200.com) -项目是纯前端项目,所有数据只存储在浏览器本地,不会上传至任何服务器,因此直接使用在线版本也是安全可靠的 +This is a pure frontend project with all data stored locally in your browser and never uploaded to any server, making the online version both safe and reliable to use. -### 2. Vercel部署 -方式1:一键部署到自己的Vercel: - [![部署到 Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer) +### 2. Vercel Deployment +Method 1: One-click deployment to your own Vercel: + [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flinshenkx%2Fprompt-optimizer) -方式2: Fork项目后在Vercel中导入(推荐): - - 先Fork项目到自己的GitHub - - 然后在Vercel中导入该项目 - - 可跟踪源项目更新,便于同步最新功能和修复 -- 配置环境变量: - - `ACCESS_PASSWORD`:设置访问密码,启用访问限制 - - `VITE_OPENAI_API_KEY`等:配置各AI服务商的API密钥 - -更多详细的部署步骤和注意事项,请查看: -- [Vercel部署指南](docs/vercel.md) +Method 2: Fork the project and import to Vercel (Recommended): + - First fork the project to your GitHub account + - Then import the project to Vercel + - This allows tracking of source project updates for easy syncing of new features and fixes +- Configure environment variables: + - `ACCESS_PASSWORD`: Set access password to enable access restriction + - `VITE_OPENAI_API_KEY` etc.: Configure API keys for various AI service providers + +For more detailed deployment steps and important notes, please check: +- [Vercel Deployment Guide](docs/vercel_en.md) -### 3. 安装Chrome插件 -1. 从Chrome商店安装(由于审批较慢,可能不是最新的):[Chrome商店地址](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) -2. 点击图标即可打开提示词优化器 +### 3. Install Chrome Extension +1. Install from Chrome Web Store (may not be the latest version due to approval delays): [Chrome Web Store](https://chromewebstore.google.com/detail/prompt-optimizer/cakkkhboolfnadechdlgdcnjammejlna) +2. Click the icon to open the Prompt Optimizer -### 4. Docker部署 +### 4. Docker Deployment ```bash -# 运行容器(默认配置) +# Run container (default configuration) docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer linshen/prompt-optimizer -# 运行容器(配置API密钥和访问密码) +# Run container (with API key configuration and password protection) docker run -d -p 80:80 \ -e VITE_OPENAI_API_KEY=your_key \ - -e ACCESS_USERNAME=your_username \ # 可选,默认为"admin" - -e ACCESS_PASSWORD=your_password \ # 设置访问密码 + -e ACCESS_USERNAME=your_username \ # Optional, defaults to "admin" + -e ACCESS_PASSWORD=your_password \ # Required for password protection --restart unless-stopped \ --name prompt-optimizer \ linshen/prompt-optimizer - ``` -### 5. Docker Compose部署 +### 5. Docker Compose Deployment ```bash -# 1. 克隆仓库 +# 1. Clone the repository git clone https://github.com/linshenkx/prompt-optimizer.git cd prompt-optimizer -# 2. 可选:创建.env文件配置API密钥和访问认证 +# 2. Optional: Create .env file for API keys and authentication cat > .env << EOF -# API密钥配置 +# API Key Configuration VITE_OPENAI_API_KEY=your_openai_api_key VITE_GEMINI_API_KEY=your_gemini_api_key VITE_DEEPSEEK_API_KEY=your_deepseek_api_key VITE_ZHIPU_API_KEY=your_zhipu_api_key VITE_SILICONFLOW_API_KEY=your_siliconflow_api_key -# Basic认证配置(密码保护) -ACCESS_USERNAME=your_username # 可选,默认为"admin" -ACCESS_PASSWORD=your_password # 设置访问密码 +# Basic Authentication +ACCESS_USERNAME=your_username # Optional, defaults to "admin" +ACCESS_PASSWORD=your_password # Required for authentication EOF -# 3. 启动服务 +# 3. Start the service docker compose up -d -# 4. 查看日志 +# 4. View logs docker compose logs -f ``` -你还可以直接编辑docker-compose.yml文件,自定义配置: +You can also edit the docker-compose.yml file directly to customize your configuration: ```yaml services: prompt-optimizer: @@ -117,39 +116,39 @@ services: container_name: prompt-optimizer restart: unless-stopped ports: - - "8081:80" # 修改端口映射 + - "8081:80" # Change port mapping environment: - - VITE_OPENAI_API_KEY=your_key_here # 直接在配置中设置密钥 + - VITE_OPENAI_API_KEY=your_key_here # Set API key directly in config ``` -## ⚙️ API密钥配置 +## ⚙️ API Key Configuration -### 方式一:通过界面配置(推荐) -1. 点击界面右上角的"⚙️设置"按钮 -2. 选择"模型管理"选项卡 -3. 点击需要配置的模型(如OpenAI、Gemini、DeepSeek等) -4. 在弹出的配置框中输入对应的API密钥 -5. 点击"保存"即可 +### Method 1: Via Interface (Recommended) +1. Click the "⚙️Settings" button in the upper right corner +2. Select the "Model Management" tab +3. Click on the model you need to configure (such as OpenAI, Gemini, DeepSeek, etc.) +4. Enter the corresponding API key in the configuration box +5. Click "Save" -支持的模型: +Supported models: - OpenAI (gpt-3.5-turbo, gpt-4, gpt-4o) - Gemini (gemini-1.5-pro, gemini-2.0-flash) - DeepSeek (deepseek-chat, deepseek-coder) -- Zhipu智谱 (glm-4-flash, glm-4, glm-3-turbo) +- Zhipu AI (glm-4-flash, glm-4, glm-3-turbo) - SiliconFlow (Pro/deepseek-ai/DeepSeek-V3) -- 自定义API(OpenAI兼容接口) +- Custom API (OpenAI compatible interface) -除了API密钥,您还可以在模型配置界面为每个模型单独设置高级LLM参数。这些参数通过一个名为 `llmParams` 的字段进行配置,它允许您以键值对的形式指定LLM SDK支持的任何参数,从而更精细地控制模型行为。 +In addition to API keys, you can configure advanced LLM parameters for each model individually. These parameters are configured through a field called `llmParams`, which allows you to specify any parameters supported by the LLM SDK in key-value pairs for fine-grained control over model behavior. -**高级LLM参数配置示例:** -- **OpenAI/兼容API**: `{"temperature": 0.7, "max_tokens": 4096, "timeout": 60000}` +**Advanced LLM Parameter Configuration Examples:** +- **OpenAI/Compatible APIs**: `{"temperature": 0.7, "max_tokens": 4096, "timeout": 60000}` - **Gemini**: `{"temperature": 0.8, "maxOutputTokens": 2048, "topP": 0.95}` - **DeepSeek**: `{"temperature": 0.5, "top_p": 0.9, "frequency_penalty": 0.1}` -有关 `llmParams` 的更详细说明和配置指南,请参阅 [LLM参数配置指南](docs/llm-params-guide.md)。 +For more detailed information about `llmParams` configuration, please refer to the [LLM Parameters Configuration Guide](docs/llm-params-guide.md). -### 方式二:通过环境变量配置 -Docker部署时通过 `-e` 参数配置环境变量: +### Method 2: Via Environment Variables +Configure environment variables through the `-e` parameter when deploying with Docker: ```bash -e VITE_OPENAI_API_KEY=your_key -e VITE_GEMINI_API_KEY=your_key @@ -161,44 +160,43 @@ Docker部署时通过 `-e` 参数配置环境变量: -e VITE_CUSTOM_API_MODEL=your_custom_model_name ``` -## 本地开发 -详细文档可查看 [开发文档](dev.md) +## Local Development +For detailed documentation, see [Development Documentation](dev.md) ```bash -# 1. 克隆项目 +# 1. Clone the project git clone https://github.com/linshenkx/prompt-optimizer.git cd prompt-optimizer -# 2. 安装依赖 +# 2. Install dependencies pnpm install -# 3. 启动开发服务 -pnpm dev # 主开发命令:构建core/ui并运行web应用 -pnpm dev:web # 仅运行web应用 -pnpm dev:fresh # 完整重置并重新启动开发环境 +# 3. Start development server +pnpm dev # Main development command: build core/ui and run web app +pnpm dev:web # Run web app only +pnpm dev:fresh # Complete reset and restart development environment ``` -## 🗺️ 开发路线 +## 🗺️ Roadmap -- [x] 基础功能开发 -- [x] Web应用发布 -- [x] Chrome插件发布 -- [x] 自定义模型支持 -- [x] 多模型支持优化 -- [x] 国际化支持 +- [x] Basic feature development +- [x] Web application release +- [x] Chrome extension release +- [x] Custom model support +- [x] Multi-model support optimization +- [x] Internationalization support -详细的项目状态可查看 [项目状态文档](docs/project-status.md) +For detailed project status, see [Project Status Document](docs/project-status.md) -## 📖 相关文档 - -- [文档索引](docs/README.md) - 所有文档的索引 -- [技术开发指南](docs/technical-development-guide.md) - 技术栈和开发规范 -- [LLM参数配置指南](docs/llm-params-guide.md) - 高级LLM参数配置详细说明 -- [项目结构](docs/project-structure.md) - 详细的项目结构说明 -- [项目状态](docs/project-status.md) - 当前进度和计划 -- [产品需求](docs/prd.md) - 产品需求文档 -- [Vercel部署指南](docs/vercel.md) - Vercel部署详细说明 +## 📖 Related Documentation +- [Documentation Index](docs/README.md) - Index of all documentation +- [Technical Development Guide](docs/technical-development-guide.md) - Technology stack and development specifications +- [LLM Parameters Configuration Guide](docs/llm-params-guide.md) - Detailed guide for advanced LLM parameter configuration +- [Project Structure](docs/project-structure.md) - Detailed project structure description +- [Project Status](docs/project-status.md) - Current progress and plans +- [Product Requirements](docs/prd.md) - Product requirements document +- [Vercel Deployment Guide](docs/vercel_en.md) - Detailed instructions for Vercel deployment ## Star History @@ -210,72 +208,71 @@ pnpm dev:fresh # 完整重置并重新启动开发环境 -## 常见问题 - -### API连接问题 +## FAQ -#### Q1: 为什么配置好API密钥后仍然无法连接到模型服务? -**A**: 大多数连接失败是由**跨域问题**(CORS)导致的。由于本项目是纯前端应用,浏览器出于安全考虑会阻止直接访问不同源的API服务。模型服务如未正确配置CORS策略,会拒绝来自浏览器的直接请求。 +### API Connection Issues -#### Q2: 如何解决本地Ollama的连接问题? -**A**: Ollama完全支持OpenAI标准接口,只需配置正确的跨域策略: -1. 设置环境变量 `OLLAMA_ORIGINS=*` 允许任意来源的请求 -2. 如仍有问题,设置 `OLLAMA_HOST=0.0.0.0:11434` 监听任意IP地址 +#### Q1: Why can't I connect to the model service after configuring the API key? +**A**: Most connection failures are caused by **Cross-Origin Resource Sharing (CORS)** issues. As this project is a pure frontend application, browsers block direct access to API services from different origins for security reasons. Model services will reject direct requests from browsers if CORS policies are not correctly configured. -#### Q3: 如何解决商业API(如Nvidia的DS API、字节跳动的火山API)的跨域问题? -**A**: 这些平台通常有严格的跨域限制,推荐以下解决方案: +#### Q2: How to solve Ollama connection issues? +**A**: Ollama fully supports the OpenAI standard interface, just configure the correct CORS policy: +1. Set environment variable `OLLAMA_ORIGINS=*` to allow requests from any origin +2. If issues persist, set `OLLAMA_HOST=0.0.0.0:11434` to listen on any IP address -1. **使用Vercel代理**(便捷方案) - - 使用在线版本:[prompt.always200.com](https://prompt.always200.com) - - 或自行部署到Vercel平台 - - 在模型设置中勾选"使用Vercel代理"选项 - - 请求流向:浏览器→Vercel→模型服务提供商 - - 详细步骤请参考 [Vercel部署指南](docs/vercel.md) +#### Q3: How to solve CORS issues with commercial APIs (such as Nvidia's DS API, ByteDance's Volcano API)? +**A**: These platforms typically have strict CORS restrictions. Recommended solutions: -2. **使用自部署的API中转服务**(可靠方案) - - 部署如OneAPI等开源API聚合/代理工具 - - 在设置中配置为自定义API端点 - - 请求流向:浏览器→中转服务→模型服务提供商 +1. **Use Vercel Proxy** (Convenient solution) + - Use the online version: [prompt.always200.com](https://prompt.always200.com) + - Or deploy to your own Vercel platform + - Check "Use Vercel Proxy" option in model settings + - Request flow: Browser → Vercel → Model service provider + - For detailed steps, please refer to the [Vercel Deployment Guide](docs/vercel_en.md) -#### Q4: Vercel代理有什么缺点或风险? -**A**: 使用Vercel代理可能会触发某些模型服务提供商的风控机制。部分厂商可能会将来自Vercel的请求判定为代理行为,从而限制或拒绝服务。如遇此问题,建议使用自部署的中转服务。 +2. **Use self-deployed API proxy service** (Reliable solution) + - Deploy open-source API aggregation/proxy tools like OneAPI + - Configure as custom API endpoint in settings + - Request flow: Browser → Proxy service → Model service provider +#### Q4: What are the drawbacks or risks of using Vercel proxy? +**A**: Using Vercel proxy may trigger risk control mechanisms of some model service providers. Some vendors may identify requests from Vercel as proxy behavior, thereby limiting or denying service. If you encounter this issue, we recommend using a self-deployed proxy service. -## 🤝 参与贡献 +## 🤝 Contributing -1. Fork 本仓库 -2. 创建特性分支 (`git checkout -b feature/AmazingFeature`) -3. 提交更改 (`git commit -m '添加某个特性'`) -4. 推送到分支 (`git push origin feature/AmazingFeature`) -5. 提交 Pull Request +1. Fork the repository +2. Create a feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit your changes (`git commit -m 'Add some feature'`) +4. Push to the branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request -提示:使用cursor工具开发时,建议在提交前: -1. 使用"code_review"规则进行代码审查 -2. 按照审查报告格式检查: - - 变更的整体一致性 - - 代码质量和实现方式 - - 测试覆盖情况 - - 文档完善程度 -3. 根据审查结果进行优化后再提交 +Tip: When developing with Cursor tool, it is recommended to do the following before committing: +1. Use the "CodeReview" rule for review +2. Check according to the review report format: + - Overall consistency of changes + - Code quality and implementation method + - Test coverage + - Documentation completeness +3. Optimize based on review results before submitting -## 👏 贡献者名单 +## 👏 Contributors -感谢所有为项目做出贡献的开发者! +Thanks to all the developers who have contributed to this project! - 贡献者 + Contributors -## 📄 开源协议 +## 📄 License -本项目采用 [MIT](LICENSE) 协议开源。 +This project is licensed under the [MIT](LICENSE) License. --- -如果这个项目对你有帮助,请考虑给它一个 Star ⭐️ +If this project is helpful to you, please consider giving it a Star ⭐️ -## 👥 联系我们 +## 👥 Contact Us -- 提交 Issue -- 发起 Pull Request -- 加入讨论组 \ No newline at end of file +- Submit an Issue +- Create a Pull Request +- Join the discussion group \ No newline at end of file diff --git a/dev.md b/dev.md index 6c1a57bee..ac3891640 100644 --- a/dev.md +++ b/dev.md @@ -1,66 +1,66 @@ -# 开发指南 (Development Guide) +# Development Guide -## 目录 +## Table of Contents -- [本地开发环境配置](#本地开发环境配置) -- [Docker开发和部署](#docker开发和部署) -- [环境变量配置](#环境变量配置) -- [开发工作流程](#开发工作流程) -- [项目构建和部署](#项目构建和部署) -- [常见问题解决](#常见问题解决) +- [Local Development Environment Setup](#local-development-environment-setup) +- [Docker Development and Deployment](#docker-development-and-deployment) +- [Environment Variable Configuration](#environment-variable-configuration) +- [Development Workflow](#development-workflow) +- [Project Build and Deployment](#project-build-and-deployment) +- [Troubleshooting Common Issues](#troubleshooting-common-issues) -## 本地开发环境配置 +## Local Development Environment Setup -### 基础环境要求 +### Basic Environment Requirements - Node.js >= 18 - pnpm >= 8 - Git >= 2.0 -- VSCode (推荐) +- VSCode (Recommended) -### 开发环境设置 +### Development Environment Setup ```bash -# 1. 克隆项目 +# 1. Clone the project git clone https://github.com/linshenkx/prompt-optimizer.git cd prompt-optimizer -# 2. 安装依赖 +# 2. Install dependencies pnpm install -# 3. 启动开发服务 -pnpm dev # 主开发命令:构建core/ui并运行web应用 -pnpm dev:web # 仅运行web应用 -pnpm dev:fresh # 完整重置并重新启动开发环境 +# 3. Start development server +pnpm dev # Main development command: build core/ui and run web app +pnpm dev:web # Run web app only +pnpm dev:fresh # Complete reset and restart development environment ``` -## Docker开发和部署 +## Docker Development and Deployment -### 环境要求 +### Environment Requirements - Docker >= 20.10.0 -### Docker构建和运行 +### Docker Build and Run -#### 基础构建 +#### Basic Build ```bash -# 获取package.json中的版本号 -$VERSION=$(node -p "require('./package.json').version") +# Get version number from package.json +VERSION=$(node -p "require('./package.json').version") -# 构建镜像(使用动态版本号) +# Build image (using dynamic version number) docker build -t linshen/prompt-optimizer:$VERSION . -# 添加latest标签 +# Add latest tag docker tag linshen/prompt-optimizer:$VERSION linshen/prompt-optimizer:latest -# 运行容器 +# Run container docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer -e ACCESS_PASSWORD=1234!@#$ linshen/prompt-optimizer:$VERSION -# 推送 +# Push docker push linshen/prompt-optimizer:$VERSION docker push linshen/prompt-optimizer:latest ``` -docker本地构建测试 +Docker local build test ```shell docker build -t linshen/prompt-optimizer:test . docker rm -f prompt-optimizer @@ -69,37 +69,37 @@ docker run -d -p 80:80 --restart unless-stopped --name prompt-optimizer -e VITE_ ``` -### 多阶段构建说明 +### Multi-stage Build Explanation -Dockerfile使用了多阶段构建优化镜像大小: +The Dockerfile uses multi-stage builds to optimize image size: -1. `base`: 基础Node.js环境,安装pnpm -2. `builder`: 构建阶段,安装依赖并构建项目 -3. `production`: 最终镜像,只包含构建产物和nginx +1. `base`: Basic Node.js environment, installs pnpm +2. `builder`: Build stage, installs dependencies and builds the project +3. `production`: Final image, contains only build artifacts and nginx -## 环境变量配置 +## Environment Variable Configuration -### 本地开发环境变量 -在项目根目录创建 `.env.local` 文件: +### Local Development Environment Variables +Create a `.env.local` file in the project root directory: ```env -# OpenAI API配置 +# OpenAI API Configuration VITE_OPENAI_API_KEY=your_openai_api_key -# Gemini API配置 +# Gemini API Configuration VITE_GEMINI_API_KEY=your_gemini_api_key -# DeepSeek API配置 +# DeepSeek API Configuration VITE_DEEPSEEK_API_KEY=your_deepseek_api_key -# 自定义API配置 +# Custom API Configuration VITE_CUSTOM_API_KEY=your_custom_api_key VITE_CUSTOM_API_BASE_URL=your_custom_api_base_url VITE_CUSTOM_API_MODEL=your_custom_model_name ``` -### Docker环境变量 -通过 `-e` 参数设置容器环境变量: +### Docker Environment Variables +Set container environment variables using the `-e` parameter: ```bash docker run -d -p 80:80 \ @@ -108,91 +108,91 @@ docker run -d -p 80:80 \ prompt-optimizer ``` -## 开发工作流程 +## Development Workflow -### 代码提交规范 +### Code Commit Guidelines ```bash -# 提交格式 +# Commit format (): -# 示例 -feat(ui): 添加新的提示词编辑器组件 -fix(core): 修复API调用超时问题 +# Example +feat(ui): Add new prompt editor component +fix(core): Fix API call timeout issue ``` -### 测试流程 +### Testing Process ```bash -# 运行所有测试 +# Run all tests pnpm test -# 运行特定包的测试 +# Run tests for a specific package pnpm test:core pnpm test:ui pnpm test:web ``` -## 项目构建和部署 +## Project Build and Deployment -### 本地构建 +### Local Build ```bash -# 构建所有包 +# Build all packages pnpm build -# 构建特定包 +# Build a specific package pnpm build:core pnpm build:ui pnpm build:web pnpm build:ext ``` -### 常用Docker命令 +### Common Docker Commands ```bash -# 查看容器日志 +# View container logs docker logs -f prompt-optimizer -# 进入容器 +# Enter container docker exec -it prompt-optimizer sh -# 容器管理 +# Container management docker stop prompt-optimizer docker start prompt-optimizer docker restart prompt-optimizer -# 清理资源 +# Clean up resources docker rm prompt-optimizer docker rmi prompt-optimizer ``` -## 常见问题解决 +## Troubleshooting Common Issues -### 依赖安装问题 +### Dependency Installation Issues ```bash -# 清理依赖缓存 +# Clear dependency cache pnpm clean -# 重新安装依赖 +# Reinstall dependencies pnpm install --force ``` -### 开发环境问题 +### Development Environment Issues ```bash -# 完全重置开发环境 +# Completely reset development environment pnpm dev:fresh -# 清理构建缓存 +# Clear build cache pnpm clean rm -rf node_modules pnpm install ``` -### 构建失败处理 -1. 检查Node.js版本是否符合要求 -2. 清理构建缓存:`pnpm clean` -3. 重新安装依赖:`pnpm install` -4. 查看详细构建日志:`pnpm build --debug` +### Build Failure Handling +1. Check if Node.js version meets requirements +2. Clear build cache: `pnpm clean` +3. Reinstall dependencies: `pnpm install` +4. View detailed build logs: `pnpm build --debug` -### 容器运行问题 -1. 检查端口占用:`netstat -ano | findstr :80` -2. 检查容器日志:`docker logs prompt-optimizer` -3. 检查容器状态:`docker ps -a` +### Container Runtime Issues +1. Check for port conflicts: `netstat -ano | findstr :80` (Windows) or `sudo netstat -tulnp | grep :80` (Linux/macOS) +2. Check container logs: `docker logs prompt-optimizer` +3. Check container status: `docker ps -a` diff --git a/docs/README.md b/docs/README.md index f5c8d0988..9c68faf69 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,54 +1,53 @@ -# 项目文档索引 +# Project Documentation Index -## 文档合并说明 +## Document Consolidation Notice -为了提高文档的组织性和可读性,我们对项目文档进行了重构和合并。以下是文档合并情况: +To improve the organization and readability of our documentation, we have refactored and consolidated project documents. Here is a summary of the document consolidation: -| 新文档 | 包含原文档 | 说明 | +| New Document | Includes Original Documents | Description | |-------|------------|------| -| [technical-development-guide.md](./technical-development-guide.md) | development-guidelines.md, technical-documentation.md | 技术开发指南,整合了开发规范和技术文档 | -| [project-structure.md](./project-structure.md) | file-structure.md, fileNames.md | 项目结构说明,包含文件结构和目录组织 | -| [project-status.md](./project-status.md) | progress.md, chrome-extension-plan.md | 项目状态,包含进度和Chrome扩展计划 | +| [technical-development-guide.md](./technical-development-guide.md) | development-guidelines.md, technical-documentation.md | Technical Development Guide, integrating development specifications and technical documentation | +| [project-structure.md](./project-structure.md) | file-structure.md, fileNames.md | Project Structure Description, including file structure and directory organization | +| [project-status.md](./project-status.md) | progress.md, chrome-extension-plan.md | Project Status, including progress and Chrome extension plans | +## Core Documents -## 核心文档 +- [README.md](../README.md) - Project Overview +- [technical-development-guide.md](./technical-development-guide.md) - Technical Development Guide, including technology stack and development specifications +- [llm-params-guide.md](./llm-params-guide.md) - Detailed Guide for LLM Parameter Configuration +- [project-structure.md](./project-structure.md) - Project Structure, focusing on file and directory organization +- [project-status.md](./project-status.md) - Project Status, including progress and plans +- [prd.md](./prd.md) - Product Requirements Document -- [README.md](../README.md) - 项目总体介绍 -- [technical-development-guide.md](./technical-development-guide.md) - 技术开发指南,包含技术栈和开发规范 -- [llm-params-guide.md](./llm-params-guide.md) - LLM参数配置详细指南 -- [project-structure.md](./project-structure.md) - 项目结构,专注于文件和目录组织 -- [project-status.md](./project-status.md) - 项目状态,包含进度和计划 -- [prd.md](./prd.md) - 产品需求文档 +## Other Resources -## 其他资源 +- [experience.md](./experience.md) - Project Experience Summary +- [scratchpad.md](./scratchpad.md) - Development Notes (Simplified) +- [vercel.md](./vercel.md) / [vercel_en.md](./vercel_en.md) - Vercel Deployment Guide -- [experience.md](./experience.md) - 项目经验总结 -- [scratchpad.md](./scratchpad.md) - 开发笔记 (已简化) -- [vercel.md](./vercel.md) / [vercel_en.md](./vercel_en.md) - Vercel部署指南 +## How to Use the Documentation -## 如何使用文档 +1. **New Member Onboarding**: + * First, read README.md to understand the project overview. + * Review project-structure.md to understand the project structure. + * Refer to technical-development-guide.md to understand technical implementation and development specifications. -1. **新成员入职**: - - 首先阅读 README.md,了解项目概况 - - 查看 project-structure.md 了解项目结构 - - 参考 technical-development-guide.md 了解技术实现和开发规范 +2. **Development Reference**: + * Follow the development specifications in technical-development-guide.md. + * Consult technical-development-guide.md to understand the application flow. + * Refer to project-structure.md to understand code organization. -2. **开发参考**: - - 遵循 technical-development-guide.md 中的开发规范 - - 查阅 technical-development-guide.md 了解应用流程 - - 参考 project-structure.md 了解代码组织 +3. **Project Progress**: + * Check project-status.md to understand current progress and plans. + * Follow CHANGELOG.md for the latest changes. -3. **项目进度**: - - 通过 project-status.md 了解当前进度和计划 - - 关注 CHANGELOG.md 了解最新变更 +## Documentation Maintenance Guidelines -## 文档维护说明 +1. All documents are in Markdown format. +2. After updating a document, please add the update time at the end of the document. +3. For significant changes, please also update the change log in project-status.md. +4. Code examples in the documentation should be runnable and comply with project specifications. +5. Pay attention to the distinct responsibilities of different documents to avoid content duplication. +6. Deprecated documents should be marked as deprecated, and users should be guided to new documents. -1. 所有文档采用 Markdown 格式 -2. 文档更新后,请在文档末尾添加更新时间 -3. 重要变更请同时更新 project-status.md 中的更新记录 -4. 文档中的代码示例应确保可运行且符合项目规范 -5. 注意区分不同文档的职责,避免内容重复 -6. 弃用的文档应标记为已弃用,并引导用户使用新文档 - -最后更新:2025-01-06 \ No newline at end of file +Last updated: 2025-01-06 \ No newline at end of file diff --git a/package.json b/package.json index 787f99a64..701c4916e 100644 --- a/package.json +++ b/package.json @@ -92,4 +92,4 @@ "normalize-wheel-es": "^1.2.0", "vue-i18n": "^10.0.6" } -} +} \ No newline at end of file