@carlonicora/nestjs-neo4jsonapi 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/agents.modules.d.ts.map +1 -1
- package/dist/agents/agents.modules.js +21 -2
- package/dist/agents/agents.modules.js.map +1 -1
- package/dist/agents/community.detector/community.detector.module.d.ts +3 -0
- package/dist/agents/community.detector/community.detector.module.d.ts.map +1 -0
- package/dist/agents/community.detector/community.detector.module.js +25 -0
- package/dist/agents/community.detector/community.detector.module.js.map +1 -0
- package/dist/agents/community.detector/services/community.detector.service.d.ts +63 -0
- package/dist/agents/community.detector/services/community.detector.service.d.ts.map +1 -0
- package/dist/agents/community.detector/services/community.detector.service.js +343 -0
- package/dist/agents/community.detector/services/community.detector.service.js.map +1 -0
- package/dist/agents/community.summariser/community.summariser.module.d.ts +3 -0
- package/dist/agents/community.summariser/community.summariser.module.d.ts.map +1 -0
- package/dist/agents/community.summariser/community.summariser.module.js +33 -0
- package/dist/agents/community.summariser/community.summariser.module.js.map +1 -0
- package/dist/agents/community.summariser/processors/community.summariser.processor.d.ts +21 -0
- package/dist/agents/community.summariser/processors/community.summariser.processor.d.ts.map +1 -0
- package/dist/agents/community.summariser/processors/community.summariser.processor.js +70 -0
- package/dist/agents/community.summariser/processors/community.summariser.processor.js.map +1 -0
- package/dist/agents/community.summariser/services/community.summariser.service.d.ts +26 -0
- package/dist/agents/community.summariser/services/community.summariser.service.d.ts.map +1 -0
- package/dist/agents/community.summariser/services/community.summariser.service.js +155 -0
- package/dist/agents/community.summariser/services/community.summariser.service.js.map +1 -0
- package/dist/agents/drift/contexts/drift.context.d.ts +56 -0
- package/dist/agents/drift/contexts/drift.context.d.ts.map +1 -0
- package/dist/agents/drift/contexts/drift.context.js +91 -0
- package/dist/agents/drift/contexts/drift.context.js.map +1 -0
- package/dist/agents/drift/drift.module.d.ts +3 -0
- package/dist/agents/drift/drift.module.d.ts.map +1 -0
- package/dist/agents/drift/drift.module.js +44 -0
- package/dist/agents/drift/drift.module.js.map +1 -0
- package/dist/agents/drift/nodes/community.search.node.service.d.ts +12 -0
- package/dist/agents/drift/nodes/community.search.node.service.d.ts.map +1 -0
- package/dist/agents/drift/nodes/community.search.node.service.js +57 -0
- package/dist/agents/drift/nodes/community.search.node.service.js.map +1 -0
- package/dist/agents/drift/nodes/followup.node.service.d.ts +28 -0
- package/dist/agents/drift/nodes/followup.node.service.d.ts.map +1 -0
- package/dist/agents/drift/nodes/followup.node.service.js +174 -0
- package/dist/agents/drift/nodes/followup.node.service.js.map +1 -0
- package/dist/agents/drift/nodes/hyde.node.service.d.ts +21 -0
- package/dist/agents/drift/nodes/hyde.node.service.d.ts.map +1 -0
- package/dist/agents/drift/nodes/hyde.node.service.js +114 -0
- package/dist/agents/drift/nodes/hyde.node.service.js.map +1 -0
- package/dist/agents/drift/nodes/primer.answer.node.service.d.ts +17 -0
- package/dist/agents/drift/nodes/primer.answer.node.service.d.ts.map +1 -0
- package/dist/agents/drift/nodes/primer.answer.node.service.js +110 -0
- package/dist/agents/drift/nodes/primer.answer.node.service.js.map +1 -0
- package/dist/agents/drift/nodes/synthesis.node.service.d.ts +17 -0
- package/dist/agents/drift/nodes/synthesis.node.service.d.ts.map +1 -0
- package/dist/agents/drift/nodes/synthesis.node.service.js +105 -0
- package/dist/agents/drift/nodes/synthesis.node.service.js.map +1 -0
- package/dist/agents/drift/services/drift.migration.service.d.ts +47 -0
- package/dist/agents/drift/services/drift.migration.service.d.ts.map +1 -0
- package/dist/agents/drift/services/drift.migration.service.js +114 -0
- package/dist/agents/drift/services/drift.migration.service.js.map +1 -0
- package/dist/agents/drift/services/drift.search.service.d.ts +52 -0
- package/dist/agents/drift/services/drift.search.service.d.ts.map +1 -0
- package/dist/agents/drift/services/drift.search.service.js +185 -0
- package/dist/agents/drift/services/drift.search.service.js.map +1 -0
- package/dist/agents/graph.creator/interfaces/chunk.analysis.interface.d.ts +4 -0
- package/dist/agents/graph.creator/interfaces/chunk.analysis.interface.d.ts.map +1 -1
- package/dist/agents/graph.creator/services/graph.creator.service.d.ts +1 -1
- package/dist/agents/graph.creator/services/graph.creator.service.d.ts.map +1 -1
- package/dist/agents/graph.creator/services/graph.creator.service.js +43 -0
- package/dist/agents/graph.creator/services/graph.creator.service.js.map +1 -1
- package/dist/agents/index.d.ts +8 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +18 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/responder/contexts/responder.context.d.ts +3 -0
- package/dist/agents/responder/contexts/responder.context.d.ts.map +1 -1
- package/dist/agents/responder/contexts/responder.context.js +8 -0
- package/dist/agents/responder/contexts/responder.context.js.map +1 -1
- package/dist/agents/responder/factories/responder.context.factory.d.ts +1 -0
- package/dist/agents/responder/factories/responder.context.factory.d.ts.map +1 -1
- package/dist/agents/responder/factories/responder.context.factory.js +2 -0
- package/dist/agents/responder/factories/responder.context.factory.js.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts +22 -0
- package/dist/agents/responder/nodes/responder.answer.node.service.d.ts.map +1 -1
- package/dist/agents/responder/nodes/responder.answer.node.service.js +155 -0
- package/dist/agents/responder/nodes/responder.answer.node.service.js.map +1 -1
- package/dist/agents/responder/responder.module.d.ts.map +1 -1
- package/dist/agents/responder/responder.module.js +2 -1
- package/dist/agents/responder/responder.module.js.map +1 -1
- package/dist/agents/responder/services/responder.service.d.ts +17 -1
- package/dist/agents/responder/services/responder.service.d.ts.map +1 -1
- package/dist/agents/responder/services/responder.service.js +49 -5
- package/dist/agents/responder/services/responder.service.js.map +1 -1
- package/dist/common/interfaces/agents/graph.creator.interface.d.ts +4 -0
- package/dist/common/interfaces/agents/graph.creator.interface.d.ts.map +1 -1
- package/dist/config/enums/queue.id.d.ts +2 -1
- package/dist/config/enums/queue.id.d.ts.map +1 -1
- package/dist/config/enums/queue.id.js +1 -0
- package/dist/config/enums/queue.id.js.map +1 -1
- package/dist/config/interfaces/config.prompts.interface.d.ts +5 -0
- package/dist/config/interfaces/config.prompts.interface.d.ts.map +1 -1
- package/dist/foundations/chunk/services/chunk.service.d.ts.map +1 -1
- package/dist/foundations/chunk/services/chunk.service.js +8 -0
- package/dist/foundations/chunk/services/chunk.service.js.map +1 -1
- package/dist/foundations/community/community.module.d.ts +5 -0
- package/dist/foundations/community/community.module.d.ts.map +1 -0
- package/dist/foundations/community/community.module.js +29 -0
- package/dist/foundations/community/community.module.js.map +1 -0
- package/dist/foundations/community/entities/community.entity.d.ts +18 -0
- package/dist/foundations/community/entities/community.entity.d.ts.map +1 -0
- package/dist/foundations/community/entities/community.entity.js +3 -0
- package/dist/foundations/community/entities/community.entity.js.map +1 -0
- package/dist/foundations/community/entities/community.map.d.ts +8 -0
- package/dist/foundations/community/entities/community.map.d.ts.map +1 -0
- package/dist/foundations/community/entities/community.map.js +23 -0
- package/dist/foundations/community/entities/community.map.js.map +1 -0
- package/dist/foundations/community/entities/community.meta.d.ts +3 -0
- package/dist/foundations/community/entities/community.meta.d.ts.map +1 -0
- package/dist/foundations/community/entities/community.meta.js +10 -0
- package/dist/foundations/community/entities/community.meta.js.map +1 -0
- package/dist/foundations/community/entities/community.model.d.ts +4 -0
- package/dist/foundations/community/entities/community.model.d.ts.map +1 -0
- package/dist/foundations/community/entities/community.model.js +15 -0
- package/dist/foundations/community/entities/community.model.js.map +1 -0
- package/dist/foundations/community/repositories/community.repository.d.ts +138 -0
- package/dist/foundations/community/repositories/community.repository.d.ts.map +1 -0
- package/dist/foundations/community/repositories/community.repository.js +446 -0
- package/dist/foundations/community/repositories/community.repository.js.map +1 -0
- package/dist/foundations/community/services/community.service.d.ts +8 -0
- package/dist/foundations/community/services/community.service.d.ts.map +1 -0
- package/dist/foundations/community/services/community.service.js +28 -0
- package/dist/foundations/community/services/community.service.js.map +1 -0
- package/dist/foundations/keyconcept/entities/key.concept.entity.d.ts +1 -0
- package/dist/foundations/keyconcept/entities/key.concept.entity.d.ts.map +1 -1
- package/dist/foundations/keyconcept/entities/key.concept.map.d.ts.map +1 -1
- package/dist/foundations/keyconcept/entities/key.concept.map.js +1 -0
- package/dist/foundations/keyconcept/entities/key.concept.map.js.map +1 -1
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts +13 -2
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.d.ts.map +1 -1
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.js +22 -2
- package/dist/foundations/keyconcept/repositories/keyconcept.repository.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CommunitySummariserProcessor = void 0;
|
|
13
|
+
const bullmq_1 = require("@nestjs/bullmq");
|
|
14
|
+
const bullmq_2 = require("bullmq");
|
|
15
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
16
|
+
const config_1 = require("../../../config");
|
|
17
|
+
const logging_service_1 = require("../../../core/logging/services/logging.service");
|
|
18
|
+
const community_summariser_service_1 = require("../services/community.summariser.service");
|
|
19
|
+
let CommunitySummariserProcessor = class CommunitySummariserProcessor extends bullmq_1.WorkerHost {
|
|
20
|
+
constructor(summariserService, cls, logger) {
|
|
21
|
+
super();
|
|
22
|
+
this.summariserService = summariserService;
|
|
23
|
+
this.cls = cls;
|
|
24
|
+
this.logger = logger;
|
|
25
|
+
}
|
|
26
|
+
onActive(job) {
|
|
27
|
+
this.logger.debug(`Processing community summariser job ${job.name} (ID: ${job.id})`);
|
|
28
|
+
}
|
|
29
|
+
onError(job) {
|
|
30
|
+
this.logger.error(`Error processing community summariser job ${job.name} (ID: ${job.id}). Reason: ${job.failedReason}`);
|
|
31
|
+
}
|
|
32
|
+
onCompleted(job) {
|
|
33
|
+
this.logger.debug(`Completed community summariser job ${job.name} (ID: ${job.id})`);
|
|
34
|
+
}
|
|
35
|
+
async process(job) {
|
|
36
|
+
const { companyId, batchSize = 10 } = job.data;
|
|
37
|
+
await this.cls.run(async () => {
|
|
38
|
+
this.cls.set("companyId", companyId);
|
|
39
|
+
this.logger.log(`Starting community summarisation for company ${companyId} (batch size: ${batchSize})`, "CommunitySummariserProcessor");
|
|
40
|
+
const processedCount = await this.summariserService.processStaleCommunities(batchSize);
|
|
41
|
+
this.logger.log(`Processed ${processedCount} stale communities for company ${companyId}`, "CommunitySummariserProcessor");
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.CommunitySummariserProcessor = CommunitySummariserProcessor;
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, bullmq_1.OnWorkerEvent)("active"),
|
|
48
|
+
__metadata("design:type", Function),
|
|
49
|
+
__metadata("design:paramtypes", [bullmq_2.Job]),
|
|
50
|
+
__metadata("design:returntype", void 0)
|
|
51
|
+
], CommunitySummariserProcessor.prototype, "onActive", null);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, bullmq_1.OnWorkerEvent)("failed"),
|
|
54
|
+
__metadata("design:type", Function),
|
|
55
|
+
__metadata("design:paramtypes", [bullmq_2.Job]),
|
|
56
|
+
__metadata("design:returntype", void 0)
|
|
57
|
+
], CommunitySummariserProcessor.prototype, "onError", null);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, bullmq_1.OnWorkerEvent)("completed"),
|
|
60
|
+
__metadata("design:type", Function),
|
|
61
|
+
__metadata("design:paramtypes", [bullmq_2.Job]),
|
|
62
|
+
__metadata("design:returntype", void 0)
|
|
63
|
+
], CommunitySummariserProcessor.prototype, "onCompleted", null);
|
|
64
|
+
exports.CommunitySummariserProcessor = CommunitySummariserProcessor = __decorate([
|
|
65
|
+
(0, bullmq_1.Processor)(config_1.QueueId.COMMUNITY_SUMMARISER, { concurrency: 1, lockDuration: 1000 * 60 * 5 }),
|
|
66
|
+
__metadata("design:paramtypes", [community_summariser_service_1.CommunitySummariserService,
|
|
67
|
+
nestjs_cls_1.ClsService,
|
|
68
|
+
logging_service_1.AppLoggingService])
|
|
69
|
+
], CommunitySummariserProcessor);
|
|
70
|
+
//# sourceMappingURL=community.summariser.processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"community.summariser.processor.js","sourceRoot":"","sources":["../../../../src/agents/community.summariser/processors/community.summariser.processor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAsE;AACtE,mCAA6B;AAC7B,2CAAwC;AACxC,4CAA0C;AAC1C,oFAAmF;AACnF,2FAAsF;AAQ/E,IAAM,4BAA4B,GAAlC,MAAM,4BAA6B,SAAQ,mBAAU;IAC1D,YACmB,iBAA6C,EAC7C,GAAe,EACf,MAAyB;QAE1C,KAAK,EAAE,CAAC;QAJS,sBAAiB,GAAjB,iBAAiB,CAA4B;QAC7C,QAAG,GAAH,GAAG,CAAY;QACf,WAAM,GAAN,MAAM,CAAmB;IAG5C,CAAC;IAGD,QAAQ,CAAC,GAAQ;QACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uCAAuC,GAAG,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACvF,CAAC;IAGD,OAAO,CAAC,GAAQ;QACd,IAAI,CAAC,MAAM,CAA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C;qCAGjD,yDAA0B;QACxC,uBAAU;QACP,mCAAiB;GAJjC,4BAA4B,CA6CxC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
import { BaseConfigInterface } from "../../../config/interfaces";
|
|
3
|
+
import { EmbedderService } from "../../../core";
|
|
4
|
+
import { LLMService } from "../../../core/llm/services/llm.service";
|
|
5
|
+
import { AppLoggingService } from "../../../core/logging/services/logging.service";
|
|
6
|
+
import { Community } from "../../../foundations/community/entities/community.entity";
|
|
7
|
+
import { CommunityRepository } from "../../../foundations/community/repositories/community.repository";
|
|
8
|
+
export declare const prompt = "\nYou are an expert knowledge analyst tasked with summarizing a community of related entities from a knowledge graph.\n\n## Your Task\n\nGiven a cluster of entities (key concepts) and their relationships, create a comprehensive summary that:\n\n1. **Identifies the Main Theme**: What is the central topic or domain this cluster represents?\n2. **Describes Key Entities**: Explain the most important entities and their roles within this cluster\n3. **Explains Relationships**: Describe how the entities are connected and interact\n4. **Provides Context**: Give context for why these entities are grouped together\n\n## Guidelines\n\n- Write in clear, professional prose\n- Focus on the most significant entities and relationships\n- Provide actionable insights where possible\n- Keep the summary between 200-500 words\n- Use the entity descriptions when available to enrich your summary\n\n## Output Format\n\nProvide:\n- **title**: A concise, descriptive title for this community (max 50 characters)\n- **summary**: A narrative summary following the guidelines above\n- **rating**: A quality score from 0-100 based on:\n - Coherence: How well do the entities relate to each other?\n - Completeness: Does the cluster represent a meaningful concept?\n - Usefulness: How valuable is this cluster for understanding the domain?\n";
|
|
9
|
+
export declare class CommunitySummariserService {
|
|
10
|
+
private readonly llmService;
|
|
11
|
+
private readonly embedderService;
|
|
12
|
+
private readonly communityRepository;
|
|
13
|
+
private readonly logger;
|
|
14
|
+
private readonly configService;
|
|
15
|
+
private readonly systemPrompt;
|
|
16
|
+
constructor(llmService: LLMService, embedderService: EmbedderService, communityRepository: CommunityRepository, logger: AppLoggingService, configService: ConfigService<BaseConfigInterface>);
|
|
17
|
+
/**
|
|
18
|
+
* Process stale communities and generate summaries
|
|
19
|
+
*/
|
|
20
|
+
processStaleCommunities(batchSize?: number): Promise<number>;
|
|
21
|
+
/**
|
|
22
|
+
* Generate summary for a single community
|
|
23
|
+
*/
|
|
24
|
+
generateSummary(community: Community): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=community.summariser.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"community.summariser.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/community.summariser/services/community.summariser.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,0DAA0D,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AAEvG,eAAO,MAAM,MAAM,ozCA6BlB,CAAC;AAmBF,qBACa,0BAA0B;IAInC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAGnB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAMpE;;OAEG;IACG,uBAAuB,CAAC,SAAS,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBtE;;OAEG;IACG,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAkE3D"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CommunitySummariserService = exports.prompt = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
const zod_1 = require("zod");
|
|
16
|
+
const core_1 = require("../../../core");
|
|
17
|
+
const llm_service_1 = require("../../../core/llm/services/llm.service");
|
|
18
|
+
const logging_service_1 = require("../../../core/logging/services/logging.service");
|
|
19
|
+
const community_repository_1 = require("../../../foundations/community/repositories/community.repository");
|
|
20
|
+
exports.prompt = `
|
|
21
|
+
You are an expert knowledge analyst tasked with summarizing a community of related entities from a knowledge graph.
|
|
22
|
+
|
|
23
|
+
## Your Task
|
|
24
|
+
|
|
25
|
+
Given a cluster of entities (key concepts) and their relationships, create a comprehensive summary that:
|
|
26
|
+
|
|
27
|
+
1. **Identifies the Main Theme**: What is the central topic or domain this cluster represents?
|
|
28
|
+
2. **Describes Key Entities**: Explain the most important entities and their roles within this cluster
|
|
29
|
+
3. **Explains Relationships**: Describe how the entities are connected and interact
|
|
30
|
+
4. **Provides Context**: Give context for why these entities are grouped together
|
|
31
|
+
|
|
32
|
+
## Guidelines
|
|
33
|
+
|
|
34
|
+
- Write in clear, professional prose
|
|
35
|
+
- Focus on the most significant entities and relationships
|
|
36
|
+
- Provide actionable insights where possible
|
|
37
|
+
- Keep the summary between 200-500 words
|
|
38
|
+
- Use the entity descriptions when available to enrich your summary
|
|
39
|
+
|
|
40
|
+
## Output Format
|
|
41
|
+
|
|
42
|
+
Provide:
|
|
43
|
+
- **title**: A concise, descriptive title for this community (max 50 characters)
|
|
44
|
+
- **summary**: A narrative summary following the guidelines above
|
|
45
|
+
- **rating**: A quality score from 0-100 based on:
|
|
46
|
+
- Coherence: How well do the entities relate to each other?
|
|
47
|
+
- Completeness: Does the cluster represent a meaningful concept?
|
|
48
|
+
- Usefulness: How valuable is this cluster for understanding the domain?
|
|
49
|
+
`;
|
|
50
|
+
const outputSchema = zod_1.z.object({
|
|
51
|
+
title: zod_1.z.string().describe("A concise, descriptive title for this community (max 50 characters)"),
|
|
52
|
+
summary: zod_1.z.string().describe("A narrative summary of the community (200-500 words)"),
|
|
53
|
+
rating: zod_1.z
|
|
54
|
+
.number()
|
|
55
|
+
.min(0)
|
|
56
|
+
.max(100)
|
|
57
|
+
.describe("Quality score from 0-100 based on coherence, completeness, and usefulness"),
|
|
58
|
+
});
|
|
59
|
+
const inputSchema = zod_1.z.object({
|
|
60
|
+
entities: zod_1.z.string().describe("List of entities in the community with their descriptions"),
|
|
61
|
+
relationships: zod_1.z.string().describe("List of relationships between entities"),
|
|
62
|
+
level: zod_1.z.number().describe("Hierarchy level of the community (0 = most granular)"),
|
|
63
|
+
memberCount: zod_1.z.number().describe("Number of entities in this community"),
|
|
64
|
+
});
|
|
65
|
+
let CommunitySummariserService = class CommunitySummariserService {
|
|
66
|
+
constructor(llmService, embedderService, communityRepository, logger, configService) {
|
|
67
|
+
this.llmService = llmService;
|
|
68
|
+
this.embedderService = embedderService;
|
|
69
|
+
this.communityRepository = communityRepository;
|
|
70
|
+
this.logger = logger;
|
|
71
|
+
this.configService = configService;
|
|
72
|
+
const prompts = this.configService.get("prompts");
|
|
73
|
+
this.systemPrompt = prompts?.communitySummariser ?? exports.prompt;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Process stale communities and generate summaries
|
|
77
|
+
*/
|
|
78
|
+
async processStaleCommunities(batchSize = 10) {
|
|
79
|
+
const staleCommunities = await this.communityRepository.findStaleCommunities(batchSize);
|
|
80
|
+
this.logger.debug(`Found ${staleCommunities.length} stale communities to process`, "CommunitySummariserService");
|
|
81
|
+
let processedCount = 0;
|
|
82
|
+
for (const community of staleCommunities) {
|
|
83
|
+
try {
|
|
84
|
+
await this.generateSummary(community);
|
|
85
|
+
processedCount++;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
this.logger.error(`Failed to generate summary for community ${community.id}: ${error.message}`, "CommunitySummariserService");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return processedCount;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generate summary for a single community
|
|
95
|
+
*/
|
|
96
|
+
async generateSummary(community) {
|
|
97
|
+
this.logger.debug(`Generating summary for community ${community.id} (level: ${community.level})`, "CommunitySummariserService");
|
|
98
|
+
// Fetch member KeyConcepts with descriptions
|
|
99
|
+
const members = await this.communityRepository.findMemberKeyConcepts(community.id);
|
|
100
|
+
if (members.length === 0) {
|
|
101
|
+
this.logger.warn(`Community ${community.id} has no members, skipping`, "CommunitySummariserService");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Fetch relationships between members
|
|
105
|
+
const relationships = await this.communityRepository.findMemberRelationships(community.id);
|
|
106
|
+
// Format entities for LLM
|
|
107
|
+
const entitiesText = members
|
|
108
|
+
.map((m) => {
|
|
109
|
+
const desc = m.description ? `: ${m.description}` : "";
|
|
110
|
+
return `- ${m.value}${desc}`;
|
|
111
|
+
})
|
|
112
|
+
.join("\n");
|
|
113
|
+
// Format relationships for LLM
|
|
114
|
+
const relationshipsText = relationships.length > 0
|
|
115
|
+
? relationships.map((r) => `- ${r.keyConcept1} <-> ${r.keyConcept2} (weight: ${r.weight})`).join("\n")
|
|
116
|
+
: "No explicit relationships between members.";
|
|
117
|
+
// Call LLM to generate summary
|
|
118
|
+
const inputParams = {
|
|
119
|
+
entities: entitiesText,
|
|
120
|
+
relationships: relationshipsText,
|
|
121
|
+
level: community.level,
|
|
122
|
+
memberCount: members.length,
|
|
123
|
+
};
|
|
124
|
+
const llmResponse = await this.llmService.call({
|
|
125
|
+
inputSchema,
|
|
126
|
+
inputParams,
|
|
127
|
+
outputSchema,
|
|
128
|
+
systemPrompts: [this.systemPrompt],
|
|
129
|
+
temperature: 0.3,
|
|
130
|
+
});
|
|
131
|
+
// Generate embedding for the summary
|
|
132
|
+
const embedding = await this.embedderService.vectoriseText({
|
|
133
|
+
text: `${llmResponse.title}\n\n${llmResponse.summary}`,
|
|
134
|
+
});
|
|
135
|
+
// Update the community with summary and embedding
|
|
136
|
+
await this.communityRepository.updateSummary({
|
|
137
|
+
communityId: community.id,
|
|
138
|
+
name: llmResponse.title.substring(0, 50),
|
|
139
|
+
summary: llmResponse.summary,
|
|
140
|
+
embedding,
|
|
141
|
+
rating: Math.round(llmResponse.rating),
|
|
142
|
+
});
|
|
143
|
+
this.logger.debug(`Generated summary for community ${community.id}: "${llmResponse.title}" (rating: ${llmResponse.rating})`, "CommunitySummariserService");
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
exports.CommunitySummariserService = CommunitySummariserService;
|
|
147
|
+
exports.CommunitySummariserService = CommunitySummariserService = __decorate([
|
|
148
|
+
(0, common_1.Injectable)(),
|
|
149
|
+
__metadata("design:paramtypes", [llm_service_1.LLMService,
|
|
150
|
+
core_1.EmbedderService,
|
|
151
|
+
community_repository_1.CommunityRepository,
|
|
152
|
+
logging_service_1.AppLoggingService,
|
|
153
|
+
config_1.ConfigService])
|
|
154
|
+
], CommunitySummariserService);
|
|
155
|
+
//# sourceMappingURL=community.summariser.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"community.summariser.service.js","sourceRoot":"","sources":["../../../../src/agents/community.summariser/services/community.summariser.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,6BAAwB;AAExB,wCAAgD;AAChD,wEAAoE;AACpE,oFAAmF;AAEnF,2GAAuG;AAE1F,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BrB,CAAC;AAEF,MAAM,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qEAAqE,CAAC;IACjG,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;IACpF,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,CAAC,2EAA2E,CAAC;CACzF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2DAA2D,CAAC;IAC1F,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;IAC5E,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;IAClF,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;CACzE,CAAC,CAAC;AAGI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG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G,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAA+B;YAC3E,WAAW;YACX,WAAW;YACX,YAAY;YACZ,aAAa,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC;YAClC,WAAW,EAAE,GAAG;SACjB,CAAC,CAAC;QAEH,qCAAqC;QACrC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;YACzD,IAAI,EAAE,GAAG,WAAW,CAAC,KAAK,OAAO,WAAW,CAAC,OAAO,EAAE;SACvD,CAAC,CAAC;QAEH,kDAAkD;QAClD,MAAM,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC;YAC3C,WAAW,EAAE,SAAS,CAAC,EAAE;YACzB,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;YACxC,OAAO,EAAE,WAAW,CAAC,OAAO;YAC5B,SAAS;YACT,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;SACvC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,mCAAmC,SAAS,CAAC,EAAE,MAAM,WAAW,CAAC,KAAK,cAAc,WAAW,CAAC,MAAM,GAAG,EACzG,4BAA4B,CAC7B,CAAC;IACJ,CAAC;CACF,CAAA;AA5GY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;qCAKoB,wBAAU;QACL,sBAAe;QACX,0CAAmB;QAChC,mCAAiB;QACV,sBAAa;GARpC,0BAA0B,CA4GtC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Community } from "../../../foundations/community/entities/community.entity";
|
|
2
|
+
export interface FollowUpAnswer {
|
|
3
|
+
question: string;
|
|
4
|
+
answer: string;
|
|
5
|
+
depth: number;
|
|
6
|
+
additionalQuestions: string[];
|
|
7
|
+
shouldContinue: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const DriftContext: import("@langchain/langgraph").AnnotationRoot<{
|
|
10
|
+
question: {
|
|
11
|
+
(): import("@langchain/langgraph").LastValue<string>;
|
|
12
|
+
(annotation: import("@langchain/langgraph").SingleReducer<string, string>): import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
13
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
14
|
+
};
|
|
15
|
+
topK: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
16
|
+
maxDepth: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
17
|
+
nextStep: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
18
|
+
hops: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
19
|
+
hypotheticalAnswer: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
20
|
+
hydeEmbedding: import("@langchain/langgraph").BinaryOperatorAggregate<number[], number[]>;
|
|
21
|
+
matchedCommunities: import("@langchain/langgraph").BinaryOperatorAggregate<Community[], Community[]>;
|
|
22
|
+
communitySummaries: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
23
|
+
initialAnswer: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
24
|
+
followUpQuestions: import("@langchain/langgraph").BinaryOperatorAggregate<string[], string[]>;
|
|
25
|
+
confidence: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
26
|
+
currentFollowUpIndex: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
27
|
+
currentDepth: import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
28
|
+
followUpAnswers: import("@langchain/langgraph").BinaryOperatorAggregate<FollowUpAnswer[], FollowUpAnswer[]>;
|
|
29
|
+
priorContext: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
30
|
+
finalAnswer: import("@langchain/langgraph").BinaryOperatorAggregate<string, string>;
|
|
31
|
+
tokens: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/langgraph").StateType<{
|
|
32
|
+
input: {
|
|
33
|
+
(): import("@langchain/langgraph").LastValue<number>;
|
|
34
|
+
(annotation: import("@langchain/langgraph").SingleReducer<number, number>): import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
35
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
36
|
+
};
|
|
37
|
+
output: {
|
|
38
|
+
(): import("@langchain/langgraph").LastValue<number>;
|
|
39
|
+
(annotation: import("@langchain/langgraph").SingleReducer<number, number>): import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
40
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
41
|
+
};
|
|
42
|
+
}>, import("@langchain/langgraph").StateType<{
|
|
43
|
+
input: {
|
|
44
|
+
(): import("@langchain/langgraph").LastValue<number>;
|
|
45
|
+
(annotation: import("@langchain/langgraph").SingleReducer<number, number>): import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
46
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
47
|
+
};
|
|
48
|
+
output: {
|
|
49
|
+
(): import("@langchain/langgraph").LastValue<number>;
|
|
50
|
+
(annotation: import("@langchain/langgraph").SingleReducer<number, number>): import("@langchain/langgraph").BinaryOperatorAggregate<number, number>;
|
|
51
|
+
Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
|
|
52
|
+
};
|
|
53
|
+
}>>;
|
|
54
|
+
}>;
|
|
55
|
+
export type DriftContextState = typeof DriftContext.State;
|
|
56
|
+
//# sourceMappingURL=drift.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.context.d.ts","sourceRoot":"","sources":["../../../../src/agents/drift/contexts/drift.context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,0DAA0D,CAAC;AAErF,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2FvB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,OAAO,YAAY,CAAC,KAAK,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DriftContext = void 0;
|
|
4
|
+
const langgraph_1 = require("@langchain/langgraph");
|
|
5
|
+
exports.DriftContext = langgraph_1.Annotation.Root({
|
|
6
|
+
// Input
|
|
7
|
+
question: (langgraph_1.Annotation),
|
|
8
|
+
topK: (0, langgraph_1.Annotation)({
|
|
9
|
+
default: () => 5,
|
|
10
|
+
reducer: (current, update) => update ?? current,
|
|
11
|
+
}),
|
|
12
|
+
maxDepth: (0, langgraph_1.Annotation)({
|
|
13
|
+
default: () => 2,
|
|
14
|
+
reducer: (current, update) => update ?? current,
|
|
15
|
+
}),
|
|
16
|
+
// Workflow control
|
|
17
|
+
nextStep: (0, langgraph_1.Annotation)({
|
|
18
|
+
default: () => "hyde",
|
|
19
|
+
reducer: (current, update) => update || current,
|
|
20
|
+
}),
|
|
21
|
+
hops: (0, langgraph_1.Annotation)({
|
|
22
|
+
default: () => 0,
|
|
23
|
+
reducer: (current, update) => (current ?? 0) + (update ?? 0),
|
|
24
|
+
}),
|
|
25
|
+
// HyDE phase
|
|
26
|
+
hypotheticalAnswer: (0, langgraph_1.Annotation)({
|
|
27
|
+
default: () => "",
|
|
28
|
+
reducer: (current, update) => update || current,
|
|
29
|
+
}),
|
|
30
|
+
hydeEmbedding: (0, langgraph_1.Annotation)({
|
|
31
|
+
default: () => [],
|
|
32
|
+
reducer: (current, update) => (update && update.length > 0 ? update : current),
|
|
33
|
+
}),
|
|
34
|
+
// Community search phase
|
|
35
|
+
matchedCommunities: (0, langgraph_1.Annotation)({
|
|
36
|
+
default: () => [],
|
|
37
|
+
reducer: (current, update) => (update && update.length > 0 ? update : current),
|
|
38
|
+
}),
|
|
39
|
+
communitySummaries: (0, langgraph_1.Annotation)({
|
|
40
|
+
default: () => "",
|
|
41
|
+
reducer: (current, update) => update || current,
|
|
42
|
+
}),
|
|
43
|
+
// Primer answer phase
|
|
44
|
+
initialAnswer: (0, langgraph_1.Annotation)({
|
|
45
|
+
default: () => "",
|
|
46
|
+
reducer: (current, update) => update || current,
|
|
47
|
+
}),
|
|
48
|
+
followUpQuestions: (0, langgraph_1.Annotation)({
|
|
49
|
+
default: () => [],
|
|
50
|
+
reducer: (current, update) => (update && update.length > 0 ? update : current),
|
|
51
|
+
}),
|
|
52
|
+
confidence: (0, langgraph_1.Annotation)({
|
|
53
|
+
default: () => 0,
|
|
54
|
+
reducer: (current, update) => update ?? current,
|
|
55
|
+
}),
|
|
56
|
+
// Follow-up phase
|
|
57
|
+
currentFollowUpIndex: (0, langgraph_1.Annotation)({
|
|
58
|
+
default: () => 0,
|
|
59
|
+
reducer: (current, update) => update ?? current,
|
|
60
|
+
}),
|
|
61
|
+
currentDepth: (0, langgraph_1.Annotation)({
|
|
62
|
+
default: () => 0,
|
|
63
|
+
reducer: (current, update) => update ?? current,
|
|
64
|
+
}),
|
|
65
|
+
followUpAnswers: (0, langgraph_1.Annotation)({
|
|
66
|
+
default: () => [],
|
|
67
|
+
reducer: (current, update) => [...(current ?? []), ...(update ?? [])],
|
|
68
|
+
}),
|
|
69
|
+
priorContext: (0, langgraph_1.Annotation)({
|
|
70
|
+
default: () => "",
|
|
71
|
+
reducer: (current, update) => update || current,
|
|
72
|
+
}),
|
|
73
|
+
// Synthesis phase
|
|
74
|
+
finalAnswer: (0, langgraph_1.Annotation)({
|
|
75
|
+
default: () => "",
|
|
76
|
+
reducer: (current, update) => update || current,
|
|
77
|
+
}),
|
|
78
|
+
// Token tracking
|
|
79
|
+
tokens: (0, langgraph_1.Annotation)({
|
|
80
|
+
default: () => ({ input: 0, output: 0 }),
|
|
81
|
+
reducer: (current, update) => {
|
|
82
|
+
if (!update)
|
|
83
|
+
return current;
|
|
84
|
+
return {
|
|
85
|
+
input: (current?.input || 0) + (update?.input || 0),
|
|
86
|
+
output: (current?.output || 0) + (update?.output || 0),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=drift.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.context.js","sourceRoot":"","sources":["../../../../src/agents/drift/contexts/drift.context.ts"],"names":[],"mappings":";;;AAAA,oDAAkD;AAYrC,QAAA,YAAY,GAAG,sBAAU,CAAC,IAAI,CAAC;IAC1C,QAAQ;IACR,QAAQ,EAAE,CAAA,sBAAkB,CAAA;IAC5B,IAAI,EAAE,IAAA,sBAAU,EAAS;QACvB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QAChB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,OAAO;KAChD,CAAC;IACF,QAAQ,EAAE,IAAA,sBAAU,EAAS;QAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;QAChB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,OAAO;KAChD,CAAC;IAEF,mBAAmB;IACnB,QAAQ,EAAE,IAAA,sBAAU,EAAS;QAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM;QACrB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,I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CAAC,MAAM,IAAI,OAAO;KAChD,CAAC;IAEF,kBAAkB;IAClB,WAAW,EAAE,IAAA,sBAAU,EAAS;QAC9B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;QACjB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,OAAO;KAChD,CAAC;IAEF,iBAAiB;IACjB,MAAM,EAAE,IAAA,sBAAU,EAAiC;QACjD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACxC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3B,IAAI,CAAC,MAAM;gBAAE,OAAO,OAAO,CAAC;YAC5B,OAAO;gBACL,KAAK,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,CAAC;gBACnD,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC;aACvD,CAAC;QACJ,CAAC;KACF,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.module.d.ts","sourceRoot":"","sources":["../../../src/agents/drift/drift.module.ts"],"names":[],"mappings":"AAeA,qBAea,WAAW;CAAG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DriftModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const llm_module_1 = require("../../core/llm/llm.module");
|
|
12
|
+
const logging_module_1 = require("../../core/logging/logging.module");
|
|
13
|
+
const tracing_module_1 = require("../../core/tracing/tracing.module");
|
|
14
|
+
const company_module_1 = require("../../foundations/company/company.module");
|
|
15
|
+
const community_module_1 = require("../../foundations/community/community.module");
|
|
16
|
+
const community_detector_module_1 = require("../community.detector/community.detector.module");
|
|
17
|
+
const community_search_node_service_1 = require("./nodes/community.search.node.service");
|
|
18
|
+
const followup_node_service_1 = require("./nodes/followup.node.service");
|
|
19
|
+
const hyde_node_service_1 = require("./nodes/hyde.node.service");
|
|
20
|
+
const primer_answer_node_service_1 = require("./nodes/primer.answer.node.service");
|
|
21
|
+
const synthesis_node_service_1 = require("./nodes/synthesis.node.service");
|
|
22
|
+
const drift_migration_service_1 = require("./services/drift.migration.service");
|
|
23
|
+
const drift_search_service_1 = require("./services/drift.search.service");
|
|
24
|
+
let DriftModule = class DriftModule {
|
|
25
|
+
};
|
|
26
|
+
exports.DriftModule = DriftModule;
|
|
27
|
+
exports.DriftModule = DriftModule = __decorate([
|
|
28
|
+
(0, common_1.Module)({
|
|
29
|
+
imports: [llm_module_1.LLMModule, logging_module_1.LoggingModule, tracing_module_1.TracingModule, community_module_1.CommunityModule, company_module_1.CompanyModule, community_detector_module_1.CommunityDetectorModule],
|
|
30
|
+
providers: [
|
|
31
|
+
// Node services
|
|
32
|
+
hyde_node_service_1.HydeNodeService,
|
|
33
|
+
community_search_node_service_1.CommunitySearchNodeService,
|
|
34
|
+
primer_answer_node_service_1.PrimerAnswerNodeService,
|
|
35
|
+
followup_node_service_1.FollowUpNodeService,
|
|
36
|
+
synthesis_node_service_1.SynthesisNodeService,
|
|
37
|
+
// Main services
|
|
38
|
+
drift_search_service_1.DriftSearchService,
|
|
39
|
+
drift_migration_service_1.DriftMigrationService,
|
|
40
|
+
],
|
|
41
|
+
exports: [drift_search_service_1.DriftSearchService, drift_migration_service_1.DriftMigrationService],
|
|
42
|
+
})
|
|
43
|
+
], DriftModule);
|
|
44
|
+
//# sourceMappingURL=drift.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.module.js","sourceRoot":"","sources":["../../../src/agents/drift/drift.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,0DAAsD;AACtD,sEAAkE;AAClE,sEAAkE;AAClE,6EAAyE;AACzE,mFAA+E;AAC/E,+FAA0F;AAC1F,yFAAmF;AACnF,yEAAoE;AACpE,iEAA4D;AAC5D,mFAA6E;AAC7E,2EAAsE;AACtE,gFAA2E;AAC3E,0EAAqE;AAiB9D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAfvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,sBAAS,EAAE,8BAAa,EAAE,8BAAa,EAAE,kCAAe,EAAE,8BAAa,EAAE,mDAAuB,CAAC;QAC3G,SAAS,EAAE;YACT,gBAAgB;YAChB,mCAAe;YACf,0DAA0B;YAC1B,oDAAuB;YACvB,2CAAmB;YACnB,6CAAoB;YACpB,gBAAgB;YAChB,yCAAkB;YAClB,+CAAqB;SACtB;QACD,OAAO,EAAE,CAAC,yCAAkB,EAAE,+CAAqB,CAAC;KACrD,CAAC;GACW,WAAW,CAAG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AppLoggingService } from "../../../core/logging/services/logging.service";
|
|
2
|
+
import { CommunityRepository } from "../../../foundations/community/repositories/community.repository";
|
|
3
|
+
import { DriftContext, DriftContextState } from "../contexts/drift.context";
|
|
4
|
+
export declare class CommunitySearchNodeService {
|
|
5
|
+
private readonly communityRepository;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
constructor(communityRepository: CommunityRepository, logger: AppLoggingService);
|
|
8
|
+
execute(params: {
|
|
9
|
+
state: typeof DriftContext.State;
|
|
10
|
+
}): Promise<Partial<DriftContextState>>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=community.search.node.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"community.search.node.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/drift/nodes/community.search.node.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE5E,qBACa,0BAA0B;IAEnC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,iBAAiB;IAGtC,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,YAAY,CAAC,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAqCjG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CommunitySearchNodeService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const logging_service_1 = require("../../../core/logging/services/logging.service");
|
|
15
|
+
const community_repository_1 = require("../../../foundations/community/repositories/community.repository");
|
|
16
|
+
let CommunitySearchNodeService = class CommunitySearchNodeService {
|
|
17
|
+
constructor(communityRepository, logger) {
|
|
18
|
+
this.communityRepository = communityRepository;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
}
|
|
21
|
+
async execute(params) {
|
|
22
|
+
this.logger.debug(`Community Search Node: searching with topK=${params.state.topK}`, "CommunitySearchNodeService");
|
|
23
|
+
// Vector search against community summaries using HyDE embedding
|
|
24
|
+
const matchedCommunities = await this.communityRepository.findByVector({
|
|
25
|
+
embedding: params.state.hydeEmbedding,
|
|
26
|
+
topK: params.state.topK,
|
|
27
|
+
});
|
|
28
|
+
this.logger.debug(`Community Search Node: found ${matchedCommunities.length} communities`, "CommunitySearchNodeService");
|
|
29
|
+
if (matchedCommunities.length === 0) {
|
|
30
|
+
return {
|
|
31
|
+
hops: 1,
|
|
32
|
+
matchedCommunities: [],
|
|
33
|
+
communitySummaries: "",
|
|
34
|
+
nextStep: "synthesis", // Skip to synthesis if no communities found
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// Format community summaries for LLM consumption
|
|
38
|
+
const communitySummaries = matchedCommunities
|
|
39
|
+
.map((c, i) => {
|
|
40
|
+
return `### Community ${i + 1}: ${c.name}\nLevel: ${c.level} | Members: ${c.memberCount} | Rating: ${c.rating}\n\n${c.summary}`;
|
|
41
|
+
})
|
|
42
|
+
.join("\n\n---\n\n");
|
|
43
|
+
return {
|
|
44
|
+
hops: 1,
|
|
45
|
+
matchedCommunities,
|
|
46
|
+
communitySummaries,
|
|
47
|
+
nextStep: "primer_answer",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.CommunitySearchNodeService = CommunitySearchNodeService;
|
|
52
|
+
exports.CommunitySearchNodeService = CommunitySearchNodeService = __decorate([
|
|
53
|
+
(0, common_1.Injectable)(),
|
|
54
|
+
__metadata("design:paramtypes", [community_repository_1.CommunityRepository,
|
|
55
|
+
logging_service_1.AppLoggingService])
|
|
56
|
+
], CommunitySearchNodeService);
|
|
57
|
+
//# sourceMappingURL=community.search.node.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"community.search.node.service.js","sourceRoot":"","sources":["../../../../src/agents/drift/nodes/community.search.node.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,oFAAmF;AACnF,2GAAuG;AAIhG,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YACmB,mBAAwC,EACxC,MAAyB;QADzB,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,WAAM,GAAN,MAAM,CAAmB;IACzC,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,MAA4C;QACxD,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8CAA8C,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EACjE,4BAA4B,CAC7B,CAAC;QAEF,iEAAiE;QACjE,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC;YACrE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa;YACrC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI;SACxB,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,kBAAkB,CAAC,MAAM,cAAc,EAAE,4BAA4B,CAAC,CAAC;QAEzH,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,OAAO;gBACL,IAAI,EAAE,CAAC;gBACP,kBAAkB,EAAE,EAAE;gBACtB,kBAAkB,EAAE,EAAE;gBACtB,QAAQ,EAAE,WAAW,EAAE,4CAA4C;aACpE,CAAC;QACJ,CAAC;QAED,iDAAiD;QACjD,MAAM,kBAAkB,GAAG,kBAAkB;aAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACZ,OAAO,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,WAAW,cAAc,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;QAClI,CAAC,CAAC;aACD,IAAI,CAAC,aAAa,CAAC,CAAC;QAEvB,OAAO;YACL,IAAI,EAAE,CAAC;YACP,kBAAkB;YAClB,kBAAkB;YAClB,QAAQ,EAAE,eAAe;SAC1B,CAAC;IACJ,CAAC;CACF,CAAA;AA3CY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,mBAAU,GAAE;qCAG6B,0CAAmB;QAChC,mCAAiB;GAHjC,0BAA0B,CA2CtC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConfigService } from "@nestjs/config";
|
|
2
|
+
import { BaseConfigInterface } from "../../../config/interfaces";
|
|
3
|
+
import { LLMService } from "../../../core/llm/services/llm.service";
|
|
4
|
+
import { AppLoggingService } from "../../../core/logging/services/logging.service";
|
|
5
|
+
import { CommunityRepository } from "../../../foundations/community/repositories/community.repository";
|
|
6
|
+
import { DriftContext, DriftContextState } from "../contexts/drift.context";
|
|
7
|
+
export declare const defaultFollowupPrompt = "\nYou are a knowledge analyst conducting a detailed investigation.\n\n## Your Task\n\nGiven a follow-up question and community context, provide:\n1. A detailed answer to the specific question\n2. Additional follow-up questions if the investigation should continue\n\n## Guidelines\n\n- Focus on answering the specific follow-up question\n- Use entity details and relationships from the community members\n- Be specific and cite relevant entities when possible\n- Only suggest more follow-up questions if there are clear gaps to explore\n\n## Output\n\nProvide:\n- **answer**: Detailed answer to the follow-up question (100-300 words)\n- **additionalQuestions**: 0-2 additional questions if further investigation is needed\n- **shouldContinue**: Whether the investigation should continue (true if important gaps remain)\n";
|
|
8
|
+
export declare class FollowUpNodeService {
|
|
9
|
+
private readonly llmService;
|
|
10
|
+
private readonly communityRepository;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
private readonly configService;
|
|
13
|
+
private readonly systemPrompt;
|
|
14
|
+
private readonly maxQuestionsPerStep;
|
|
15
|
+
constructor(llmService: LLMService, communityRepository: CommunityRepository, logger: AppLoggingService, configService: ConfigService<BaseConfigInterface>);
|
|
16
|
+
execute(params: {
|
|
17
|
+
state: typeof DriftContext.State;
|
|
18
|
+
}): Promise<Partial<DriftContextState>>;
|
|
19
|
+
/**
|
|
20
|
+
* Collect additional questions from follow-up answers that should continue
|
|
21
|
+
*/
|
|
22
|
+
private collectAdditionalQuestions;
|
|
23
|
+
/**
|
|
24
|
+
* Gather detailed information about communities for local search
|
|
25
|
+
*/
|
|
26
|
+
private gatherCommunityDetails;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=followup.node.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"followup.node.service.d.ts","sourceRoot":"","sources":["../../../../src/agents/drift/nodes/followup.node.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kEAAkE,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAkB,MAAM,2BAA2B,CAAC;AAE5F,eAAO,MAAM,qBAAqB,yzBAsBjC,CAAC;AAeF,qBACa,mBAAmB;IAK5B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAPhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAK;gBAGtB,UAAU,EAAE,UAAU,EACtB,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAAC;IAM9D,OAAO,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,YAAY,CAAC,KAAK,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IA+EhG;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;OAEG;YACW,sBAAsB;CA+BrC"}
|