flowquery 1.0.2 → 1.0.3
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/README.md +54 -1
- package/dist/tokenization/token_mapper.js +2 -2
- package/dist/tokenization/token_mapper.js.map +1 -1
- package/misc/apps/RAG/README.md +48 -0
- package/misc/apps/RAG/package.json +31 -0
- package/misc/apps/RAG/src/index.ts +20 -0
- package/misc/apps/RAG/tsconfig.json +19 -0
- package/misc/apps/RAG/webpack.config.js +32 -0
- package/misc/apps/README.md +1 -0
- package/package.json +1 -1
- package/src/tokenization/token_mapper.ts +2 -2
- /package/{queries → misc/queries}/analyze_catfacts.cql +0 -0
- /package/{queries → misc/queries}/azure_openai_completions.cql +0 -0
- /package/{queries → misc/queries}/azure_openai_models.cql +0 -0
- /package/{queries → misc/queries}/mock_pipeline.cql +0 -0
- /package/{queries → misc/queries}/openai_completions.cql +0 -0
- /package/{queries → misc/queries}/openai_models.cql +0 -0
- /package/{queries → misc/queries}/test.cql +0 -0
- /package/{queries → misc/queries}/tool_inference.cql +0 -0
- /package/{queries → misc/queries}/wisdom.cql +0 -0
- /package/{queries → misc/queries}/wisdom_letter_histogram.cql +0 -0
package/README.md
CHANGED
|
@@ -18,8 +18,61 @@ FlowQuery is written in TypeScript (https://www.typescriptlang.org/) and built/c
|
|
|
18
18
|
- This will run all unit tests.
|
|
19
19
|
- Build: ```npm run build``` (builds for both Node and web)
|
|
20
20
|
|
|
21
|
+
## Installation & Usage
|
|
22
|
+
|
|
23
|
+
### Node.js
|
|
24
|
+
|
|
25
|
+
Install FlowQuery from npm:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install flowquery
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then use it in your code:
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const FlowQuery = require('flowquery').default;
|
|
35
|
+
// Or with ES modules:
|
|
36
|
+
// import FlowQuery from 'flowquery';
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
const query = new FlowQuery('WITH 1 AS x RETURN x + 1');
|
|
40
|
+
await query.run();
|
|
41
|
+
console.log(query.results); // [ { expr0: 2 } ]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Browser
|
|
48
|
+
|
|
49
|
+
Include the minified bundle in your HTML:
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<script src="https://microsoft.github.io/FlowQuery/flowquery.min.js"></script>
|
|
53
|
+
<script>
|
|
54
|
+
async function main() {
|
|
55
|
+
const query = new FlowQuery('WITH 1 AS x RETURN x + 1');
|
|
56
|
+
await query.run();
|
|
57
|
+
console.log(query.results); // [ { expr0: 2 } ]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
main();
|
|
61
|
+
</script>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Or import from the browser-specific entry point:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
import FlowQuery from 'flowquery/browser';
|
|
68
|
+
|
|
69
|
+
const query = new FlowQuery('WITH "Hello" AS greeting RETURN greeting');
|
|
70
|
+
await query.run();
|
|
71
|
+
console.log(query.results);
|
|
72
|
+
```
|
|
73
|
+
|
|
21
74
|
## Examples
|
|
22
|
-
See also
|
|
75
|
+
See also ./misc/queries and ./tests/compute/runner.test.ts for more examples.
|
|
23
76
|
```cypher
|
|
24
77
|
/*
|
|
25
78
|
Collect 10 random pieces of wisdom and create a letter histogram.
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const token_1 = __importDefault(require("
|
|
7
|
-
const trie_1 = __importDefault(require("
|
|
6
|
+
const token_1 = __importDefault(require("./token"));
|
|
7
|
+
const trie_1 = __importDefault(require("./trie"));
|
|
8
8
|
/**
|
|
9
9
|
* Maps string values to tokens using a Trie for efficient lookup.
|
|
10
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token_mapper.js","sourceRoot":"","sources":["../../src/tokenization/token_mapper.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"token_mapper.js","sourceRoot":"","sources":["../../src/tokenization/token_mapper.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,kDAA0B;AAE1B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW;IAGb;;;;OAIG;IACH,YAAoB,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;QAPzC,UAAK,GAAS,IAAI,cAAI,EAAE,CAAC;QAQ7B,KAAI,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAsB,eAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACnD,IAAG,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,KAAa;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;IACjC,CAAC;CACJ;AAED,kBAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# RAG FlowQuery App
|
|
2
|
+
|
|
3
|
+
A RAG (Retrieval Augmented Generation) loop based on [FlowQuery](https://www.npmjs.com/package/flowquery).
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js 18+
|
|
8
|
+
- npm
|
|
9
|
+
|
|
10
|
+
## Getting Started
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# Install dependencies
|
|
14
|
+
npm install
|
|
15
|
+
|
|
16
|
+
# Run in development mode (with ts-node)
|
|
17
|
+
npm run dev
|
|
18
|
+
|
|
19
|
+
# Or build and run
|
|
20
|
+
npm run build
|
|
21
|
+
npm start
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Available Scripts
|
|
25
|
+
|
|
26
|
+
| Script | Description |
|
|
27
|
+
|--------|-------------|
|
|
28
|
+
| `npm run dev` | Run directly with ts-node (for development) |
|
|
29
|
+
| `npm run build` | Compile TypeScript to `dist/` |
|
|
30
|
+
| `npm start` | Run the compiled JavaScript |
|
|
31
|
+
| `npm run build:bundle` | Create a webpack bundle |
|
|
32
|
+
| `npm run watch` | Watch mode for TypeScript compilation |
|
|
33
|
+
|
|
34
|
+
## Project Structure
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
RAG/
|
|
38
|
+
├── src/
|
|
39
|
+
│ └── index.ts # Main entry point
|
|
40
|
+
├── dist/ # Compiled output (generated)
|
|
41
|
+
├── package.json
|
|
42
|
+
├── tsconfig.json
|
|
43
|
+
└── webpack.config.js
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
MIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rag-flowquery",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A RAG (Retrieval Augmented Generation) loop based on FlowQuery.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node dist/index.js",
|
|
8
|
+
"dev": "ts-node src/index.ts",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"build:bundle": "webpack",
|
|
11
|
+
"watch": "tsc --watch"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"rag",
|
|
15
|
+
"flowquery",
|
|
16
|
+
"retrieval-augmented-generation"
|
|
17
|
+
],
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"flowquery": "^1.0.2"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^22.0.0",
|
|
25
|
+
"ts-loader": "^9.5.1",
|
|
26
|
+
"ts-node": "^10.9.2",
|
|
27
|
+
"typescript": "^5.7.2",
|
|
28
|
+
"webpack": "^5.97.1",
|
|
29
|
+
"webpack-cli": "^6.0.1"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { run } from 'flowquery';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* RAG (Retrieval Augmented Generation) loop using FlowQuery.
|
|
5
|
+
*
|
|
6
|
+
* This is a starter template - customize it for your RAG implementation.
|
|
7
|
+
*/
|
|
8
|
+
async function main() {
|
|
9
|
+
// Example: Run a simple FlowQuery query
|
|
10
|
+
const query = `return 1`;
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
const result = await run(query);
|
|
14
|
+
console.log('Result:', result);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.error('Error running query:', error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist",
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"target": "ES2020",
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"resolveJsonModule": true,
|
|
15
|
+
"types": ["node"]
|
|
16
|
+
},
|
|
17
|
+
"include": ["src/**/*"],
|
|
18
|
+
"exclude": ["node_modules", "dist"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './src/index.ts',
|
|
6
|
+
target: 'node',
|
|
7
|
+
output: {
|
|
8
|
+
filename: 'rag.bundle.js',
|
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
|
10
|
+
libraryTarget: 'commonjs2'
|
|
11
|
+
},
|
|
12
|
+
resolve: {
|
|
13
|
+
extensions: ['.ts', '.js']
|
|
14
|
+
},
|
|
15
|
+
module: {
|
|
16
|
+
rules: [
|
|
17
|
+
{
|
|
18
|
+
test: /\.ts$/,
|
|
19
|
+
use: 'ts-loader',
|
|
20
|
+
exclude: /node_modules/
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
externals: {
|
|
25
|
+
// Add any externals here if needed
|
|
26
|
+
// For example, if you want to exclude flowquery from the bundle:
|
|
27
|
+
// 'flowquery': 'commonjs flowquery'
|
|
28
|
+
},
|
|
29
|
+
optimization: {
|
|
30
|
+
minimize: true
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Example apps using FlowQuery.
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|