Skip to content

Commit e875654

Browse files
committed
cleanup: scroll and missing user message
1 parent 6bc5f42 commit e875654

File tree

9 files changed

+38
-41
lines changed

9 files changed

+38
-41
lines changed

clients/search-component/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"import": "./dist/vanilla/index.js"
2020
}
2121
},
22-
"version": "0.2.26",
22+
"version": "0.2.27",
2323
"license": "MIT",
2424
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component",
2525
"scripts": {

clients/search-component/src/TrieveModal/Search/ProductItem.tsx

+14-14
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,21 @@ export const ProductItem = ({
178178
featured_image: { src: string };
179179
title: string;
180180
}[]
181-
)?.map((variant) => (
182-
<button
183-
key={variant.title}
184-
onClick={(ev) => {
185-
ev.preventDefault();
186-
ev.stopPropagation();
187-
ev.nativeEvent.stopImmediatePropagation();
188-
if (variant.featured_image?.src) {
181+
)
182+
?.filter((variant) => variant.featured_image?.src)
183+
?.map((variant) => (
184+
<button
185+
key={variant.title}
186+
onClick={(ev) => {
187+
ev.preventDefault();
188+
ev.stopPropagation();
189+
ev.nativeEvent.stopImmediatePropagation();
189190
setShownImage(variant.featured_image?.src);
190-
}
191-
}}
192-
>
193-
{variant.title}
194-
</button>
195-
))}
191+
}}
192+
>
193+
{variant.title}
194+
</button>
195+
))}
196196
</div>
197197
) : null}
198198
</>

clients/search-component/src/TrieveModal/index.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ body {
499499
}
500500

501501
.brand-name {
502-
@apply text-white px-1.5 py-1 rounded-md font-[500];
502+
@apply text-white px-1.5 py-1 rounded-md font-[500] whitespace-nowrap;
503503
}
504504
}
505505
}
@@ -639,8 +639,7 @@ body {
639639
}
640640

641641
&:focus {
642-
border: 1.5px solid var(--tv-prop-brand-color);
643-
transform: translateY(-0.1px) scale(1.0006);
642+
border: 1px solid var(--tv-prop-brand-color);
644643
}
645644
}
646645

clients/search-component/src/utils/hooks/chat-context.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
262262

