cogniscrape 1.0.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/LICENSE +21 -0
- package/README.md +308 -0
- package/dist/graphs/AbstractGraph.d.ts +27 -0
- package/dist/graphs/AbstractGraph.d.ts.map +1 -0
- package/dist/graphs/AbstractGraph.js +44 -0
- package/dist/graphs/AbstractGraph.js.map +1 -0
- package/dist/graphs/BaseGraph.d.ts +30 -0
- package/dist/graphs/BaseGraph.d.ts.map +1 -0
- package/dist/graphs/BaseGraph.js +62 -0
- package/dist/graphs/BaseGraph.js.map +1 -0
- package/dist/graphs/CSVScraperGraph.d.ts +16 -0
- package/dist/graphs/CSVScraperGraph.d.ts.map +1 -0
- package/dist/graphs/CSVScraperGraph.js +84 -0
- package/dist/graphs/CSVScraperGraph.js.map +1 -0
- package/dist/graphs/DepthSearchGraph.d.ts +14 -0
- package/dist/graphs/DepthSearchGraph.d.ts.map +1 -0
- package/dist/graphs/DepthSearchGraph.js +45 -0
- package/dist/graphs/DepthSearchGraph.js.map +1 -0
- package/dist/graphs/JSONScraperGraph.d.ts +18 -0
- package/dist/graphs/JSONScraperGraph.d.ts.map +1 -0
- package/dist/graphs/JSONScraperGraph.js +100 -0
- package/dist/graphs/JSONScraperGraph.js.map +1 -0
- package/dist/graphs/SearchGraph.d.ts +14 -0
- package/dist/graphs/SearchGraph.d.ts.map +1 -0
- package/dist/graphs/SearchGraph.js +42 -0
- package/dist/graphs/SearchGraph.js.map +1 -0
- package/dist/graphs/SmartScraperGraph.d.ts +16 -0
- package/dist/graphs/SmartScraperGraph.d.ts.map +1 -0
- package/dist/graphs/SmartScraperGraph.js +57 -0
- package/dist/graphs/SmartScraperGraph.js.map +1 -0
- package/dist/graphs/SmartScraperMultiGraph.d.ts +17 -0
- package/dist/graphs/SmartScraperMultiGraph.d.ts.map +1 -0
- package/dist/graphs/SmartScraperMultiGraph.js +71 -0
- package/dist/graphs/SmartScraperMultiGraph.js.map +1 -0
- package/dist/graphs/index.d.ts +12 -0
- package/dist/graphs/index.d.ts.map +1 -0
- package/dist/graphs/index.js +23 -0
- package/dist/graphs/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/models/GeminiModel.d.ts +16 -0
- package/dist/models/GeminiModel.d.ts.map +1 -0
- package/dist/models/GeminiModel.js +127 -0
- package/dist/models/GeminiModel.js.map +1 -0
- package/dist/models/OllamaModel.d.ts +15 -0
- package/dist/models/OllamaModel.d.ts.map +1 -0
- package/dist/models/OllamaModel.js +134 -0
- package/dist/models/OllamaModel.js.map +1 -0
- package/dist/models/index.d.ts +8 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +24 -0
- package/dist/models/index.js.map +1 -0
- package/dist/nodes/BaseNode.d.ts +37 -0
- package/dist/nodes/BaseNode.d.ts.map +1 -0
- package/dist/nodes/BaseNode.js +116 -0
- package/dist/nodes/BaseNode.js.map +1 -0
- package/dist/nodes/CSVExporterNode.d.ts +16 -0
- package/dist/nodes/CSVExporterNode.d.ts.map +1 -0
- package/dist/nodes/CSVExporterNode.js +85 -0
- package/dist/nodes/CSVExporterNode.js.map +1 -0
- package/dist/nodes/ConditionalNode.d.ts +16 -0
- package/dist/nodes/ConditionalNode.d.ts.map +1 -0
- package/dist/nodes/ConditionalNode.js +68 -0
- package/dist/nodes/ConditionalNode.js.map +1 -0
- package/dist/nodes/FetchNode.d.ts +15 -0
- package/dist/nodes/FetchNode.d.ts.map +1 -0
- package/dist/nodes/FetchNode.js +182 -0
- package/dist/nodes/FetchNode.js.map +1 -0
- package/dist/nodes/GenerateAnswerNode.d.ts +14 -0
- package/dist/nodes/GenerateAnswerNode.d.ts.map +1 -0
- package/dist/nodes/GenerateAnswerNode.js +86 -0
- package/dist/nodes/GenerateAnswerNode.js.map +1 -0
- package/dist/nodes/JSONExporterNode.d.ts +16 -0
- package/dist/nodes/JSONExporterNode.d.ts.map +1 -0
- package/dist/nodes/JSONExporterNode.js +42 -0
- package/dist/nodes/JSONExporterNode.js.map +1 -0
- package/dist/nodes/MergeNode.d.ts +10 -0
- package/dist/nodes/MergeNode.d.ts.map +1 -0
- package/dist/nodes/MergeNode.js +51 -0
- package/dist/nodes/MergeNode.js.map +1 -0
- package/dist/nodes/PDFScraperNode.d.ts +10 -0
- package/dist/nodes/PDFScraperNode.d.ts.map +1 -0
- package/dist/nodes/PDFScraperNode.js +80 -0
- package/dist/nodes/PDFScraperNode.js.map +1 -0
- package/dist/nodes/ParseNode.d.ts +12 -0
- package/dist/nodes/ParseNode.d.ts.map +1 -0
- package/dist/nodes/ParseNode.js +44 -0
- package/dist/nodes/ParseNode.js.map +1 -0
- package/dist/nodes/RAGNode.d.ts +13 -0
- package/dist/nodes/RAGNode.d.ts.map +1 -0
- package/dist/nodes/RAGNode.js +64 -0
- package/dist/nodes/RAGNode.js.map +1 -0
- package/dist/nodes/ReasoningNode.d.ts +10 -0
- package/dist/nodes/ReasoningNode.d.ts.map +1 -0
- package/dist/nodes/ReasoningNode.js +51 -0
- package/dist/nodes/ReasoningNode.js.map +1 -0
- package/dist/nodes/SearchNode.d.ts +13 -0
- package/dist/nodes/SearchNode.d.ts.map +1 -0
- package/dist/nodes/SearchNode.js +81 -0
- package/dist/nodes/SearchNode.js.map +1 -0
- package/dist/nodes/XMLScraperNode.d.ts +11 -0
- package/dist/nodes/XMLScraperNode.d.ts.map +1 -0
- package/dist/nodes/XMLScraperNode.js +99 -0
- package/dist/nodes/XMLScraperNode.js.map +1 -0
- package/dist/nodes/index.d.ts +17 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +33 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/prompts/index.d.ts +12 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +117 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/cache.d.ts +28 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +72 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/chunking.d.ts +8 -0
- package/dist/utils/chunking.d.ts.map +1 -0
- package/dist/utils/chunking.js +51 -0
- package/dist/utils/chunking.js.map +1 -0
- package/dist/utils/cleanupHtml.d.ts +7 -0
- package/dist/utils/cleanupHtml.d.ts.map +1 -0
- package/dist/utils/cleanupHtml.js +81 -0
- package/dist/utils/cleanupHtml.js.map +1 -0
- package/dist/utils/convertToMarkdown.d.ts +6 -0
- package/dist/utils/convertToMarkdown.d.ts.map +1 -0
- package/dist/utils/convertToMarkdown.js +61 -0
- package/dist/utils/convertToMarkdown.js.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +40 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/proxy.d.ts +30 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +62 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/rateLimiter.d.ts +24 -0
- package/dist/utils/rateLimiter.d.ts.map +1 -0
- package/dist/utils/rateLimiter.js +61 -0
- package/dist/utils/rateLimiter.js.map +1 -0
- package/dist/utils/retry.d.ts +17 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +43 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/schemaValidator.d.ts +69 -0
- package/dist/utils/schemaValidator.d.ts.map +1 -0
- package/dist/utils/schemaValidator.js +133 -0
- package/dist/utils/schemaValidator.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DepthSearchGraph - Search the internet, scrape results, and perform deep analysis
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DepthSearchGraph = void 0;
|
|
7
|
+
const SearchNode_1 = require("../nodes/SearchNode");
|
|
8
|
+
const FetchNode_1 = require("../nodes/FetchNode");
|
|
9
|
+
const ParseNode_1 = require("../nodes/ParseNode");
|
|
10
|
+
const RAGNode_1 = require("../nodes/RAGNode");
|
|
11
|
+
const ReasoningNode_1 = require("../nodes/ReasoningNode");
|
|
12
|
+
const GenerateAnswerNode_1 = require("../nodes/GenerateAnswerNode");
|
|
13
|
+
const logger_1 = require("../utils/logger");
|
|
14
|
+
class DepthSearchGraph {
|
|
15
|
+
constructor(prompt, config, llmModel) {
|
|
16
|
+
this.prompt = prompt;
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.llmModel = llmModel;
|
|
19
|
+
this.logger = new logger_1.Logger('DepthSearchGraph', config.verbose ?? false);
|
|
20
|
+
}
|
|
21
|
+
async run() {
|
|
22
|
+
this.logger.info('Starting DepthSearchGraph execution');
|
|
23
|
+
this.logger.info(`Deep search query: ${this.prompt}`);
|
|
24
|
+
let state = {
|
|
25
|
+
userPrompt: this.prompt,
|
|
26
|
+
};
|
|
27
|
+
// Create and execute nodes in sequence
|
|
28
|
+
const searchNode = new SearchNode_1.SearchNode('userPrompt', ['searchResults'], this.config);
|
|
29
|
+
state = await searchNode.execute(state);
|
|
30
|
+
const fetchNode = new FetchNode_1.FetchNode('searchResults', ['doc'], this.config);
|
|
31
|
+
state = await fetchNode.execute(state);
|
|
32
|
+
const parseNode = new ParseNode_1.ParseNode('doc', ['parsedDoc'], this.config);
|
|
33
|
+
state = await parseNode.execute(state);
|
|
34
|
+
const ragNode = new RAGNode_1.RAGNode('userPrompt & parsedDoc', ['relevantChunks'], this.config);
|
|
35
|
+
state = await ragNode.execute(state);
|
|
36
|
+
const reasoningNode = new ReasoningNode_1.ReasoningNode('userPrompt & relevantChunks', ['reasoning'], { ...this.config, llmModel: this.llmModel });
|
|
37
|
+
state = await reasoningNode.execute(state);
|
|
38
|
+
const generateNode = new GenerateAnswerNode_1.GenerateAnswerNode('userPrompt & reasoning & relevantChunks', ['answer'], { ...this.config, llmModel: this.llmModel });
|
|
39
|
+
state = await generateNode.execute(state);
|
|
40
|
+
this.logger.success('DepthSearchGraph execution completed');
|
|
41
|
+
return state;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.DepthSearchGraph = DepthSearchGraph;
|
|
45
|
+
//# sourceMappingURL=DepthSearchGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DepthSearchGraph.js","sourceRoot":"","sources":["../../src/graphs/DepthSearchGraph.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,oDAAiD;AACjD,kDAA+C;AAC/C,kDAA+C;AAC/C,8CAA2C;AAC3C,0DAAuD;AACvD,oEAAiE;AACjE,4CAAyC;AAEzC,MAAa,gBAAgB;IAM3B,YACE,MAAc,EACd,MAAqB,EACrB,QAAiB;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAEtD,IAAI,KAAK,GAAe;YACtB,UAAU,EAAE,IAAI,CAAC,MAAM;SACxB,CAAC;QAEF,uCAAuC;QACvC,MAAM,UAAU,G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,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxDD,4CAwDC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSONScraperGraph - Scrape data and export to JSON
|
|
3
|
+
*/
|
|
4
|
+
import { BaseLLM, GraphState, ScraperConfig } from '../types';
|
|
5
|
+
import { Logger } from '../utils/logger';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
export declare class JSONScraperGraph {
|
|
8
|
+
protected prompt: string;
|
|
9
|
+
protected source: string;
|
|
10
|
+
protected config: ScraperConfig;
|
|
11
|
+
protected llmModel: BaseLLM;
|
|
12
|
+
protected logger: Logger;
|
|
13
|
+
protected outputPath?: string;
|
|
14
|
+
protected schema?: z.ZodType<any>;
|
|
15
|
+
constructor(prompt: string, source: string, config: ScraperConfig, llmModel: BaseLLM, outputPath?: string, schema?: z.ZodType<any>);
|
|
16
|
+
run(): Promise<GraphState>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=JSONScraperGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONScraperGraph.d.ts","sourceRoot":"","sources":["../../src/graphs/JSONScraperGraph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAK9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,gBAAgB;IAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAGhC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,OAAO,EACjB,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAWnB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;CA2DjC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* JSONScraperGraph - Scrape data and export to JSON
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.JSONScraperGraph = void 0;
|
|
40
|
+
const FetchNode_1 = require("../nodes/FetchNode");
|
|
41
|
+
const ParseNode_1 = require("../nodes/ParseNode");
|
|
42
|
+
const GenerateAnswerNode_1 = require("../nodes/GenerateAnswerNode");
|
|
43
|
+
const JSONExporterNode_1 = require("../nodes/JSONExporterNode");
|
|
44
|
+
const logger_1 = require("../utils/logger");
|
|
45
|
+
const schemaValidator_1 = require("../utils/schemaValidator");
|
|
46
|
+
class JSONScraperGraph {
|
|
47
|
+
constructor(prompt, source, config, llmModel, outputPath, schema) {
|
|
48
|
+
this.prompt = prompt;
|
|
49
|
+
this.source = source;
|
|
50
|
+
this.config = config;
|
|
51
|
+
this.llmModel = llmModel;
|
|
52
|
+
this.outputPath = outputPath;
|
|
53
|
+
this.schema = schema;
|
|
54
|
+
this.logger = new logger_1.Logger('JSONScraperGraph', config.verbose ?? false);
|
|
55
|
+
}
|
|
56
|
+
async run() {
|
|
57
|
+
this.logger.info('Starting JSONScraperGraph execution');
|
|
58
|
+
this.logger.info(`Scraping: ${this.source}`);
|
|
59
|
+
let state = {
|
|
60
|
+
url: this.source,
|
|
61
|
+
userPrompt: this.prompt,
|
|
62
|
+
schema: this.schema,
|
|
63
|
+
};
|
|
64
|
+
// Fetch content
|
|
65
|
+
const fetchNode = new FetchNode_1.FetchNode('url', ['doc'], this.config);
|
|
66
|
+
state = await fetchNode.execute(state);
|
|
67
|
+
// Parse content
|
|
68
|
+
const parseNode = new ParseNode_1.ParseNode('doc', ['parsedDoc'], this.config);
|
|
69
|
+
state = await parseNode.execute(state);
|
|
70
|
+
// Generate answer
|
|
71
|
+
const generateNode = new GenerateAnswerNode_1.GenerateAnswerNode('userPrompt & parsedDoc', ['answer'], { ...this.config, llmModel: this.llmModel, schema: this.schema });
|
|
72
|
+
state = await generateNode.execute(state);
|
|
73
|
+
// Validate with schema if provided
|
|
74
|
+
if (this.schema) {
|
|
75
|
+
this.logger.info('Validating output against schema');
|
|
76
|
+
const validation = schemaValidator_1.SchemaValidator.validate(this.schema, state.answer);
|
|
77
|
+
if (validation.success) {
|
|
78
|
+
this.logger.success('Schema validation passed');
|
|
79
|
+
state.validatedAnswer = validation.data;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.logger.warn(`Schema validation failed: ${validation.error}`);
|
|
83
|
+
this.logger.warn('Proceeding with unvalidated data');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Export to JSON
|
|
87
|
+
const jsonExporter = new JSONExporterNode_1.JSONExporterNode('answer', ['json'], { ...this.config, outputPath: this.outputPath });
|
|
88
|
+
state = await jsonExporter.execute(state);
|
|
89
|
+
this.logger.success('JSONScraperGraph execution completed');
|
|
90
|
+
// Save to file if path provided
|
|
91
|
+
if (this.outputPath && state.json) {
|
|
92
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
93
|
+
fs.writeFileSync(this.outputPath, state.json, 'utf-8');
|
|
94
|
+
this.logger.success(`JSON saved to: ${this.outputPath}`);
|
|
95
|
+
}
|
|
96
|
+
return state;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.JSONScraperGraph = JSONScraperGraph;
|
|
100
|
+
//# sourceMappingURL=JSONScraperGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONScraperGraph.js","sourceRoot":"","sources":["../../src/graphs/JSONScraperGraph.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;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C,CAAC;QAE5D,gCAAgC;QAChC,IAAI,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAClC,MAAM,EAAE,GAAG,wDAAa,IAAI,GAAC,CAAC;YAC9B,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArFD,4CAqFC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchGraph - Search the internet and scrape relevant results
|
|
3
|
+
*/
|
|
4
|
+
import { BaseLLM, GraphState, ScraperConfig } from '../types';
|
|
5
|
+
import { Logger } from '../utils/logger';
|
|
6
|
+
export declare class SearchGraph {
|
|
7
|
+
protected prompt: string;
|
|
8
|
+
protected config: ScraperConfig;
|
|
9
|
+
protected llmModel: BaseLLM;
|
|
10
|
+
protected logger: Logger;
|
|
11
|
+
constructor(prompt: string, config: ScraperConfig, llmModel: BaseLLM);
|
|
12
|
+
run(): Promise<GraphState>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=SearchGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchGraph.d.ts","sourceRoot":"","sources":["../../src/graphs/SearchGraph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAM9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,qBAAa,WAAW;IACtB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,OAAO;IAQb,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;CAgCjC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SearchGraph - Search the internet and scrape relevant results
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SearchGraph = void 0;
|
|
7
|
+
const SearchNode_1 = require("../nodes/SearchNode");
|
|
8
|
+
const FetchNode_1 = require("../nodes/FetchNode");
|
|
9
|
+
const ParseNode_1 = require("../nodes/ParseNode");
|
|
10
|
+
const RAGNode_1 = require("../nodes/RAGNode");
|
|
11
|
+
const GenerateAnswerNode_1 = require("../nodes/GenerateAnswerNode");
|
|
12
|
+
const logger_1 = require("../utils/logger");
|
|
13
|
+
class SearchGraph {
|
|
14
|
+
constructor(prompt, config, llmModel) {
|
|
15
|
+
this.prompt = prompt;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.llmModel = llmModel;
|
|
18
|
+
this.logger = new logger_1.Logger('SearchGraph', config.verbose ?? false);
|
|
19
|
+
}
|
|
20
|
+
async run() {
|
|
21
|
+
this.logger.info('Starting SearchGraph execution');
|
|
22
|
+
this.logger.info(`Search query: ${this.prompt}`);
|
|
23
|
+
let state = {
|
|
24
|
+
userPrompt: this.prompt,
|
|
25
|
+
};
|
|
26
|
+
// Create and execute nodes in sequence
|
|
27
|
+
const searchNode = new SearchNode_1.SearchNode('userPrompt', ['searchResults'], this.config);
|
|
28
|
+
state = await searchNode.execute(state);
|
|
29
|
+
const fetchNode = new FetchNode_1.FetchNode('searchResults', ['doc'], this.config);
|
|
30
|
+
state = await fetchNode.execute(state);
|
|
31
|
+
const parseNode = new ParseNode_1.ParseNode('doc', ['parsedDoc'], this.config);
|
|
32
|
+
state = await parseNode.execute(state);
|
|
33
|
+
const ragNode = new RAGNode_1.RAGNode('userPrompt & parsedDoc', ['relevantChunks'], this.config);
|
|
34
|
+
state = await ragNode.execute(state);
|
|
35
|
+
const generateNode = new GenerateAnswerNode_1.GenerateAnswerNode('userPrompt & relevantChunks', ['answer'], { ...this.config, llmModel: this.llmModel });
|
|
36
|
+
state = await generateNode.execute(state);
|
|
37
|
+
this.logger.success('SearchGraph execution completed');
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SearchGraph = SearchGraph;
|
|
42
|
+
//# sourceMappingURL=SearchGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchGraph.js","sourceRoot":"","sources":["../../src/graphs/SearchGraph.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,oDAAiD;AACjD,kDAA+C;AAC/C,kDAA+C;AAC/C,8CAA2C;AAC3C,oEAAiE;AACjE,4CAAyC;AAEzC,MAAa,WAAW;IAMtB,YACE,MAAc,EACd,MAAqB,EACrB,QAAiB;QAEjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAEjD,IAAI,KAAK,GAAe;YACtB,UAAU,EAAE,IAAI,CAAC,MAAM;SACxB,CAAC;QAEF,uCAAuC;QACvC,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,YAAY,EAAE,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAChF,KAAK,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAExC,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvE,KAAK,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACnE,KAAK,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,wBAAwB,EAAE,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvF,KAAK,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAErC,MAAM,YAAY,GAAG,IAAI,uCAAkB,CACzC,6BAA6B,EAC7B,CAAC,QAAQ,CAAC,EACV,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5C,CAAC;QACF,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;QAEvD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAjDD,kCAiDC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartScraperGraph - Main scraping graph implementation
|
|
3
|
+
*/
|
|
4
|
+
import { AbstractGraph } from './AbstractGraph';
|
|
5
|
+
import { BaseGraph } from './BaseGraph';
|
|
6
|
+
import { ScraperConfig } from '../types';
|
|
7
|
+
export declare class SmartScraperGraph extends AbstractGraph {
|
|
8
|
+
constructor(options: {
|
|
9
|
+
prompt: string;
|
|
10
|
+
source: string;
|
|
11
|
+
config: ScraperConfig;
|
|
12
|
+
schema?: any;
|
|
13
|
+
});
|
|
14
|
+
protected createGraph(): BaseGraph;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=SmartScraperGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartScraperGraph.d.ts","sourceRoot":"","sources":["../../src/graphs/SmartScraperGraph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,EAAE;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,aAAa,CAAC;QACtB,MAAM,CAAC,EAAE,GAAG,CAAC;KACd;IAID,SAAS,CAAC,WAAW,IAAI,SAAS;CA0DnC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SmartScraperGraph - Main scraping graph implementation
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SmartScraperGraph = void 0;
|
|
7
|
+
const AbstractGraph_1 = require("./AbstractGraph");
|
|
8
|
+
const BaseGraph_1 = require("./BaseGraph");
|
|
9
|
+
const nodes_1 = require("../nodes");
|
|
10
|
+
class SmartScraperGraph extends AbstractGraph_1.AbstractGraph {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super(options.prompt, options.config, options.source, options.schema);
|
|
13
|
+
}
|
|
14
|
+
createGraph() {
|
|
15
|
+
this.logger.info('Creating SmartScraper graph');
|
|
16
|
+
// Create nodes
|
|
17
|
+
const fetchNode = new nodes_1.FetchNode('url | localDir', ['doc'], {
|
|
18
|
+
llmModel: this.llmModel,
|
|
19
|
+
verbose: this.verbose,
|
|
20
|
+
headless: this.config.headless ?? true,
|
|
21
|
+
timeout: this.config.timeout ?? 30000,
|
|
22
|
+
cut: this.config.cut ?? true,
|
|
23
|
+
loaderKwargs: this.config.loaderKwargs,
|
|
24
|
+
});
|
|
25
|
+
const parseNode = new nodes_1.ParseNode('doc', ['parsedDoc'], {
|
|
26
|
+
llmModel: this.llmModel,
|
|
27
|
+
verbose: this.verbose,
|
|
28
|
+
chunkSize: this.modelToken,
|
|
29
|
+
});
|
|
30
|
+
const generateAnswerNode = new nodes_1.GenerateAnswerNode('userPrompt & (relevantChunks | parsedDoc | doc)', ['answer'], {
|
|
31
|
+
llmModel: this.llmModel,
|
|
32
|
+
verbose: this.verbose,
|
|
33
|
+
additionalInfo: this.config.additionalInfo,
|
|
34
|
+
schema: this.schema,
|
|
35
|
+
});
|
|
36
|
+
// Define graph based on configuration
|
|
37
|
+
if (this.config.htmlMode === false) {
|
|
38
|
+
// With parsing
|
|
39
|
+
const nodes = [fetchNode, parseNode, generateAnswerNode];
|
|
40
|
+
const edges = [
|
|
41
|
+
[fetchNode, parseNode],
|
|
42
|
+
[parseNode, generateAnswerNode],
|
|
43
|
+
];
|
|
44
|
+
return new BaseGraph_1.BaseGraph(nodes, edges, fetchNode, this.verbose);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// HTML mode - skip parsing
|
|
48
|
+
const nodes = [fetchNode, generateAnswerNode];
|
|
49
|
+
const edges = [
|
|
50
|
+
[fetchNode, generateAnswerNode],
|
|
51
|
+
];
|
|
52
|
+
return new BaseGraph_1.BaseGraph(nodes, edges, fetchNode, this.verbose);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.SmartScraperGraph = SmartScraperGraph;
|
|
57
|
+
//# sourceMappingURL=Sm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YACrB,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;YAC1C,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CACF,CAAC;QAEF,sCAAsC;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;YACnC,eAAe;YACf,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,kBAAkB,CAAC,CAAC;YACzD,MAAM,KAAK,GAAiB;gBAC1B,CAAC,SAAS,EAAE,SAAS,CAAC;gBACtB,CAAC,SAAS,EAAE,kBAAkB,CAAC;aAChC,CAAC;YAEF,OAAO,IAAI,qBAAS,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,2BAA2B;YAC3B,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;YAC9C,MAAM,KAAK,GAAiB;gBAC1B,CAAC,SAAS,EAAE,kBAAkB,CAAC;aAChC,CAAC;YAEF,OAAO,IAAI,qBAAS,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF;AApED,8CAoEC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartScraperMultiGraph - Scrape multiple URLs in parallel or sequence
|
|
3
|
+
*/
|
|
4
|
+
import { BaseLLM, GraphState, ScraperConfig } from '../types';
|
|
5
|
+
import { Logger } from '../utils/logger';
|
|
6
|
+
export declare class SmartScraperMultiGraph {
|
|
7
|
+
protected prompt: string;
|
|
8
|
+
protected sources: string[];
|
|
9
|
+
protected config: ScraperConfig;
|
|
10
|
+
protected llmModel: BaseLLM;
|
|
11
|
+
protected logger: Logger;
|
|
12
|
+
protected parallel: boolean;
|
|
13
|
+
constructor(prompt: string, sources: string[], config: ScraperConfig, llmModel: BaseLLM, parallel?: boolean);
|
|
14
|
+
run(): Promise<GraphState>;
|
|
15
|
+
private scrapeSource;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SmartScraperMultiGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartScraperMultiGraph.d.ts","sourceRoot":"","sources":["../../src/graphs/SmartScraperMultiGraph.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAK9D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,qBAAa,sBAAsB;IACjC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAG1B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,OAAO,EACjB,QAAQ,GAAE,OAAe;IAUrB,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;YA0ClB,YAAY;CA4B3B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SmartScraperMultiGraph - Scrape multiple URLs in parallel or sequence
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SmartScraperMultiGraph = void 0;
|
|
7
|
+
const FetchNode_1 = require("../nodes/FetchNode");
|
|
8
|
+
const ParseNode_1 = require("../nodes/ParseNode");
|
|
9
|
+
const GenerateAnswerNode_1 = require("../nodes/GenerateAnswerNode");
|
|
10
|
+
const MergeNode_1 = require("../nodes/MergeNode");
|
|
11
|
+
const logger_1 = require("../utils/logger");
|
|
12
|
+
class SmartScraperMultiGraph {
|
|
13
|
+
constructor(prompt, sources, config, llmModel, parallel = false) {
|
|
14
|
+
this.prompt = prompt;
|
|
15
|
+
this.sources = sources;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.llmModel = llmModel;
|
|
18
|
+
this.parallel = parallel;
|
|
19
|
+
this.logger = new logger_1.Logger('SmartScraperMultiGraph', config.verbose ?? false);
|
|
20
|
+
}
|
|
21
|
+
async run() {
|
|
22
|
+
this.logger.info('Starting SmartScraperMultiGraph execution');
|
|
23
|
+
this.logger.info(`Scraping ${this.sources.length} URLs`);
|
|
24
|
+
let answers = [];
|
|
25
|
+
if (this.parallel) {
|
|
26
|
+
// Parallel execution
|
|
27
|
+
this.logger.info('Executing in parallel mode');
|
|
28
|
+
const promises = this.sources.map(source => this.scrapeSource(source));
|
|
29
|
+
const results = await Promise.all(promises);
|
|
30
|
+
answers = results.map(r => r.answer);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Sequential execution
|
|
34
|
+
this.logger.info('Executing in sequential mode');
|
|
35
|
+
for (const source of this.sources) {
|
|
36
|
+
const result = await this.scrapeSource(source);
|
|
37
|
+
answers.push(result.answer);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Merge all answers
|
|
41
|
+
this.logger.info('Merging results from all sources');
|
|
42
|
+
const mergeState = {
|
|
43
|
+
userPrompt: this.prompt,
|
|
44
|
+
answers,
|
|
45
|
+
};
|
|
46
|
+
const mergeNode = new MergeNode_1.MergeNode('answers', ['answer'], { ...this.config, llmModel: this.llmModel });
|
|
47
|
+
const finalState = await mergeNode.execute(mergeState);
|
|
48
|
+
this.logger.success('SmartScraperMultiGraph execution completed');
|
|
49
|
+
return finalState;
|
|
50
|
+
}
|
|
51
|
+
async scrapeSource(source) {
|
|
52
|
+
this.logger.info(`Scraping: ${source}`);
|
|
53
|
+
let state = {
|
|
54
|
+
url: source,
|
|
55
|
+
userPrompt: this.prompt,
|
|
56
|
+
};
|
|
57
|
+
// Fetch
|
|
58
|
+
const fetchNode = new FetchNode_1.FetchNode('url', ['doc'], this.config);
|
|
59
|
+
state = await fetchNode.execute(state);
|
|
60
|
+
// Parse
|
|
61
|
+
const parseNode = new ParseNode_1.ParseNode('doc', ['parsedDoc'], this.config);
|
|
62
|
+
state = await parseNode.execute(state);
|
|
63
|
+
// Generate answer
|
|
64
|
+
const generateNode = new GenerateAnswerNode_1.GenerateAnswerNode('userPrompt & parsedDoc', ['answer'], { ...this.config, llmModel: this.llmModel });
|
|
65
|
+
state = await generateNode.execute(state);
|
|
66
|
+
this.logger.success(`Completed scraping: ${source}`);
|
|
67
|
+
return state;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.SmartScraperMultiGraph = SmartScraperMultiGraph;
|
|
71
|
+
//# sourceMappingURL=SmartScraperMultiGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmartScraperMultiGraph.js","sourceRoot":"","sources":["../../src/graphs/SmartScraperMultiGraph.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAGH,kDAA+C;AAC/C,kDAA+C;AAC/C,oEAAiE;AACjE,kDAA+C;AAC/C,4CAAyC;AAEzC,MAAa,sBAAsB;IAQjC,YACE,MAAc,EACd,OAAiB,EACjB,MAAqB,EACrB,QAAiB,EACjB,WAAoB,KAAK;QAEzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,eAAM,CAAC,wBAAwB,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,C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1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graphs index
|
|
3
|
+
*/
|
|
4
|
+
export { BaseGraph } from './BaseGraph';
|
|
5
|
+
export { AbstractGraph } from './AbstractGraph';
|
|
6
|
+
export { SmartScraperGraph } from './SmartScraperGraph';
|
|
7
|
+
export { SearchGraph } from './SearchGraph';
|
|
8
|
+
export { DepthSearchGraph } from './DepthSearchGraph';
|
|
9
|
+
export { CSVScraperGraph } from './CSVScraperGraph';
|
|
10
|
+
export { JSONScraperGraph } from './JSONScraperGraph';
|
|
11
|
+
export { SmartScraperMultiGraph } from './SmartScraperMultiGraph';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graphs/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Graphs index
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SmartScraperMultiGraph = exports.JSONScraperGraph = exports.CSVScraperGraph = exports.DepthSearchGraph = exports.SearchGraph = exports.SmartScraperGraph = exports.AbstractGraph = exports.BaseGraph = void 0;
|
|
7
|
+
var BaseGraph_1 = require("./BaseGraph");
|
|
8
|
+
Object.defineProperty(exports, "BaseGraph", { enumerable: true, get: function () { return BaseGraph_1.BaseGraph; } });
|
|
9
|
+
var AbstractGraph_1 = require("./AbstractGraph");
|
|
10
|
+
Object.defineProperty(exports, "AbstractGraph", { enumerable: true, get: function () { return AbstractGraph_1.AbstractGraph; } });
|
|
11
|
+
var SmartScraperGraph_1 = require("./SmartScraperGraph");
|
|
12
|
+
Object.defineProperty(exports, "SmartScraperGraph", { enumerable: true, get: function () { return SmartScraperGraph_1.SmartScraperGraph; } });
|
|
13
|
+
var SearchGraph_1 = require("./SearchGraph");
|
|
14
|
+
Object.defineProperty(exports, "SearchGraph", { enumerable: true, get: function () { return SearchGraph_1.SearchGraph; } });
|
|
15
|
+
var DepthSearchGraph_1 = require("./DepthSearchGraph");
|
|
16
|
+
Object.defineProperty(exports, "DepthSearchGraph", { enumerable: true, get: function () { return DepthSearchGraph_1.DepthSearchGraph; } });
|
|
17
|
+
var CSVScraperGraph_1 = require("./CSVScraperGraph");
|
|
18
|
+
Object.defineProperty(exports, "CSVScraperGraph", { enumerable: true, get: function () { return CSVScraperGraph_1.CSVScraperGraph; } });
|
|
19
|
+
var JSONScraperGraph_1 = require("./JSONScraperGraph");
|
|
20
|
+
Object.defineProperty(exports, "JSONScraperGraph", { enumerable: true, get: function () { return JSONScraperGraph_1.JSONScraperGraph; } });
|
|
21
|
+
var SmartScraperMultiGraph_1 = require("./SmartScraperMultiGraph");
|
|
22
|
+
Object.defineProperty(exports, "SmartScraperMultiGraph", { enumerable: true, get: function () { return SmartScraperMultiGraph_1.SmartScraperMultiGraph; } });
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graphs/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CogniScrape TypeScript - Main exports
|
|
3
|
+
*/
|
|
4
|
+
export { OllamaModel, GeminiModel, createLLM } from './models';
|
|
5
|
+
export { SmartScraperGraph, AbstractGraph, BaseGraph } from './graphs';
|
|
6
|
+
export { BaseNode, FetchNode, ParseNode, GenerateAnswerNode } from './nodes';
|
|
7
|
+
export * from './types';
|
|
8
|
+
export * from './utils';
|
|
9
|
+
export * from './prompts';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG/D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGvE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7E,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CogniScrape TypeScript - Main exports
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.GenerateAnswerNode = exports.ParseNode = exports.FetchNode = exports.BaseNode = exports.BaseGraph = exports.AbstractGraph = exports.SmartScraperGraph = exports.createLLM = exports.GeminiModel = exports.OllamaModel = void 0;
|
|
21
|
+
// Models
|
|
22
|
+
var models_1 = require("./models");
|
|
23
|
+
Object.defineProperty(exports, "OllamaModel", { enumerable: true, get: function () { return models_1.OllamaModel; } });
|
|
24
|
+
Object.defineProperty(exports, "GeminiModel", { enumerable: true, get: function () { return models_1.GeminiModel; } });
|
|
25
|
+
Object.defineProperty(exports, "createLLM", { enumerable: true, get: function () { return models_1.createLLM; } });
|
|
26
|
+
// Graphs
|
|
27
|
+
var graphs_1 = require("./graphs");
|
|
28
|
+
Object.defineProperty(exports, "SmartScraperGraph", { enumerable: true, get: function () { return graphs_1.SmartScraperGraph; } });
|
|
29
|
+
Object.defineProperty(exports, "AbstractGraph", { enumerable: true, get: function () { return graphs_1.AbstractGraph; } });
|
|
30
|
+
Object.defineProperty(exports, "BaseGraph", { enumerable: true, get: function () { return graphs_1.BaseGraph; } });
|
|
31
|
+
// Nodes
|
|
32
|
+
var nodes_1 = require("./nodes");
|
|
33
|
+
Object.defineProperty(exports, "BaseNode", { enumerable: true, get: function () { return nodes_1.BaseNode; } });
|
|
34
|
+
Object.defineProperty(exports, "FetchNode", { enumerable: true, get: function () { return nodes_1.FetchNode; } });
|
|
35
|
+
Object.defineProperty(exports, "ParseNode", { enumerable: true, get: function () { return nodes_1.ParseNode; } });
|
|
36
|
+
Object.defineProperty(exports, "GenerateAnswerNode", { enumerable: true, get: function () { return nodes_1.GenerateAnswerNode; } });
|
|
37
|
+
// Types
|
|
38
|
+
__exportStar(require("./types"), exports);
|
|
39
|
+
// Utils
|
|
40
|
+
__exportStar(require("./utils"), exports);
|
|
41
|
+
// Prompts
|
|
42
|
+
__exportStar(require("./prompts"), exports);
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAEH,SAAS;AACT,mCAA+D;AAAtD,qGAAA,WAAW,OAAA;AAAE,qGAAA,WAAW,OAAA;AAAE,mGAAA,SAAS,OAAA;AAE5C,SAAS;AACT,mCAAuE;AAA9D,2GAAA,iBAAiB,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,mGAAA,SAAS,OAAA;AAEpD,QAAQ;AACR,iCAA6E;AAApE,iGAAA,QAAQ,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,kGAAA,SAAS,OAAA;AAAE,2GAAA,kBAAkB,OAAA;AAE3D,QAAQ;AACR,0CAAwB;AAExB,QAAQ;AACR,0CAAwB;AAExB,UAAU;AACV,4CAA0B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Gemini LLM Model Implementation
|
|
3
|
+
*/
|
|
4
|
+
import { BaseLLM, LLMConfig } from '../types';
|
|
5
|
+
export declare class GeminiModel extends BaseLLM {
|
|
6
|
+
private genAI;
|
|
7
|
+
private modelName;
|
|
8
|
+
constructor(config: LLMConfig);
|
|
9
|
+
generate(prompt: string, systemPrompt?: string): Promise<string>;
|
|
10
|
+
generateJson(prompt: string, systemPrompt?: string): Promise<any>;
|
|
11
|
+
chat(messages: Array<{
|
|
12
|
+
role: string;
|
|
13
|
+
content: string;
|
|
14
|
+
}>): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=GeminiModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeminiModel.d.ts","sourceRoot":"","sources":["../../src/models/GeminiModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAK9C,qBAAa,WAAY,SAAQ,OAAO;IACtC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,SAAS;IAWvB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0ChE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA0DjE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CA2BhF"}
|