Skip to content

Commit

Permalink
cleanup: scroll and missing user message
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev committed Dec 17, 2024
1 parent 6bc5f42 commit 01d30a0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 38 deletions.
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.26",
"version": "0.2.27",
"license": "MIT",
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component",
"scripts": {
Expand Down
28 changes: 14 additions & 14 deletions clients/search-component/src/TrieveModal/Search/ProductItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,21 @@ export const ProductItem = ({
featured_image: { src: string };
title: string;
}[]
)?.map((variant) => (
<button
key={variant.title}
onClick={(ev) => {
ev.preventDefault();
ev.stopPropagation();
ev.nativeEvent.stopImmediatePropagation();
if (variant.featured_image?.src) {
)
?.filter((variant) => variant.featured_image?.src)
?.map((variant) => (
<button
key={variant.title}
onClick={(ev) => {
ev.preventDefault();
ev.stopPropagation();
ev.nativeEvent.stopImmediatePropagation();
setShownImage(variant.featured_image?.src);
}
}}
>
{variant.title}
</button>
))}
}}
>
{variant.title}
</button>
))}
</div>
) : null}
</>
Expand Down
5 changes: 2 additions & 3 deletions clients/search-component/src/TrieveModal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ body {
}

.brand-name {
@apply text-white px-1.5 py-1 rounded-md font-[500];
@apply text-white px-1.5 py-1 rounded-md font-[500] whitespace-nowrap;
}
}
}
Expand Down Expand Up @@ -639,8 +639,7 @@ body {
}

&:focus {
border: 1.5px solid var(--tv-prop-brand-color);
transform: translateY(-0.1px) scale(1.0006);
border: 1px solid var(--tv-prop-brand-color);
}
}

Expand Down
11 changes: 6 additions & 5 deletions clients/search-component/src/utils/hooks/chat-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ function ChatProvider({ children }: { children: React.ReactNode }) {

const askQuestion = async (question?: string, group?: ChunkGroup) => {
isDoneReading.current = false;

if (!currentGroup && group) {
chatWithGroup(group);
setCurrentGroup(group);
}

setMessages((m) => [
...m,
[
Expand All @@ -274,11 +280,6 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
],
]);

if (!currentGroup && group) {
chatWithGroup(group);
setCurrentGroup(group);
}

if (!currentTopic && !currentGroup && !group) {
await createTopic({ question: question || currentQuestion });
} else {
Expand Down
18 changes: 8 additions & 10 deletions server/src/handlers/chunk_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,6 @@ pub async fn generate_off_chunks(
};

let chunk_ids = data.chunk_ids.clone();
let prompt = data.prompt.clone();
let stream_response = data.stream_response;
let context_options = data.context_options.clone();

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

let base_url = dataset_config.LLM_BASE_URL;

let default_model = dataset_config.LLM_DEFAULT_MODEL;
let rag_prompt = dataset_config.RAG_PROMPT.clone();
let chosen_model = dataset_config.LLM_DEFAULT_MODEL;

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

let last_prev_message = prev_messages
.last()
.expect("There needs to be at least 1 prior message");
.expect("There needs to be at least 1 prior message")
.clone();

let mut prev_messages = prev_messages.clone();

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

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());

messages.push(ChatMessage::User {
content: ChatMessageContent::Text(format!(
"{} {}",
prompt,
rag_prompt,
last_prev_message.content.clone()
)),
name: None,
});

let parameters = ChatCompletionParameters {
model: default_model,
model: chosen_model,
stream: stream_response,
messages,
top_p: None,
Expand Down Expand Up @@ -2729,7 +2727,7 @@ pub async fn generate_off_chunks(
json.to_string()
})
.collect(),
user_message: prompt,
user_message: format!("{} {}", rag_prompt, last_prev_message.content.clone()),
query_rating: String::new(),
rag_type: "chosen_chunks".to_string(),
llm_response: completion_content.clone(),
Expand Down Expand Up @@ -2799,7 +2797,7 @@ pub async fn generate_off_chunks(
json.to_string()
})
.collect(),
user_message: prompt,
user_message: format!("{} {}", rag_prompt, last_prev_message.content.clone()),
rag_type: "chosen_chunks".to_string(),
query_rating: String::new(),
llm_response: completion,
Expand Down
1 change: 1 addition & 0 deletions server/src/public/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ <h6 class="rec-price mt-1 text-sm text-gray-700">${price}</h6>
const betterGroupName =
window.paramsData.singleProductOptions.productName;

console.log({ detail: { group, betterGroupName, message } });

window.dispatchEvent(
new CustomEvent("trieve-start-chat-with-group", {
Expand Down
6 changes: 5 additions & 1 deletion server/src/public/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
window.tabData = {{ tabs | tojson }};

function setOpenTab(tabIndex) {
const tabButtonsCarousel = document.querySelector('#tab-buttons');
const tabButtons = document.querySelectorAll('.tab-button');
tabButtons.forEach((tabButton, index) => {
if (index === tabIndex) {
tabButton.classList.add('active');
tabButton.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
tabButtonsCarousel.scrollTo({
left: tabButton.offsetLeft - tabButtonsCarousel.offsetWidth / 2 + tabButton.offsetWidth / 2,
behavior: 'smooth',
});
} else {
tabButton.classList.remove('active');
}
Expand Down
4 changes: 0 additions & 4 deletions server/static/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,6 @@ video {
-webkit-line-clamp: 1;
}

.block {
display: block;
}

.flex {
display: flex;
}
Expand Down

0 comments on commit 01d30a0

Please sign in to comment.