263263
const askQuestion = async (question?: string, group?: ChunkGroup) => {
264264
isDoneReading.current = false;
265+
266+
if (!currentGroup && group) {
267+
chatWithGroup(group);
268+
setCurrentGroup(group);
269+
}
270+
265271
setMessages((m) => [
266272
...m,
267273
[
@@ -274,11 +280,6 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
274280
],
275281
]);
276282

277-
if (!currentGroup && group) {
278-
chatWithGroup(group);
279-
setCurrentGroup(group);
280-
}
281-
282283
if (!currentTopic && !currentGroup && !group) {
283284
await createTopic({ question: question || currentQuestion });
284285
} else {

server/src/handlers/chunk_handler.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,6 @@ pub async fn generate_off_chunks(
24662466
};
24672467

24682468
let chunk_ids = data.chunk_ids.clone();
2469-
let prompt = data.prompt.clone();
24702469
let stream_response = data.stream_response;
24712470
let context_options = data.context_options.clone();
24722471

@@ -2477,8 +2476,8 @@ pub async fn generate_off_chunks(
24772476
DatasetConfiguration::from_json(dataset_org_plan_sub.dataset.server_configuration);
24782477

24792478
let base_url = dataset_config.LLM_BASE_URL;
2480-
2481-
let default_model = dataset_config.LLM_DEFAULT_MODEL;
2479+
let rag_prompt = dataset_config.RAG_PROMPT.clone();
2480+
let chosen_model = dataset_config.LLM_DEFAULT_MODEL;
24822481

24832482
let base_url = if base_url.is_empty() {
24842483
"https://openrouter.ai/api/v1".into()
@@ -2600,7 +2599,8 @@ pub async fn generate_off_chunks(
26002599

26012600
let last_prev_message = prev_messages
26022601
.last()
2603-
.expect("There needs to be at least 1 prior message");
2602+
.expect("There needs to be at least 1 prior message")
2603+
.clone();
26042604

26052605
let mut prev_messages = prev_messages.clone();
26062606

@@ -2610,19 +2610,17 @@ pub async fn generate_off_chunks(
26102610
.iter()
26112611
.for_each(|message| messages.push(ChatMessage::from(message.clone())));
26122612

2613-
let prompt = prompt.unwrap_or("Respond to the question or instruction using the docs and include the doc numbers that you used in square brackets at the end of the sentences that you used the docs for:\n\n".to_string());
2614-
26152613
messages.push(ChatMessage::User {
26162614
content: ChatMessageContent::Text(format!(
26172615
"{} {}",
2618-
prompt,
2616+
rag_prompt,
26192617
last_prev_message.content.clone()
26202618
)),
26212619
name: None,
26222620
});
26232621

26242622
let parameters = ChatCompletionParameters {
2625-
model: default_model,
2623+
model: chosen_model,
26262624
stream: stream_response,
26272625
messages,
26282626
top_p: None,
@@ -2729,7 +2727,7 @@ pub async fn generate_off_chunks(
27292727
json.to_string()
27302728
})
27312729
.collect(),
2732-
user_message: prompt,
2730+
user_message: format!("{} {}", rag_prompt, last_prev_message.content.clone()),
27332731
query_rating: String::new(),
27342732
rag_type: "chosen_chunks".to_string(),
27352733
llm_response: completion_content.clone(),
@@ -2799,7 +2797,7 @@ pub async fn generate_off_chunks(
27992797
json.to_string()
28002798
})
28012799
.collect(),
2802-
user_message: prompt,
2800+
user_message: format!("{} {}", rag_prompt, last_prev_message.content.clone()),
28032801
rag_type: "chosen_chunks".to_string(),
28042802
query_rating: String::new(),
28052803
llm_response: completion,

server/src/public/page.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<link rel="stylesheet" href="/static/output.css" />
55
<link
66
rel="stylesheet"
7-
href="https://unpkg.com/[email protected].26/dist/index.css"
7+
href="https://unpkg.com/[email protected].27/dist/index.css"
88
/>
99
<link
1010
rel="apple-touch-icon"
@@ -274,7 +274,7 @@
274274
</style>
275275

276276
<script type="module">
277-
import {renderToDiv} from 'https://unpkg.com/[email protected].26/dist/vanilla/index.js';
277+
import {renderToDiv} from 'https://unpkg.com/[email protected].27/dist/vanilla/index.js';
278278
const root = document.getElementById('root');
279279
renderToDiv(root, {
280280
... {{params | tojson}}

server/src/public/product.html

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ <h6 class="rec-price mt-1 text-sm text-gray-700">${price}</h6>
215215
const betterGroupName =
216216
window.paramsData.singleProductOptions.productName;
217217

218-
219218
window.dispatchEvent(
220219
new CustomEvent("trieve-start-chat-with-group", {
221220
detail: {

server/src/public/tabs.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525
window.tabData = {{ tabs | tojson }};
2626

2727
function setOpenTab(tabIndex) {
28+
const tabButtonsCarousel = document.querySelector('#tab-buttons');
2829
const tabButtons = document.querySelectorAll('.tab-button');
2930
tabButtons.forEach((tabButton, index) => {
3031
if (index === tabIndex) {
3132
tabButton.classList.add('active');
32-
tabButton.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
33+
tabButtonsCarousel.scrollTo({
34+
left: tabButton.offsetLeft - tabButtonsCarousel.offsetWidth / 2 + tabButton.offsetWidth / 2,
35+
behavior: 'smooth',
36+
});
3337
} else {
3438
tabButton.classList.remove('active');
3539
}

server/static/output.css

-4
Original file line numberDiff line numberDiff line change
@@ -620,10 +620,6 @@ video {
620620
-webkit-line-clamp: 1;
621621
}
622622

623-
.block {
624-
display: block;
625-
}
626-
627623
.flex {
628624
display: flex;
629625
}

0 commit comments

Comments
 (0)