Merge commit 'd803bfe2b1fe7f5e219e50ac20d6801a0a58ac75' as 'vendor/ruvector'
This commit is contained in:
5
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.d.ts
vendored
Normal file
5
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Basic usage examples for @ruvector/graph-data-generator
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=basic-usage.d.ts.map
|
||||
1
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.d.ts.map
vendored
Normal file
1
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.d.ts.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"basic-usage.d.ts","sourceRoot":"","sources":["basic-usage.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
||||
79
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.js
vendored
Normal file
79
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.js
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Basic usage examples for @ruvector/graph-data-generator
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_js_1 = require("../src/index.js");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
async function main() {
|
||||
// Initialize generator with OpenRouter API key
|
||||
const generator = (0, index_js_1.createGraphDataGenerator)({
|
||||
apiKey: process.env.OPENROUTER_API_KEY,
|
||||
model: 'moonshot/kimi-k2-instruct'
|
||||
});
|
||||
console.log('=== Knowledge Graph Generation ===');
|
||||
const knowledgeGraph = await generator.generateKnowledgeGraph({
|
||||
domain: 'technology',
|
||||
entities: 50,
|
||||
relationships: 150,
|
||||
includeEmbeddings: true,
|
||||
embeddingDimension: 768
|
||||
});
|
||||
console.log(`Generated ${knowledgeGraph.data.nodes.length} nodes`);
|
||||
console.log(`Generated ${knowledgeGraph.data.edges.length} edges`);
|
||||
console.log(`Duration: ${knowledgeGraph.metadata.duration}ms`);
|
||||
// Generate Cypher statements
|
||||
const cypher = generator.generateCypher(knowledgeGraph.data, {
|
||||
useConstraints: true,
|
||||
useIndexes: true,
|
||||
useMerge: false
|
||||
});
|
||||
// Save to file
|
||||
fs_1.default.writeFileSync('knowledge-graph.cypher', cypher);
|
||||
console.log('Saved Cypher to knowledge-graph.cypher');
|
||||
console.log('\n=== Social Network Generation ===');
|
||||
const socialNetwork = await generator.generateSocialNetwork({
|
||||
users: 100,
|
||||
avgConnections: 10,
|
||||
networkType: 'small-world',
|
||||
includeMetadata: true,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
console.log(`Generated ${socialNetwork.data.nodes.length} users`);
|
||||
console.log(`Generated ${socialNetwork.data.edges.length} connections`);
|
||||
const socialCypher = generator.generateCypher(socialNetwork.data);
|
||||
fs_1.default.writeFileSync('social-network.cypher', socialCypher);
|
||||
console.log('Saved Cypher to social-network.cypher');
|
||||
console.log('\n=== Temporal Events Generation ===');
|
||||
const temporalEvents = await generator.generateTemporalEvents({
|
||||
startDate: '2024-01-01',
|
||||
endDate: '2024-01-31',
|
||||
eventTypes: ['login', 'purchase', 'logout', 'error'],
|
||||
eventsPerDay: 20,
|
||||
entities: 25,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
console.log(`Generated ${temporalEvents.data.nodes.length} nodes`);
|
||||
console.log(`Generated ${temporalEvents.data.edges.length} edges`);
|
||||
const temporalCypher = generator.generateCypher(temporalEvents.data);
|
||||
fs_1.default.writeFileSync('temporal-events.cypher', temporalCypher);
|
||||
console.log('Saved Cypher to temporal-events.cypher');
|
||||
console.log('\n=== Entity Relationships Generation ===');
|
||||
const erGraph = await generator.generateEntityRelationships({
|
||||
domain: 'e-commerce',
|
||||
entityCount: 75,
|
||||
relationshipDensity: 0.2,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
console.log(`Generated ${erGraph.data.nodes.length} entities`);
|
||||
console.log(`Generated ${erGraph.data.edges.length} relationships`);
|
||||
const erCypher = generator.generateCypher(erGraph.data);
|
||||
fs_1.default.writeFileSync('entity-relationships.cypher', erCypher);
|
||||
console.log('Saved Cypher to entity-relationships.cypher');
|
||||
console.log('\n✓ All examples completed successfully!');
|
||||
}
|
||||
main().catch(console.error);
|
||||
//# sourceMappingURL=basic-usage.js.map
|
||||
1
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.js.map
vendored
Normal file
1
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"basic-usage.js","sourceRoot":"","sources":["basic-usage.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAEH,8CAA2D;AAC3D,4CAAoB;AAEpB,KAAK,UAAU,IAAI;IACjB,+CAA+C;IAC/C,MAAM,SAAS,GAAG,IAAA,mCAAwB,EAAC;QACzC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;QACtC,KAAK,EAAE,2BAA2B;KACnC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAClD,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,sBAAsB,CAAC;QAC5D,MAAM,EAAE,YAAY;QACpB,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,GAAG;QAClB,iBAAiB,EAAE,IAAI;QACvB,kBAAkB,EAAE,GAAG;KACxB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,aAAa,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,aAAa,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,aAAa,cAAc,CAAC,QAAQ,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ph-data-generator/examples/basic-usage.ts
vendored
Normal file
90
vendor/ruvector/npm/packages/graph-data-generator/examples/basic-usage.ts
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Basic usage examples for @ruvector/graph-data-generator
|
||||
*/
|
||||
|
||||
import { createGraphDataGenerator } from '../src/index.js';
|
||||
import fs from 'fs';
|
||||
|
||||
async function main() {
|
||||
// Initialize generator with OpenRouter API key
|
||||
const generator = createGraphDataGenerator({
|
||||
apiKey: process.env.OPENROUTER_API_KEY,
|
||||
model: 'moonshot/kimi-k2-instruct'
|
||||
});
|
||||
|
||||
console.log('=== Knowledge Graph Generation ===');
|
||||
const knowledgeGraph = await generator.generateKnowledgeGraph({
|
||||
domain: 'technology',
|
||||
entities: 50,
|
||||
relationships: 150,
|
||||
includeEmbeddings: true,
|
||||
embeddingDimension: 768
|
||||
});
|
||||
|
||||
console.log(`Generated ${knowledgeGraph.data.nodes.length} nodes`);
|
||||
console.log(`Generated ${knowledgeGraph.data.edges.length} edges`);
|
||||
console.log(`Duration: ${knowledgeGraph.metadata.duration}ms`);
|
||||
|
||||
// Generate Cypher statements
|
||||
const cypher = generator.generateCypher(knowledgeGraph.data, {
|
||||
useConstraints: true,
|
||||
useIndexes: true,
|
||||
useMerge: false
|
||||
});
|
||||
|
||||
// Save to file
|
||||
fs.writeFileSync('knowledge-graph.cypher', cypher);
|
||||
console.log('Saved Cypher to knowledge-graph.cypher');
|
||||
|
||||
console.log('\n=== Social Network Generation ===');
|
||||
const socialNetwork = await generator.generateSocialNetwork({
|
||||
users: 100,
|
||||
avgConnections: 10,
|
||||
networkType: 'small-world',
|
||||
includeMetadata: true,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
|
||||
console.log(`Generated ${socialNetwork.data.nodes.length} users`);
|
||||
console.log(`Generated ${socialNetwork.data.edges.length} connections`);
|
||||
|
||||
const socialCypher = generator.generateCypher(socialNetwork.data);
|
||||
fs.writeFileSync('social-network.cypher', socialCypher);
|
||||
console.log('Saved Cypher to social-network.cypher');
|
||||
|
||||
console.log('\n=== Temporal Events Generation ===');
|
||||
const temporalEvents = await generator.generateTemporalEvents({
|
||||
startDate: '2024-01-01',
|
||||
endDate: '2024-01-31',
|
||||
eventTypes: ['login', 'purchase', 'logout', 'error'],
|
||||
eventsPerDay: 20,
|
||||
entities: 25,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
|
||||
console.log(`Generated ${temporalEvents.data.nodes.length} nodes`);
|
||||
console.log(`Generated ${temporalEvents.data.edges.length} edges`);
|
||||
|
||||
const temporalCypher = generator.generateCypher(temporalEvents.data);
|
||||
fs.writeFileSync('temporal-events.cypher', temporalCypher);
|
||||
console.log('Saved Cypher to temporal-events.cypher');
|
||||
|
||||
console.log('\n=== Entity Relationships Generation ===');
|
||||
const erGraph = await generator.generateEntityRelationships({
|
||||
domain: 'e-commerce',
|
||||
entityCount: 75,
|
||||
relationshipDensity: 0.2,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
|
||||
console.log(`Generated ${erGraph.data.nodes.length} entities`);
|
||||
console.log(`Generated ${erGraph.data.edges.length} relationships`);
|
||||
|
||||
const erCypher = generator.generateCypher(erGraph.data);
|
||||
fs.writeFileSync('entity-relationships.cypher', erCypher);
|
||||
console.log('Saved Cypher to entity-relationships.cypher');
|
||||
|
||||
console.log('\n✓ All examples completed successfully!');
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Integration example with @ruvector/agentic-synth
|
||||
*
|
||||
* This example shows how to use both agentic-synth and graph-data-generator
|
||||
* together to create comprehensive synthetic datasets.
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=integration-with-agentic-synth.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"integration-with-agentic-synth.d.ts","sourceRoot":"","sources":["integration-with-agentic-synth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
||||
177
vendor/ruvector/npm/packages/graph-data-generator/examples/integration-with-agentic-synth.js
vendored
Normal file
177
vendor/ruvector/npm/packages/graph-data-generator/examples/integration-with-agentic-synth.js
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Integration example with @ruvector/agentic-synth
|
||||
*
|
||||
* This example shows how to use both agentic-synth and graph-data-generator
|
||||
* together to create comprehensive synthetic datasets.
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const agentic_synth_1 = require("@ruvector/agentic-synth");
|
||||
const index_js_1 = require("../src/index.js");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
async function main() {
|
||||
// Initialize both generators
|
||||
const synth = (0, agentic_synth_1.createSynth)({
|
||||
provider: 'gemini',
|
||||
apiKey: process.env.GEMINI_API_KEY,
|
||||
model: 'gemini-2.0-flash-exp'
|
||||
});
|
||||
const graphGen = (0, index_js_1.createGraphDataGenerator)({
|
||||
apiKey: process.env.OPENROUTER_API_KEY,
|
||||
model: 'moonshot/kimi-k2-instruct'
|
||||
});
|
||||
console.log('=== Hybrid Synthetic Data Generation ===\n');
|
||||
// Step 1: Generate structured user data with agentic-synth
|
||||
console.log('1. Generating user profiles with agentic-synth...');
|
||||
const userProfiles = await synth.generateStructured({
|
||||
count: 50,
|
||||
schema: {
|
||||
user_id: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
email: { type: 'string' },
|
||||
role: { type: 'string', enum: ['developer', 'designer', 'manager', 'analyst'] },
|
||||
skills: { type: 'array', items: { type: 'string' } },
|
||||
experience_years: { type: 'number', minimum: 0, maximum: 30 }
|
||||
}
|
||||
});
|
||||
console.log(`✓ Generated ${userProfiles.data.length} user profiles`);
|
||||
// Step 2: Generate project data with agentic-synth
|
||||
console.log('\n2. Generating project data with agentic-synth...');
|
||||
const projects = await synth.generateStructured({
|
||||
count: 20,
|
||||
schema: {
|
||||
project_id: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
description: { type: 'string' },
|
||||
status: { type: 'string', enum: ['active', 'completed', 'on-hold'] },
|
||||
start_date: { type: 'string' },
|
||||
tech_stack: { type: 'array', items: { type: 'string' } }
|
||||
}
|
||||
});
|
||||
console.log(`✓ Generated ${projects.data.length} projects`);
|
||||
// Step 3: Generate knowledge graph relationships with graph-data-generator
|
||||
console.log('\n3. Generating knowledge graph with relationships...');
|
||||
const knowledgeGraph = await graphGen.generateKnowledgeGraph({
|
||||
domain: 'software development teams',
|
||||
entities: 100,
|
||||
relationships: 300,
|
||||
entityTypes: ['Person', 'Project', 'Skill', 'Technology', 'Team'],
|
||||
relationshipTypes: [
|
||||
'WORKS_ON',
|
||||
'HAS_SKILL',
|
||||
'USES_TECHNOLOGY',
|
||||
'MEMBER_OF',
|
||||
'DEPENDS_ON',
|
||||
'MENTORS'
|
||||
],
|
||||
includeEmbeddings: true
|
||||
});
|
||||
console.log(`✓ Generated ${knowledgeGraph.data.nodes.length} nodes`);
|
||||
console.log(`✓ Generated ${knowledgeGraph.data.edges.length} edges`);
|
||||
// Step 4: Generate temporal event data
|
||||
console.log('\n4. Generating temporal events for user activities...');
|
||||
const temporalEvents = await graphGen.generateTemporalEvents({
|
||||
startDate: '2024-01-01',
|
||||
endDate: '2024-12-31',
|
||||
eventTypes: [
|
||||
'code_commit',
|
||||
'pull_request',
|
||||
'code_review',
|
||||
'deployment',
|
||||
'meeting',
|
||||
'task_completed'
|
||||
],
|
||||
eventsPerDay: 50,
|
||||
entities: 50,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
console.log(`✓ Generated ${temporalEvents.data.nodes.length} temporal nodes`);
|
||||
console.log(`✓ Generated ${temporalEvents.data.edges.length} temporal edges`);
|
||||
// Step 5: Generate time-series metrics with agentic-synth
|
||||
console.log('\n5. Generating time-series metrics with agentic-synth...');
|
||||
const metrics = await synth.generateTimeSeries({
|
||||
startDate: '2024-01-01',
|
||||
endDate: '2024-12-31',
|
||||
interval: '1d',
|
||||
metrics: ['code_quality', 'test_coverage', 'deployment_frequency'],
|
||||
trend: 'up',
|
||||
seasonality: true,
|
||||
noise: 0.1
|
||||
});
|
||||
console.log(`✓ Generated ${metrics.data.length} time-series data points`);
|
||||
// Step 6: Combine and export data
|
||||
console.log('\n6. Combining and exporting datasets...');
|
||||
// Save structured data as JSON
|
||||
fs_1.default.writeFileSync('users.json', JSON.stringify(userProfiles.data, null, 2));
|
||||
fs_1.default.writeFileSync('projects.json', JSON.stringify(projects.data, null, 2));
|
||||
fs_1.default.writeFileSync('metrics.json', JSON.stringify(metrics.data, null, 2));
|
||||
// Save graph data as Cypher
|
||||
const knowledgeCypher = graphGen.generateCypher(knowledgeGraph.data, {
|
||||
useConstraints: true,
|
||||
useIndexes: true,
|
||||
useMerge: true
|
||||
});
|
||||
fs_1.default.writeFileSync('knowledge-graph.cypher', knowledgeCypher);
|
||||
const temporalCypher = graphGen.generateCypher(temporalEvents.data, {
|
||||
useConstraints: true,
|
||||
useIndexes: true
|
||||
});
|
||||
fs_1.default.writeFileSync('temporal-events.cypher', temporalCypher);
|
||||
// Create a combined dataset summary
|
||||
const summary = {
|
||||
generation_timestamp: new Date().toISOString(),
|
||||
datasets: {
|
||||
user_profiles: {
|
||||
count: userProfiles.data.length,
|
||||
provider: 'gemini',
|
||||
file: 'users.json'
|
||||
},
|
||||
projects: {
|
||||
count: projects.data.length,
|
||||
provider: 'gemini',
|
||||
file: 'projects.json'
|
||||
},
|
||||
knowledge_graph: {
|
||||
nodes: knowledgeGraph.data.nodes.length,
|
||||
edges: knowledgeGraph.data.edges.length,
|
||||
provider: 'openrouter/kimi-k2',
|
||||
file: 'knowledge-graph.cypher',
|
||||
has_embeddings: true
|
||||
},
|
||||
temporal_events: {
|
||||
nodes: temporalEvents.data.nodes.length,
|
||||
edges: temporalEvents.data.edges.length,
|
||||
provider: 'openrouter/kimi-k2',
|
||||
file: 'temporal-events.cypher'
|
||||
},
|
||||
time_series_metrics: {
|
||||
count: metrics.data.length,
|
||||
provider: 'gemini',
|
||||
file: 'metrics.json'
|
||||
}
|
||||
},
|
||||
total_generation_time: {
|
||||
knowledge_graph: knowledgeGraph.metadata.duration,
|
||||
temporal_events: temporalEvents.metadata.duration
|
||||
}
|
||||
};
|
||||
fs_1.default.writeFileSync('dataset-summary.json', JSON.stringify(summary, null, 2));
|
||||
console.log('\n✓ All datasets generated and saved!');
|
||||
console.log('\nGenerated files:');
|
||||
console.log('- users.json (structured user profiles)');
|
||||
console.log('- projects.json (structured project data)');
|
||||
console.log('- metrics.json (time-series metrics)');
|
||||
console.log('- knowledge-graph.cypher (Neo4j graph with embeddings)');
|
||||
console.log('- temporal-events.cypher (Neo4j temporal events)');
|
||||
console.log('- dataset-summary.json (metadata and summary)');
|
||||
console.log('\n=== Integration Complete ===');
|
||||
console.log(`Total nodes in graphs: ${knowledgeGraph.data.nodes.length + temporalEvents.data.nodes.length}`);
|
||||
console.log(`Total edges in graphs: ${knowledgeGraph.data.edges.length + temporalEvents.data.edges.length}`);
|
||||
console.log(`Total structured records: ${userProfiles.data.length + projects.data.length}`);
|
||||
console.log(`Total time-series points: ${metrics.data.length}`);
|
||||
}
|
||||
main().catch(console.error);
|
||||
//# sourceMappingURL=integration-with-agentic-synth.js.map
|
||||
File diff suppressed because one or more lines are too long
194
vendor/ruvector/npm/packages/graph-data-generator/examples/integration-with-agentic-synth.ts
vendored
Normal file
194
vendor/ruvector/npm/packages/graph-data-generator/examples/integration-with-agentic-synth.ts
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* Integration example with @ruvector/agentic-synth
|
||||
*
|
||||
* This example shows how to use both agentic-synth and graph-data-generator
|
||||
* together to create comprehensive synthetic datasets.
|
||||
*/
|
||||
|
||||
import { createSynth } from '@ruvector/agentic-synth';
|
||||
import { createGraphDataGenerator } from '../src/index.js';
|
||||
import fs from 'fs';
|
||||
|
||||
async function main() {
|
||||
// Initialize both generators
|
||||
const synth = createSynth({
|
||||
provider: 'gemini',
|
||||
apiKey: process.env.GEMINI_API_KEY,
|
||||
model: 'gemini-2.0-flash-exp'
|
||||
});
|
||||
|
||||
const graphGen = createGraphDataGenerator({
|
||||
apiKey: process.env.OPENROUTER_API_KEY,
|
||||
model: 'moonshot/kimi-k2-instruct'
|
||||
});
|
||||
|
||||
console.log('=== Hybrid Synthetic Data Generation ===\n');
|
||||
|
||||
// Step 1: Generate structured user data with agentic-synth
|
||||
console.log('1. Generating user profiles with agentic-synth...');
|
||||
const userProfiles = await synth.generateStructured({
|
||||
count: 50,
|
||||
schema: {
|
||||
user_id: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
email: { type: 'string' },
|
||||
role: { type: 'string', enum: ['developer', 'designer', 'manager', 'analyst'] },
|
||||
skills: { type: 'array', items: { type: 'string' } },
|
||||
experience_years: { type: 'number', minimum: 0, maximum: 30 }
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`✓ Generated ${userProfiles.data.length} user profiles`);
|
||||
|
||||
// Step 2: Generate project data with agentic-synth
|
||||
console.log('\n2. Generating project data with agentic-synth...');
|
||||
const projects = await synth.generateStructured({
|
||||
count: 20,
|
||||
schema: {
|
||||
project_id: { type: 'string' },
|
||||
name: { type: 'string' },
|
||||
description: { type: 'string' },
|
||||
status: { type: 'string', enum: ['active', 'completed', 'on-hold'] },
|
||||
start_date: { type: 'string' },
|
||||
tech_stack: { type: 'array', items: { type: 'string' } }
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`✓ Generated ${projects.data.length} projects`);
|
||||
|
||||
// Step 3: Generate knowledge graph relationships with graph-data-generator
|
||||
console.log('\n3. Generating knowledge graph with relationships...');
|
||||
const knowledgeGraph = await graphGen.generateKnowledgeGraph({
|
||||
domain: 'software development teams',
|
||||
entities: 100,
|
||||
relationships: 300,
|
||||
entityTypes: ['Person', 'Project', 'Skill', 'Technology', 'Team'],
|
||||
relationshipTypes: [
|
||||
'WORKS_ON',
|
||||
'HAS_SKILL',
|
||||
'USES_TECHNOLOGY',
|
||||
'MEMBER_OF',
|
||||
'DEPENDS_ON',
|
||||
'MENTORS'
|
||||
],
|
||||
includeEmbeddings: true
|
||||
});
|
||||
|
||||
console.log(`✓ Generated ${knowledgeGraph.data.nodes.length} nodes`);
|
||||
console.log(`✓ Generated ${knowledgeGraph.data.edges.length} edges`);
|
||||
|
||||
// Step 4: Generate temporal event data
|
||||
console.log('\n4. Generating temporal events for user activities...');
|
||||
const temporalEvents = await graphGen.generateTemporalEvents({
|
||||
startDate: '2024-01-01',
|
||||
endDate: '2024-12-31',
|
||||
eventTypes: [
|
||||
'code_commit',
|
||||
'pull_request',
|
||||
'code_review',
|
||||
'deployment',
|
||||
'meeting',
|
||||
'task_completed'
|
||||
],
|
||||
eventsPerDay: 50,
|
||||
entities: 50,
|
||||
includeEmbeddings: false
|
||||
});
|
||||
|
||||
console.log(`✓ Generated ${temporalEvents.data.nodes.length} temporal nodes`);
|
||||
console.log(`✓ Generated ${temporalEvents.data.edges.length} temporal edges`);
|
||||
|
||||
// Step 5: Generate time-series metrics with agentic-synth
|
||||
console.log('\n5. Generating time-series metrics with agentic-synth...');
|
||||
const metrics = await synth.generateTimeSeries({
|
||||
startDate: '2024-01-01',
|
||||
endDate: '2024-12-31',
|
||||
interval: '1d',
|
||||
metrics: ['code_quality', 'test_coverage', 'deployment_frequency'],
|
||||
trend: 'up',
|
||||
seasonality: true,
|
||||
noise: 0.1
|
||||
});
|
||||
|
||||
console.log(`✓ Generated ${metrics.data.length} time-series data points`);
|
||||
|
||||
// Step 6: Combine and export data
|
||||
console.log('\n6. Combining and exporting datasets...');
|
||||
|
||||
// Save structured data as JSON
|
||||
fs.writeFileSync('users.json', JSON.stringify(userProfiles.data, null, 2));
|
||||
fs.writeFileSync('projects.json', JSON.stringify(projects.data, null, 2));
|
||||
fs.writeFileSync('metrics.json', JSON.stringify(metrics.data, null, 2));
|
||||
|
||||
// Save graph data as Cypher
|
||||
const knowledgeCypher = graphGen.generateCypher(knowledgeGraph.data, {
|
||||
useConstraints: true,
|
||||
useIndexes: true,
|
||||
useMerge: true
|
||||
});
|
||||
fs.writeFileSync('knowledge-graph.cypher', knowledgeCypher);
|
||||
|
||||
const temporalCypher = graphGen.generateCypher(temporalEvents.data, {
|
||||
useConstraints: true,
|
||||
useIndexes: true
|
||||
});
|
||||
fs.writeFileSync('temporal-events.cypher', temporalCypher);
|
||||
|
||||
// Create a combined dataset summary
|
||||
const summary = {
|
||||
generation_timestamp: new Date().toISOString(),
|
||||
datasets: {
|
||||
user_profiles: {
|
||||
count: userProfiles.data.length,
|
||||
provider: 'gemini',
|
||||
file: 'users.json'
|
||||
},
|
||||
projects: {
|
||||
count: projects.data.length,
|
||||
provider: 'gemini',
|
||||
file: 'projects.json'
|
||||
},
|
||||
knowledge_graph: {
|
||||
nodes: knowledgeGraph.data.nodes.length,
|
||||
edges: knowledgeGraph.data.edges.length,
|
||||
provider: 'openrouter/kimi-k2',
|
||||
file: 'knowledge-graph.cypher',
|
||||
has_embeddings: true
|
||||
},
|
||||
temporal_events: {
|
||||
nodes: temporalEvents.data.nodes.length,
|
||||
edges: temporalEvents.data.edges.length,
|
||||
provider: 'openrouter/kimi-k2',
|
||||
file: 'temporal-events.cypher'
|
||||
},
|
||||
time_series_metrics: {
|
||||
count: metrics.data.length,
|
||||
provider: 'gemini',
|
||||
file: 'metrics.json'
|
||||
}
|
||||
},
|
||||
total_generation_time: {
|
||||
knowledge_graph: knowledgeGraph.metadata.duration,
|
||||
temporal_events: temporalEvents.metadata.duration
|
||||
}
|
||||
};
|
||||
|
||||
fs.writeFileSync('dataset-summary.json', JSON.stringify(summary, null, 2));
|
||||
|
||||
console.log('\n✓ All datasets generated and saved!');
|
||||
console.log('\nGenerated files:');
|
||||
console.log('- users.json (structured user profiles)');
|
||||
console.log('- projects.json (structured project data)');
|
||||
console.log('- metrics.json (time-series metrics)');
|
||||
console.log('- knowledge-graph.cypher (Neo4j graph with embeddings)');
|
||||
console.log('- temporal-events.cypher (Neo4j temporal events)');
|
||||
console.log('- dataset-summary.json (metadata and summary)');
|
||||
|
||||
console.log('\n=== Integration Complete ===');
|
||||
console.log(`Total nodes in graphs: ${knowledgeGraph.data.nodes.length + temporalEvents.data.nodes.length}`);
|
||||
console.log(`Total edges in graphs: ${knowledgeGraph.data.edges.length + temporalEvents.data.edges.length}`);
|
||||
console.log(`Total structured records: ${userProfiles.data.length + projects.data.length}`);
|
||||
console.log(`Total time-series points: ${metrics.data.length}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
Reference in New Issue
Block a user