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

feature: add more context to suggested questions #3107

Merged
merged 1 commit 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
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