Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: component inline fixes #3104

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3.7",
"version": "0.3.8",
"license": "MIT",
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion clients/search-component/src/TrieveModal/Chat/ChatMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ChatMode = () => {
}, [chatInput, mode, open]);

return (
<Suspense>
<Suspense fallback={<div className="suspense-fallback w-96 h-96 bg-red-500">HIIIIII</div>}>
{props.inline && messages.length ? (
<div className="inline-chat-header">
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const SearchMode = () => {
}, [results]);

return (
<Suspense fallback={<div className="suspense-fallback"> </div>}>
<Suspense fallback={<div className="suspense-fallback w-96 h-96 bg-red-500">HIIIIII</div>}>
<div
className={`close-modal-button search ${props.type}`}
onClick={() => setOpen(false)}
Expand Down
2 changes: 1 addition & 1 deletion clients/search-component/src/TrieveModal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ body {
}

#trieve-search-modal {
@apply animate-contentShow scroll-smooth max-h-[60vh] w-[90vw] sm:max-w-[800px] rounded-lg focus:outline-none overflow-hidden text-base;
@apply scroll-smooth max-h-[60vh] w-[90vw] sm:max-w-[800px] rounded-lg focus:outline-none overflow-hidden text-base;

color: var(--tv-zinc-950);
background-color: #fff;
Expand Down
22 changes: 21 additions & 1 deletion clients/search-component/src/utils/hooks/chat-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {

const clearConversation = () => {
setCurrentTopic("");
setCurrentGroup(null);
setMessages([]);
};

Expand Down Expand Up @@ -201,7 +202,7 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
llm_options: {
completion_first: false,
},
page_size: props.searchOptions?.page_size ?? 5,
page_size: props.searchOptions?.page_size ?? 8,
score_threshold: props.searchOptions?.score_threshold || null,
use_group_search: props.useGroupSearch,
filters:
Expand Down Expand Up @@ -258,6 +259,25 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
const askQuestion = async (question?: string, group?: ChunkGroup) => {
setIsDoneReading(false);

if (props.groupTrackingId) {

const fetchedGroup = await trieveSDK.getGroupByTrackingId({
trackingId: props.groupTrackingId
});
if (fetchedGroup) {
group = {
created_at: fetchedGroup.created_at,
updated_at: fetchedGroup.updated_at,
dataset_id: fetchedGroup.dataset_id,
description: fetchedGroup.description,
id: fetchedGroup.id,
metadata: fetchedGroup.metadata,
name: props.cleanGroupName ? props.cleanGroupName : fetchedGroup.name,
tag_set: fetchedGroup.tag_set,
} as ChunkGroup;
}
}

if (!currentGroup && group) {
chatWithGroup(group);
setCurrentGroup(group);
Expand Down
6 changes: 4 additions & 2 deletions clients/search-component/src/utils/hooks/modal-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ export type ModalProps = {
showFloatingSearchIcon?: boolean;
showFloatingInput?: boolean;
inlineHeader?: string;
suggestedQueriesContext: string;
groupTrackingId?: string;
cleanGroupName?: string;
};

const defaultProps = {
Expand Down Expand Up @@ -153,7 +154,8 @@ const defaultProps = {
showFloatingInput: false,
inline: false,
inlineHeader: "AI Assistant by Trieve",
suggestedQueriesContext: "You are an ecommerce sales assistant to help people buy items."
groupTrackingId: undefined,
cleanGroupName: undefined,
};

const ModalContext = createContext<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const useFollowupQuestions = () => {
trieve: trieveSDK,
query: currentQuestion,
count: props.numberOfSuggestions ?? 3,
context: props.suggestedQueriesContext,
group: currentGroup
});
setSuggestedQuestions(queries.queries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const useSuggestedQueries = () => {
trieve: trieveSDK,
query,
count: props.numberOfSuggestions ?? 3,
context: props.suggestedQueriesContext,
abortController,
});
setSuggestedQueries(queries.queries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const useSuggestedQuestions = () => {
const queries = await getSuggestedQuestions({
trieve: trieveSDK,
count: props.numberOfSuggestions ?? 3,
context: props.suggestedQueriesContext,
query,
});
setSuggestedQuestions(queries.queries);
Expand All @@ -39,7 +38,6 @@ export const useSuggestedQuestions = () => {
const queries = await getSuggestedQuestions({
trieve: trieveSDK,
count: props.numberOfSuggestions ?? 3,
context: props.suggestedQueriesContext,
abortController,
query,
});
Expand Down
6 changes: 0 additions & 6 deletions clients/search-component/src/utils/trieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,11 @@ export const getSuggestedQueries = async ({
trieve,
query,
count,
context,
abortController,
}: {
query: string;
trieve: TrieveSDK;
count: number;
context: string;
abortController?: AbortController;
}) => {
return trieve.suggestedQueries(
Expand All @@ -274,7 +272,6 @@ export const getSuggestedQueries = async ({
suggestion_type: "keyword",
suggestions_to_create: count,
search_type: "semantic",
context: context
},
abortController?.signal
);
Expand All @@ -283,14 +280,12 @@ export const getSuggestedQueries = async ({
export const getSuggestedQuestions = async ({
trieve,
abortController,
context,
query,
count,
group,
}: {
trieve: TrieveSDK;
abortController?: AbortController;
context: string;
query?: string;
count: number;
group?: ChunkGroup | null;
Expand All @@ -300,7 +295,6 @@ export const getSuggestedQuestions = async ({
...(query && { query }),
suggestion_type: "question",
search_type: "semantic",
context: context,
suggestions_to_create: count,
...(group &&
group?.tracking_id && {
Expand Down
15 changes: 0 additions & 15 deletions frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1073,21 +1073,6 @@ const PublicPageControls = () => {
/>
</div>

<div class="flex gap-4 pb-2 pt-2">
<div class="grow">
<label class="block">Suggested Queries Context</label>
<textarea
cols={2}
placeholder="You are an ecommerce sales assistant to help people buy items."
value={ extraParams.suggestedQueriesContext || ""}
onInput={(e) => {
setExtraParams("suggestedQueriesContext", e.currentTarget.value)
}}
class="block w-full 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 class="grid grid-cols-2 gap-4">
<div class="flex gap-2">
<div class="flex items-center gap-1">
Expand Down
3 changes: 0 additions & 3 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3297,9 +3297,6 @@ impl DatasetConfigurationDTO {
inline_header: page_parameters_self
.inline_header
.or(page_parameters_curr.inline_header),
suggested_queries_context: page_parameters_self
.suggested_queries_context
.or(page_parameters_curr.suggested_queries_context),
}),
},
DISABLE_ANALYTICS: self
Expand Down
2 changes: 1 addition & 1 deletion server/src/handlers/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ pub async fn get_suggested_queries(
context_sentence,
number_of_suggestions_to_create,
query_style,
number_of_suggestions_to_create,
number_of_suggestions_to_create,
query_style,
query_style,
query_style,
Expand Down
2 changes: 0 additions & 2 deletions server/src/handlers/page_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ pub struct PublicPageParameters {
pub number_of_suggestions: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub inline_header: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub suggested_queries_context: Option<String>,
}

#[utoipa::path(
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 @@ -49,6 +49,8 @@
{% endif %}
{% endif %}

<script defer data-domain="demos.trieve.ai" src="https://plausible.trieve.ai/js/script.js"></script>

<script
src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/js/all.min.js"
data-auto-replace-svg
Expand Down Expand Up @@ -442,7 +444,8 @@

if (params.inline) {
const inlineRoot = document.querySelector("#inline-root");

params.groupTrackingId = params.singleProductOptions.groupTrackingId;
params.cleanGroupName = params.singleProductOptions.productName;
renderToDiv(inlineRoot, {
...params,
})
Expand Down
3 changes: 0 additions & 3 deletions server/src/public/search-component-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
{% if params.inline -%}
inline: {{ params.inline }},
{% endif -%}
{% if params.suggestedQueriesContext -%}
suggestedQueriesContext: "{{ params.suggestedQueriesContext }}",
{% endif -%}
{% if params.analytics -%}
analytics: {{ params.analytics }},
{% endif -%}
Expand Down