Skip to content

Commit

Permalink
feature: make followupQuestions an optional parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdxker committed Jan 6, 2025
1 parent f79377b commit 20e114d
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 23 deletions.
10 changes: 5 additions & 5 deletions clients/search-component/example/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* prettier-ignore-start */

/* eslint-disable */

// @ts-nocheck

// noinspection JSUnusedGlobalSymbols

// This file is auto-generated by TanStack Router
// This file was automatically generated by TanStack Router.
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import { createFileRoute } from '@tanstack/react-router'

Expand All @@ -22,11 +22,13 @@ const IndexLazyImport = createFileRoute('/')()
// Create/Update Routes

const EcommerceRoute = EcommerceImport.update({
id: '/ecommerce',
path: '/ecommerce',
getParentRoute: () => rootRoute,
} as any)

const IndexLazyRoute = IndexLazyImport.update({
id: '/',
path: '/',
getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/index.lazy').then((d) => d.Route))
Expand Down Expand Up @@ -93,8 +95,6 @@ export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()

/* prettier-ignore-end */

/* ROUTE_MANIFEST_START
{
"routes": {
Expand Down
2 changes: 1 addition & 1 deletion clients/search-component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"import": "./dist/vanilla/index.js"
}
},
"version": "0.2.71",
"version": "0.2.73",
"license": "MIT",
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ export const Message = ({
) : (
<LoadingIcon className="loading" />
)}
<FollowupQueries />
<div>
{message.additional
? props.type !== "ecommerce" && (
Expand Down Expand Up @@ -309,6 +308,8 @@ export const Message = ({
</div>
</div>
</div>
{props.followupQuestions &&
<FollowupQueries /> }
</div>
) : null}
</div>
Expand Down
2 changes: 2 additions & 0 deletions clients/search-component/src/utils/hooks/modal-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type ModalProps = {
analytics?: boolean;
ButtonEl?: JSX.ElementType;
suggestedQueries?: boolean;
followupQuestions?: boolean;
defaultSearchQueries?: string[];
defaultAiQuestions?: string[];
brandLogoImgSrcUrl?: string;
Expand Down Expand Up @@ -124,6 +125,7 @@ const defaultProps = {
analytics: true,
chat: true,
suggestedQueries: true,
followupQuestions: true,
trieve: (() => {}) as unknown as TrieveSDK,
openKeyCombination: [{ ctrl: true }, { key: "k", label: "K" }],
type: "docs" as ModalTypes,
Expand Down
31 changes: 26 additions & 5 deletions clients/ts-sdk/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9356,7 +9356,7 @@
"FULLTEXT_ENABLED": true,
"INDEXED_ONLY": false,
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_DEFAULT_MODEL": "gpt-3.5-turbo-1106",
"LLM_DEFAULT_MODEL": "gpt-4o",
"LOCKED": false,
"MAX_LIMIT": 10000,
"MESSAGE_TO_QUERY_PROMPT": "Write a 1-2 sentence semantic search query along the lines of a hypothetical response to: \n\n",
Expand Down Expand Up @@ -9647,7 +9647,7 @@
"FULLTEXT_ENABLED": true,
"INDEXED_ONLY": false,
"LLM_BASE_URL": "https://api.openai.com/v1",
"LLM_DEFAULT_MODEL": "gpt-3.5-turbo-1106",
"LLM_DEFAULT_MODEL": "gpt-4o",
"LOCKED": false,
"MAX_LIMIT": 10000,
"MESSAGE_TO_QUERY_PROMPT": "Write a 1-2 sentence semantic search query along the lines of a hypothetical response to: \n\n",
Expand Down Expand Up @@ -12130,8 +12130,7 @@
],
"properties": {
"query": {
"type": "string",
"description": "Query to embed for the final weighted sum vector."
"$ref": "#/components/schemas/SearchModalities"
},
"weight": {
"type": "number",
Expand Down Expand Up @@ -12518,6 +12517,10 @@
"type": "string",
"nullable": true
},
"followupQuestions": {
"type": "boolean",
"nullable": true
},
"forBrandName": {
"type": "string",
"nullable": true
Expand Down Expand Up @@ -12941,7 +12944,7 @@
"QueryTypes": {
"oneOf": [
{
"type": "string"
"$ref": "#/components/schemas/SearchModalities"
},
{
"type": "array",
Expand Down Expand Up @@ -14956,6 +14959,24 @@
"bm25"
]
},
"SearchModalities": {
"oneOf": [
{
"type": "object",
"required": [
"image_url"
],
"properties": {
"image_url": {
"type": "string"
}
}
},
{
"type": "string"
}
]
},
"SearchOverGroupsReqPayload": {
"type": "object",
"required": [
Expand Down
12 changes: 7 additions & 5 deletions clients/ts-sdk/src/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1990,10 +1990,7 @@ export type MmrOptions = {
* MultiQuery allows you to construct a dense vector from multiple queries with a weighted sum. This is useful for when you want to emphasize certain features of the query. This only works with Semantic Search and is not compatible with cross encoder re-ranking or highlights.
*/
export type MultiQuery = {
/**
* Query to embed for the final weighted sum vector.
*/
query: string;
query: SearchModalities;
/**
* Float value which is applies as a multiplier to the query vector when summing.
*/
Expand Down Expand Up @@ -2089,6 +2086,7 @@ export type PublicPageParameters = {
defaultSearchQueries?: Array<(string)> | null;
floatingButtonPosition?: (string) | null;
floatingSearchIconPosition?: (string) | null;
followupQuestions?: (boolean) | null;
forBrandName?: (string) | null;
headingPrefix?: (string) | null;
heroPattern?: ((HeroPattern) | null);
Expand Down Expand Up @@ -2208,7 +2206,7 @@ export type QueryCountResponse = {
/**
* Query is the search query. This can be any string. The query will be used to create an embedding vector and/or SPLADE vector which will be used to find the result set. You can either provide one query, or multiple with weights. Multi-query only works with Semantic Search and is not compatible with cross encoder re-ranking or highlights.
*/
export type QueryTypes = string | Array<MultiQuery>;
export type QueryTypes = SearchModalities | Array<MultiQuery>;

export type RAGAnalytics = {
filter?: ((RAGAnalyticsFilter) | null);
Expand Down Expand Up @@ -2694,6 +2692,10 @@ export type SearchLatencyGraph = {

export type SearchMethod = 'fulltext' | 'semantic' | 'hybrid' | 'bm25';

export type SearchModalities = {
image_url: string;
} | string;

export type SearchOverGroupsReqPayload = {
filters?: ((ChunkFilter) | null);
/**
Expand Down
27 changes: 23 additions & 4 deletions frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,25 @@ const PublicPageControls = () => {
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="">
Enable Followup Questions
</label>
<Tooltip
tooltipText="Show AI powered suggested followup questions after the first message."
body={<FaRegularCircleQuestion class="h-3 w-3 text-black" />}
/>
</div>
<input
checked={extraParams.followupQuestions ?? true}
type="checkbox"
onChange={(e) => {
setExtraParams("followupQuestions", 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 class="flex gap-2">
<div class="flex items-center gap-1">
<label class="block" for="">
Expand All @@ -414,7 +433,7 @@ const PublicPageControls = () => {
/>
</div>
<input
checked={extraParams.suggestedQueries || true}
checked={extraParams.suggestedQueries ?? true}
type="checkbox"
onChange={(e) => {
setExtraParams("suggestedQueries", e.currentTarget.checked);
Expand All @@ -433,7 +452,7 @@ const PublicPageControls = () => {
/>
</div>
<input
checked={extraParams.chat || true}
checked={extraParams.chat ?? true}
type="checkbox"
onChange={(e) => {
setExtraParams("chat", e.currentTarget.checked);
Expand Down Expand Up @@ -1071,10 +1090,10 @@ const PublicPageControls = () => {
<div class="flex gap-2">
<div class="flex items-center gap-1">
<label class="block" for="">
Enable Test Mode
Use Beta component
</label>
<Tooltip
tooltipText="Use the unstable version of the search-component. (Mostly used for testing)"
tooltipText="Use the beta version of the search-component."
body={
<FaRegularCircleQuestion class="h-3 w-3 text-black" />
}
Expand Down
3 changes: 3 additions & 0 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3148,6 +3148,9 @@ impl DatasetConfigurationDTO {
suggested_queries: page_parameters_self
.suggested_queries
.or(page_parameters_curr.suggested_queries),
followup_questions: page_parameters_self
.followup_questions
.or(page_parameters_curr.followup_questions),
responsive: page_parameters_self
.responsive
.or(page_parameters_curr.responsive),
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 @@ -183,6 +183,8 @@ pub struct PublicPageParameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub suggested_queries: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub followup_questions: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub responsive: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub chat: Option<bool>,
Expand Down
3 changes: 1 addition & 2 deletions server/src/public/search-component-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
{% if params.type -%}
type: "{{ params.type }}",
{% endif -%}
{% if params.suggestedQueries -%}
suggestedQueries: {{ params.suggestedQueries }},
{% endif -%}
followupQuestions: {{ params.followupQuestions }},
{% if params.analytics -%}
analytics: {{ params.analytics }},
{% endif -%}
Expand Down

0 comments on commit 20e114d

Please sign in to comment.