diff --git a/builder/partnerproduct/src/config.yaml b/builder/partnerproduct/src/config.yaml
index 637dc3a0..68c1a469 100644
--- a/builder/partnerproduct/src/config.yaml
+++ b/builder/partnerproduct/src/config.yaml
@@ -14,6 +14,7 @@ vector_store:
numCandidates: 150
minScore: 0.1
vectorSearchIndexName: 'vector_index'
+ textSearchIndexName: 'text_index'
llms:
class_name: Fireworks
model_name: 'accounts/fireworks/models/mixtral-8x22b-instruct'
diff --git a/builder/partnerproduct/src/loader.ts b/builder/partnerproduct/src/loader.ts
index 67f77371..23a5f46f 100644
--- a/builder/partnerproduct/src/loader.ts
+++ b/builder/partnerproduct/src/loader.ts
@@ -26,10 +26,11 @@ try {
chunksAdded += chunks.entriesAdded;
});
}
-
+
if (chunksAdded > 0) {
console.log(`\n Total documents added : ${chunksAdded} `)
await llmApplication.createVectorIndex();
+ await llmApplication.createTextIndex();
}
else {
console.log("\n-- Data not inserted, please retry --")
diff --git a/builder/partnerproduct/src/semantic-search.ts b/builder/partnerproduct/src/semantic-search.ts
index d95659f3..c6fb2ca2 100644
--- a/builder/partnerproduct/src/semantic-search.ts
+++ b/builder/partnerproduct/src/semantic-search.ts
@@ -14,7 +14,7 @@ const app = express();
const port = 9001;
app.use(express.json());
-app.use(cors());
+app.use(cors());
const llmApplication = await new RAGApplicationBuilder()
.setModel(getModelClass())
@@ -42,6 +42,30 @@ app.get('/semantic-search', async (req: Request, res: Response) => {
}
});
+app.get('/hybrid-search', async (req: Request, res: Response) => {
+ try {
+ const userQuery = asString(req.query.query);
+ const vectorWeight = asFloat(req.query.vectorWeight ?? 0.5);
+ const fullTextWeight = asFloat(req.query.fullTextWeight ?? 0.5);
+
+ if (!userQuery) {
+ return res.status(400).send('Query is required');
+ }
+
+ llmApplication.hybridQuery(userQuery, vectorWeight, fullTextWeight).then((result) => {
+ console.log('Result:', result);
+ res.send(result);
+ });
+
+ } catch (error) {
+ console.error('Error during hybrid vector search:', error);
+ res.status(500).send('An error occurred while processing your request.');
+ }
+});
+
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
-});
\ No newline at end of file
+});
+
+function asString(value: any): string { return typeof value !== 'undefined' ? value.toString() : ''; }
+function asFloat(value: any): number { return typeof value !== 'undefined' ? parseFloat(value.toString()) || 0 : 0; }
diff --git a/builder/partnerproduct/ui/package-lock.json b/builder/partnerproduct/ui/package-lock.json
index 0ffff7fe..ec5e6f74 100644
--- a/builder/partnerproduct/ui/package-lock.json
+++ b/builder/partnerproduct/ui/package-lock.json
@@ -11,6 +11,7 @@
"@leafygreen-ui/card": "^11.0.0",
"@leafygreen-ui/icon": "^12.6.0",
"@leafygreen-ui/loading-indicator": "^2.0.12",
+ "@leafygreen-ui/number-input": "^2.2.1",
"@leafygreen-ui/search-input": "^3.1.2",
"@leafygreen-ui/side-nav": "^14.1.3",
"@leafygreen-ui/tabs": "^13.0.1",
@@ -3892,9 +3893,10 @@
}
},
"node_modules/@leafygreen-ui/form-field": {
- "version": "1.2.3",
- "resolved": "https://registry.npmjs.org/@leafygreen-ui/form-field/-/form-field-1.2.3.tgz",
- "integrity": "sha512-LW2fM9oFgoQH8V4ZrWcrVlo6phNhULy7i5MTQDiHi+HvAkJQl67R2DWl2QuXgBNgkOkgrDM5ccb/J7fD37VO4A==",
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/form-field/-/form-field-1.2.5.tgz",
+ "integrity": "sha512-XH7vJZbgn6wnS7Wv0DpNqcL8q0qPqxHsrVBnqk+iKlnGjCjo1GFzngjOIHODUymEfWRJERrxKO6z8FsSof0GsQ==",
+ "license": "Apache-2.0",
"dependencies": {
"@leafygreen-ui/emotion": "^4.0.8",
"@leafygreen-ui/hooks": "^8.1.3",
@@ -4160,6 +4162,58 @@
"@leafygreen-ui/leafygreen-provider": "^3.1.12"
}
},
+ "node_modules/@leafygreen-ui/number-input": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/number-input/-/number-input-2.2.1.tgz",
+ "integrity": "sha512-hfJW3llFkz06PR9QzzJataT+OqRYYOFztZOA4hKZYiRpU6GkybFD/1Rr428KVuY5URP5gZLzAoLn5nNNwq5LTA==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@leafygreen-ui/a11y": "^1.4.13",
+ "@leafygreen-ui/button": "^21.2.0",
+ "@leafygreen-ui/emotion": "^4.0.8",
+ "@leafygreen-ui/form-field": "^1.2.4",
+ "@leafygreen-ui/hooks": "^8.1.3",
+ "@leafygreen-ui/icon": "^12.5.0",
+ "@leafygreen-ui/lib": "^13.5.0",
+ "@leafygreen-ui/palette": "^4.0.9",
+ "@leafygreen-ui/popover": "^11.4.0",
+ "@leafygreen-ui/select": "^12.1.4",
+ "@leafygreen-ui/tokens": "^2.8.0",
+ "@leafygreen-ui/tooltip": "^11.1.0",
+ "@leafygreen-ui/typography": "^19.1.0",
+ "lodash": "^4.17.21"
+ },
+ "peerDependencies": {
+ "@leafygreen-ui/leafygreen-provider": "^3.1.12"
+ }
+ },
+ "node_modules/@leafygreen-ui/number-input/node_modules/@leafygreen-ui/polymorphic": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/polymorphic/-/polymorphic-2.0.2.tgz",
+ "integrity": "sha512-OjP+hPG/cwADShcGa1SZdm51G2wVpbNqpU0B3GonEAvGLcAvG4LDMXa7BWo3GDliNkPtVMS86w0eZzEDmLfKmQ==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@leafygreen-ui/lib": "^13.6.0",
+ "lodash": "^4.17.21"
+ }
+ },
+ "node_modules/@leafygreen-ui/number-input/node_modules/@leafygreen-ui/typography": {
+ "version": "19.3.0",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/typography/-/typography-19.3.0.tgz",
+ "integrity": "sha512-pgTRcc4usW/S9nDDzkf5Ac/JPEybhWtOnDpmrp99mAJHM6tH48Pd1HjRNHWjn6bnh0nXWjwANXX1ZEe+8ggCNg==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@leafygreen-ui/emotion": "^4.0.8",
+ "@leafygreen-ui/icon": "^12.6.0",
+ "@leafygreen-ui/lib": "^13.6.1",
+ "@leafygreen-ui/palette": "^4.0.10",
+ "@leafygreen-ui/polymorphic": "^2.0.0",
+ "@leafygreen-ui/tokens": "^2.9.0"
+ },
+ "peerDependencies": {
+ "@leafygreen-ui/leafygreen-provider": "^3.1.12"
+ }
+ },
"node_modules/@leafygreen-ui/palette": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@leafygreen-ui/palette/-/palette-4.1.1.tgz",
@@ -4279,21 +4333,22 @@
}
},
"node_modules/@leafygreen-ui/select": {
- "version": "12.1.0",
- "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-12.1.0.tgz",
- "integrity": "sha512-4NaDvlYWciwg83snMwKrmUx9mvUrGzucqGRAIShsH9M4R21Bvdy2sXMWcjX/w8tZCwT500Jk6xWJll9op2Yx9w==",
+ "version": "12.1.4",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-12.1.4.tgz",
+ "integrity": "sha512-FUb2y2UbytstILK11jOLCIH8am2rF8e/8QAoZ6D1SNgEgmOnOyn0krP8aM7B7P2YNy/oMKFYFwFIU/zsbG3g8w==",
+ "license": "Apache-2.0",
"dependencies": {
"@leafygreen-ui/button": "^21.2.0",
"@leafygreen-ui/emotion": "^4.0.8",
- "@leafygreen-ui/form-field": "^1.2.0",
+ "@leafygreen-ui/form-field": "^1.2.4",
"@leafygreen-ui/hooks": "^8.1.3",
- "@leafygreen-ui/icon": "^12.5.0",
- "@leafygreen-ui/input-option": "^1.1.3",
- "@leafygreen-ui/lib": "^13.5.0",
+ "@leafygreen-ui/icon": "^12.5.4",
+ "@leafygreen-ui/input-option": "^2.0.1",
+ "@leafygreen-ui/lib": "^13.6.1",
"@leafygreen-ui/palette": "^4.0.10",
"@leafygreen-ui/popover": "^11.4.0",
- "@leafygreen-ui/tokens": "^2.8.0",
- "@leafygreen-ui/typography": "^19.1.0",
+ "@leafygreen-ui/tokens": "^2.9.0",
+ "@leafygreen-ui/typography": "^19.2.1",
"@lg-tools/test-harnesses": "^0.1.2",
"@types/react-is": "^18.0.0",
"lodash": "^4.17.21",
@@ -4304,17 +4359,46 @@
"@leafygreen-ui/leafygreen-provider": "^3.1.12"
}
},
+ "node_modules/@leafygreen-ui/select/node_modules/@leafygreen-ui/input-option": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/input-option/-/input-option-2.0.2.tgz",
+ "integrity": "sha512-GD3TX/5uF6NMdlcOt89jg7NXrN43ZAm+TEg/84NT9Mpdik9pw44Nznhv/BD/jXaWpxPXlDQzq7ReAOi7WtUujg==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@leafygreen-ui/a11y": "^1.5.0",
+ "@leafygreen-ui/emotion": "^4.0.8",
+ "@leafygreen-ui/lib": "^13.6.1",
+ "@leafygreen-ui/palette": "^4.0.9",
+ "@leafygreen-ui/polymorphic": "^2.0.0",
+ "@leafygreen-ui/tokens": "^2.9.0",
+ "@leafygreen-ui/typography": "^19.2.1"
+ },
+ "peerDependencies": {
+ "@leafygreen-ui/leafygreen-provider": "^3.1.12"
+ }
+ },
+ "node_modules/@leafygreen-ui/select/node_modules/@leafygreen-ui/polymorphic": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/polymorphic/-/polymorphic-2.0.2.tgz",
+ "integrity": "sha512-OjP+hPG/cwADShcGa1SZdm51G2wVpbNqpU0B3GonEAvGLcAvG4LDMXa7BWo3GDliNkPtVMS86w0eZzEDmLfKmQ==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@leafygreen-ui/lib": "^13.6.0",
+ "lodash": "^4.17.21"
+ }
+ },
"node_modules/@leafygreen-ui/select/node_modules/@leafygreen-ui/typography": {
- "version": "19.1.2",
- "resolved": "https://registry.npmjs.org/@leafygreen-ui/typography/-/typography-19.1.2.tgz",
- "integrity": "sha512-Fd5NJWrH5yaUSylqDlh+j53AxWmbng1lbjXtCpJ6l6YS4YBgnhjGH3+wGh3XjPxhsiSQv9/eyMNZ1BIgH5V11w==",
+ "version": "19.3.0",
+ "resolved": "https://registry.npmjs.org/@leafygreen-ui/typography/-/typography-19.3.0.tgz",
+ "integrity": "sha512-pgTRcc4usW/S9nDDzkf5Ac/JPEybhWtOnDpmrp99mAJHM6tH48Pd1HjRNHWjn6bnh0nXWjwANXX1ZEe+8ggCNg==",
+ "license": "Apache-2.0",
"dependencies": {
"@leafygreen-ui/emotion": "^4.0.8",
- "@leafygreen-ui/icon": "^12.5.2",
- "@leafygreen-ui/lib": "^13.4.0",
+ "@leafygreen-ui/icon": "^12.6.0",
+ "@leafygreen-ui/lib": "^13.6.1",
"@leafygreen-ui/palette": "^4.0.10",
- "@leafygreen-ui/polymorphic": "^1.3.7",
- "@leafygreen-ui/tokens": "^2.7.0"
+ "@leafygreen-ui/polymorphic": "^2.0.0",
+ "@leafygreen-ui/tokens": "^2.9.0"
},
"peerDependencies": {
"@leafygreen-ui/leafygreen-provider": "^3.1.12"
@@ -20540,6 +20624,20 @@
"is-typedarray": "^1.0.0"
}
},
+ "node_modules/typescript": {
+ "version": "4.9.5",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
+ "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
+ "license": "Apache-2.0",
+ "peer": true,
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=4.2.0"
+ }
+ },
"node_modules/unbox-primitive": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz",
diff --git a/builder/partnerproduct/ui/package.json b/builder/partnerproduct/ui/package.json
index ed383c09..d23e5b28 100644
--- a/builder/partnerproduct/ui/package.json
+++ b/builder/partnerproduct/ui/package.json
@@ -6,6 +6,7 @@
"@leafygreen-ui/card": "^11.0.0",
"@leafygreen-ui/icon": "^12.6.0",
"@leafygreen-ui/loading-indicator": "^2.0.12",
+ "@leafygreen-ui/number-input": "^2.2.1",
"@leafygreen-ui/search-input": "^3.1.2",
"@leafygreen-ui/side-nav": "^14.1.3",
"@leafygreen-ui/tabs": "^13.0.1",
diff --git a/builder/partnerproduct/ui/src/App.js b/builder/partnerproduct/ui/src/App.js
index 00e5b76e..6d3adb5f 100644
--- a/builder/partnerproduct/ui/src/App.js
+++ b/builder/partnerproduct/ui/src/App.js
@@ -49,6 +49,11 @@ function App() {
Vector Search
+
+
Text Score: {item.fts_score}, Vector Score: {item.vs_score}}
Content: {item.pageContent}