Skip to content

Commit

Permalink
feature: add type + groupSearch as options to public page config
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev committed Nov 14, 2024
1 parent 4ba4aea commit cd13e5e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
2 changes: 2 additions & 0 deletions clients/search-component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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..." |
Expand Down
4 changes: 4 additions & 0 deletions clients/ts-sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -11434,6 +11434,10 @@
],
"nullable": true
},
"type": {
"type": "string",
"nullable": true
},
"useGroupSearch": {
"type": "boolean",
"nullable": true
Expand Down
1 change: 1 addition & 0 deletions clients/ts-sdk/src/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,7 @@ export type PublicPageParameters = {
searchOptions?: ((PublicPageSearchOptions) | null);
suggestedQueries?: (boolean) | null;
theme?: ((PublicPageTheme) | null);
type?: (string) | null;
useGroupSearch?: (boolean) | null;
};

Expand Down
43 changes: 43 additions & 0 deletions frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
/>
</div>
<div class="flex gap-2">
<div class="flex items-center gap-1">
<label class="block" for="">
Ecommerce Mode
</label>
<Tooltip
tooltipText="Use the component in ecommerce mode"
body={<FaRegularCircleQuestion class="h-3 w-3 text-black" />}
/>
</div>
<input
placeholder="Search..."
checked={extraParams.type === "ecommerce" || false}
type="checkbox"
onChange={(e) => {
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"
/>
</div>
<div class="flex gap-2">
<div class="flex items-center gap-1">
<label class="block" for="">
Use Grouping
</label>
<Tooltip
tooltipText="Use search over groups instead of chunk-level search"
body={<FaRegularCircleQuestion class="h-3 w-3 text-black" />}
/>
</div>
<input
placeholder="Search..."
checked={extraParams.useGroupSearch || true}
type="checkbox"
onChange={(e) => {
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"
/>
</div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions server/src/handlers/page_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ pub struct PublicPageParameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub base_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub r#type: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub api_key: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub analytics: Option<bool>,
Expand Down
5 changes: 4 additions & 1 deletion server/src/public/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<link rel="stylesheet" href="https://unpkg.com/trieve-search-component@0.0.65/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/trieve-search-component@0.1.1/dist/index.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Maven+Pro:[email protected]&amp;display=swap" rel="stylesheet">
Expand Down Expand Up @@ -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 -%}
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit cd13e5e

Please sign in to comment.