Files
zhuiguang-ai/scripts/test-deepseek.mjs
T

78 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import OpenAI from "openai";
import "dotenv/config";
const openai = new OpenAI({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com/v1",
});
const REVIEW_PROMPT = `你是一个GitHub开源项目评测专家。请基于以下项目信息进行五维深度评测,并以JSON格式返回。务必只返回JSON,不要包含任何其他文字或Markdown格式。
项目信息:
- 仓库全名:{repoName}
- 简介:{description}
- GitHub Stars:{stars}
- 开源许可证:{license}
- README摘要(前1500字):{readmeSummary}
请严格按照以下JSON结构输出:
{
"capability": { "score": 4.5, "summary": "一句话亮点(15字内)", "detail": "80-120字场景能力分析" },
"devExp": { "score": 3.5, "summary": "上手体验总结", "detail": "80-120字,包含安装、文档、API评价" },
"costLicense": { "score": 4.0, "summary": "成本与许可总结", "detail": "80-120字,包含硬件成本、API定价、许可证风险" },
"community": { "score": 4.5, "summary": "社区健康度总结", "detail": "80-120字,包含Issue响应、PR频率、生态描述" },
"performance": { "score": 3.5, "summary": "性能稳定性总结", "detail": "80-120字,包含运行效率、稳定性、输出质量" },
"overall": 4.0,
"tags": ["标签1", "标签2", "标签3"]
}
评分要求:
- 分数为1-5之间,可使用0.5步长
- 综合分应为五个维度分数的算术平均值(保留1位小数)
- 每个维度的summary需严格控制在15字以内
- 每个维度的detail需严格控制在80-120字
- 标签从以下类别中选择最匹配的3-5个:LLM框架, Agent框架, RAG, 提示工程, 多模态, 代码助手, 模型训练, 数据工程, 部署工具, 评测工具, 安全对齐, 其他`;
(async () => {
console.log("🧪 测试 DeepSeek 评测生成...\n");
const testRepo = {
name: "langflow-ai/langflow",
description:
"Langflow is a low-code app builder for RAG and multi-agent AI applications.",
stars: 148000,
license: "MIT",
readme:
"Langflow is a visual framework for building multi-agent and RAG applications. It is open-source, Python-based, and fully customizable. Model and vector store agnostic.",
};
const prompt = REVIEW_PROMPT
.replace("{repoName}", testRepo.name)
.replace("{description}", testRepo.description)
.replace("{stars}", testRepo.stars.toString())
.replace("{license}", testRepo.license)
.replace("{readmeSummary}", testRepo.readme.substring(0, 1500));
const completion = await openai.chat.completions.create({
model: "deepseek-v4-pro",
messages: [{ role: "user", content: prompt }],
temperature: 0.3,
});
const content = completion.choices[0]?.message?.content;
if (!content) {
console.error("❌ DeepSeek API 返回内容为空");
process.exit(1);
}
const jsonMatch = content.match(/\{[\s\S]*\}/);
if (!jsonMatch) {
console.error("❌ 无法从响应中提取JSON:", content.substring(0, 200));
process.exit(1);
}
const result = JSON.parse(jsonMatch[0]);
console.log("✅ 生成的评测结果:\n");
console.log(JSON.stringify(result, null, 2));
})();