| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const http = require('http');
- console.log('创建测试书籍...');
- const data = JSON.stringify({
- title: '操作系统原理',
- description: '系统讲解操作系统的核心原理与设计思想,涵盖进程管理、内存管理、文件系统、设备管理、安全保护等关键模块,帮助学生建立完整的操作系统知识体系。',
- targetAudience: '大学生',
- style: '专业严谨',
- bookScale: '130000',
- knowledgeLevel: '进阶',
- industry: 'IT/计算机'
- });
- const options = {
- hostname: 'localhost',
- port: 3000,
- path: '/api/book-generator/langgraph/books',
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'Content-Length': Buffer.byteLength(data)
- }
- };
- const req = http.request(options, (res) => {
- let body = '';
-
- res.on('data', (chunk) => {
- body += chunk;
- });
-
- res.on('end', () => {
- console.log('响应状态:', res.statusCode);
- try {
- const responseData = JSON.parse(body);
- console.log('响应数据:', JSON.stringify(responseData, null, 2));
-
- if (res.statusCode === 200 && responseData.data) {
- console.log('\n✅ 书籍创建成功!');
- console.log('书籍 ID:', responseData.data.id);
- console.log('\n现在可以开始生成大纲了...');
- } else {
- console.log('\n❌ 创建失败:', responseData.message);
- }
- } catch (e) {
- console.log('响应体:', body);
- }
- });
- });
- req.on('error', (e) => {
- console.error('请求失败:', e.message);
- });
- req.write(data);
- req.end();
|