Skip to content

Commit

Permalink
feature: add more context to suggested questions
Browse files Browse the repository at this point in the history
  • Loading branch information
cdxker authored and densumesh committed Jan 10, 2025
1 parent c8dd845 commit 16c9df6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ import { useChatState } from "./chat-context";

export const useFollowupQuestions = () => {
const { trieveSDK, currentGroup, props } = useModalState();
const { currentQuestion } = useChatState();
const { messages } = useChatState();
const [isLoading, setIsLoading] = useState(false);
const [suggestedQuestions, setSuggestedQuestions] = useState<
SuggestedQueriesResponse["queries"]
>([]);

const getQuestions = async () => {
setIsLoading(true);
const prevMessage = messages.filter((msg) => {
return msg.type == "user"
}).slice(-1)[0];

const queries = await getSuggestedQuestions({
trieve: trieveSDK,
query: currentQuestion,
query: prevMessage.text,
count: props.numberOfSuggestions ?? 3,
group: currentGroup
});
Expand Down
3 changes: 2 additions & 1 deletion clients/search-component/src/utils/trieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ export const getSuggestedQuestions = async ({
{
...(query && { query }),
suggestion_type: "question",
search_type: "semantic",
search_type: "hybrid",
suggestions_to_create: count,
context: `.The users previous query was "${query}", all responses should look like that.`,
...(group &&
group?.tracking_id && {
filters: {
Expand Down
6 changes: 0 additions & 6 deletions server/src/handlers/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,12 +930,6 @@ pub async fn get_suggested_queries(
};
let context_sentence = match data.context.clone() {
Some(context) => {
if context.split_whitespace().count() > 15 || context.len() > 200 {
return Err(ServiceError::BadRequest(
"Context must be under 15 words and 200 characters".to_string(),
));
}

format!(
"\n\nSuggest things with the following context in mind: {}.\n\n",
context
Expand Down
4 changes: 2 additions & 2 deletions server/src/public/product.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h4 class="text-sm text-gray-500 mt-2 w-fit">
>
{% for i in range(5) %}
<div class="mt-auto w-64 flex-shrink-0" x-key="{{ i }}">
<div class="h-72 w-full overflow-hidden rounded-lg">
<div class="w-full overflow-hidden rounded-lg">
<div class="h-full w-full bg-gray-200 animate-pulse"></div>
</div>
<div class="mt-4">
Expand Down Expand Up @@ -120,7 +120,7 @@ <h4 class="text-sm text-gray-500 mt-2 w-fit">
newDiv.classList.add("w-64", "flex-shrink-0", "mt-auto");
newDiv.setAttribute("x-key", i);
newDiv.innerHTML = `
<div class="h-72 w-full overflow-hidden rounded-lg">
<div class="w-full overflow-hidden rounded-lg">
<div class="h-full w-full bg-gray-200 animate-pulse"></div>
</div>
<div class="mt-4">
Expand Down
4 changes: 0 additions & 4 deletions server/static/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,6 @@ video {
height: 1.5rem;
}

.h-72 {
height: 18rem;
}

.h-full {
height: 100%;
}
Expand Down

0 comments on commit 16c9df6

Please sign in to comment.