From cd13e5e94a1a57ef442251ae72aeb6d85c0181c1 Mon Sep 17 00:00:00 2001 From: skeptrune Date: Thu, 14 Nov 2024 11:37:00 -0800 Subject: [PATCH] feature: add type + groupSearch as options to public page config --- clients/search-component/README.md | 2 + clients/ts-sdk/openapi.json | 4 ++ clients/ts-sdk/src/types.gen.ts | 1 + .../src/pages/dataset/PublicPageSettings.tsx | 43 +++++++++++++++++++ server/src/data/models.rs | 1 + server/src/handlers/page_handler.rs | 2 + server/src/public/page.html | 5 ++- yarn.lock | 7 +-- 8 files changed, 58 insertions(+), 7 deletions(-) diff --git a/clients/search-component/README.md b/clients/search-component/README.md index 3745c9aa3..7ae637c1f 100644 --- a/clients/search-component/README.md +++ b/clients/search-component/README.md @@ -78,6 +78,8 @@ declare module "solid-js" { | datasetId | string | '' | | apiKey | string | '' | | baseUrl | string | "https://api.trieve.ai" | +| type | "docs" | "ecommerce" | "docs" | +| useGroupSearch | boolean | false | | chat | boolean | true | | analytics | boolean | true | | placeholder | string | "Search..." | diff --git a/clients/ts-sdk/openapi.json b/clients/ts-sdk/openapi.json index 6ee04b653..8dca178a9 100644 --- a/clients/ts-sdk/openapi.json +++ b/clients/ts-sdk/openapi.json @@ -11434,6 +11434,10 @@ ], "nullable": true }, + "type": { + "type": "string", + "nullable": true + }, "useGroupSearch": { "type": "boolean", "nullable": true diff --git a/clients/ts-sdk/src/types.gen.ts b/clients/ts-sdk/src/types.gen.ts index 47adf7994..7546322b8 100644 --- a/clients/ts-sdk/src/types.gen.ts +++ b/clients/ts-sdk/src/types.gen.ts @@ -1820,6 +1820,7 @@ export type PublicPageParameters = { searchOptions?: ((PublicPageSearchOptions) | null); suggestedQueries?: (boolean) | null; theme?: ((PublicPageTheme) | null); + type?: (string) | null; useGroupSearch?: (boolean) | null; }; diff --git a/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx b/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx index 8c598ff01..81ba34f99 100644 --- a/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx +++ b/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx @@ -357,6 +357,49 @@ export const PublicPageSettings = () => { class="block w-4 rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6" /> +
+
+ + } + /> +
+ { + setExtraParams( + "type", + e.currentTarget.checked ? "ecommerce" : "docs", + ); + }} + class="block w-4 rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6" + /> +
+
+
+ + } + /> +
+ { + setExtraParams("useGroupSearch", e.currentTarget.checked); + }} + class="block w-4 rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6" + /> +
diff --git a/server/src/data/models.rs b/server/src/data/models.rs index 1156b795f..869c6947c 100644 --- a/server/src/data/models.rs +++ b/server/src/data/models.rs @@ -2720,6 +2720,7 @@ impl DatasetConfigurationDTO { base_url: page_parameters_self .base_url .or(page_parameters_curr.base_url), + r#type: page_parameters_self.r#type.or(page_parameters_curr.r#type), api_key: page_parameters_self .api_key .or(page_parameters_curr.api_key), diff --git a/server/src/handlers/page_handler.rs b/server/src/handlers/page_handler.rs index a51d907c4..2721ef62a 100644 --- a/server/src/handlers/page_handler.rs +++ b/server/src/handlers/page_handler.rs @@ -114,6 +114,8 @@ pub struct PublicPageParameters { #[serde(skip_serializing_if = "Option::is_none")] pub base_url: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub r#type: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub api_key: Option, #[serde(skip_serializing_if = "Option::is_none")] pub analytics: Option, diff --git a/server/src/public/page.html b/server/src/public/page.html index cc94c3b59..e0a53c8f5 100644 --- a/server/src/public/page.html +++ b/server/src/public/page.html @@ -2,7 +2,7 @@ - + @@ -99,6 +99,9 @@ {% if params.baseUrl -%} baseUrl="{{ params.baseUrl }}" {% endif -%} + {% if params.type -%} + type="{{ params.type }}" + {% endif -%} {% if params.suggestedQueries -%} suggestedQueries={{ params.suggestedQueries }} {% endif -%} diff --git a/yarn.lock b/yarn.lock index 34f68fd3f..2335403f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7116,13 +7116,8 @@ totalist@^3.0.0: resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8" integrity sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ== -trieve-ts-sdk@^0.0.28: - version "0.0.28" - resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.28.tgz#e8a943727e36f6ac8ad4ead7c1d4ce5effe1329b" - integrity sha512-vYJRpWSav4wNdhloUpjWhQaPB+2yLKccP3MqbR2HEca02rUc3okomx9cA9yt+42g6ueYqJ0oomRUYR6mVBAnfw== - "trieve-ts-sdk@file:clients/ts-sdk": - version "0.0.14" + version "0.0.28" trim-lines@^3.0.0: version "3.0.1"