better chinese vs
This commit is contained in:
parent
6b02b2d00e
commit
327a32355a
17
README.md
17
README.md
@ -22,10 +22,12 @@ npm install
|
||||
cp .env.example .env.local
|
||||
```
|
||||
|
||||
3. Add your Replicate API token to `.env.local`:
|
||||
3. Add your OpenRouter API key to `.env.local`:
|
||||
```
|
||||
REPLICATE_API_TOKEN=your_replicate_api_token_here
|
||||
REPLICATE_MODEL=meta/llama-2-70b-chat:02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3
|
||||
OPENROUTER_API_KEY=your_openrouter_api_key_here
|
||||
OPENROUTER_MODEL=anthropic/claude-3.5-sonnet
|
||||
OPENROUTER_CHINESE_MODEL=deepseek/deepseek-chat
|
||||
NEXT_PUBLIC_SITE_URL=https://anything-vs-anything.com
|
||||
```
|
||||
|
||||
4. Run the development server:
|
||||
@ -44,16 +46,19 @@ npm run dev
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `REPLICATE_API_TOKEN`: Your Replicate API token (required)
|
||||
- `REPLICATE_MODEL`: The Replicate model to use (optional, defaults to Llama 2 70B)
|
||||
- `OPENROUTER_API_KEY`: Your OpenRouter API key (required)
|
||||
- `OPENROUTER_MODEL`: The default model to use (optional, defaults to Claude 3.5 Sonnet)
|
||||
- `OPENROUTER_CHINESE_MODEL`: The model to use for Chinese comparisons (optional, defaults to DeepSeek Chat for better Chinese support)
|
||||
- `NEXT_PUBLIC_SITE_URL`: Your site URL for API referrer (optional)
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- Next.js 15 with App Router
|
||||
- TypeScript
|
||||
- Tailwind CSS
|
||||
- Replicate AI API
|
||||
- OpenRouter AI API
|
||||
- React Markdown for table rendering
|
||||
- Automatic Chinese/English model switching for better localization
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
|
4663
pnpm-lock.yaml
generated
Normal file
4663
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const { item1, item2, description1, description2 } = await request.json();
|
||||
const { item1, item2, description1, description2, language } = await request.json();
|
||||
|
||||
if (!item1 || !item2) {
|
||||
return NextResponse.json(
|
||||
@ -11,11 +11,41 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const prompt = `Compare ${item1} and ${item2} in a detailed table format. ${
|
||||
description1 ? `Additional context for ${item1}: ${description1}` : ''
|
||||
} ${
|
||||
description2 ? `Additional context for ${item2}: ${description2}` : ''
|
||||
}
|
||||
// 根据传入的语言参数判断,默认为英文
|
||||
const isChinese = language === 'zh-CN';
|
||||
console.log(`isChinese? [${isChinese}]`)
|
||||
|
||||
const prompt = isChinese ?
|
||||
`请详细比较 ${item1} 和 ${item2},用中文表格格式展示。${description1 ? `\n\n${item1} 的补充信息:${description1}` : ''
|
||||
}${description2 ? `\n${item2} 的补充信息:${description2}` : ''
|
||||
}
|
||||
|
||||
请提供全面的中文对比分析,严格按照以下要求:
|
||||
|
||||
## 输出要求:
|
||||
1. **主要内容使用中文表达**
|
||||
2. **专业术语、品牌名称、技术名词可保持原文**
|
||||
3. **描述性文字和解释说明必须使用中文**
|
||||
4. **表格标题使用中文**
|
||||
|
||||
## 表格结构:
|
||||
- 创建多个对比维度的行(功能特点、优缺点、价格范围、适用场景、性能表现、用户体验等)
|
||||
- 每个对比项目都用清晰、客观的中文描述
|
||||
- 专业术语可保持原文,但需要中文解释说明
|
||||
- 包含详细的相似性和差异性分析
|
||||
- 确保对比内容平衡且信息丰富
|
||||
- 使用标准 markdown 表格格式
|
||||
|
||||
## 表格格式:
|
||||
表格必须包含三列:
|
||||
- 第一列:对比维度(中文)
|
||||
- 第二列:${item1}(中文描述,术语可保持原文)
|
||||
- 第三列:${item2}(中文描述,术语可保持原文)
|
||||
|
||||
请开始进行中文对比分析:` :
|
||||
`Compare ${item1} and ${item2} in a detailed table format. ${description1 ? `Additional context for ${item1}: ${description1}` : ''
|
||||
} ${description2 ? `Additional context for ${item2}: ${description2}` : ''
|
||||
}
|
||||
|
||||
Please provide a comprehensive comparison in a markdown table format with the following structure:
|
||||
- Create rows for different comparison aspects (features, pros, cons, price range, best use cases, etc.)
|
||||
@ -35,7 +65,9 @@ The table should have three columns: Aspect, ${item1}, ${item2}`;
|
||||
'X-Title': 'Anything vs Anything',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: process.env.OPENROUTER_MODEL || 'anthropic/claude-3.5-sonnet',
|
||||
model: isChinese && process.env.OPENROUTER_CHINESE_MODEL
|
||||
? process.env.OPENROUTER_CHINESE_MODEL
|
||||
: process.env.OPENROUTER_MODEL || 'anthropic/claude-3.5-sonnet',
|
||||
messages: [
|
||||
{
|
||||
role: 'user',
|
||||
|
@ -40,6 +40,7 @@ export default function Home() {
|
||||
item2,
|
||||
description1,
|
||||
description2,
|
||||
language: 'en',
|
||||
}),
|
||||
});
|
||||
|
||||
|
@ -40,6 +40,7 @@ export default function HomePage() {
|
||||
item2,
|
||||
description1,
|
||||
description2,
|
||||
language: 'zh-CN',
|
||||
}),
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user