fix(ui): chat suggestions leave out prompts already asked in the conversation
This commit is contained in:
1 file changed
+7
-2
@@ -4,7 +4,7 @@ import { computed, onUnmounted } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { chatModelReady, placeholderHint, sendMessage } from "./state";
|
||||
import { chatModelReady, messages, placeholderHint, sendMessage } from "./state";
|
||||
import { suggestionsForRoute } from "./suggestions";
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,12 @@ defineProps<{ list?: boolean }>();
|
||||
|
||||
const route = useRoute();
|
||||
// No model, no prompts: one sent now could only fail.
|
||||
const prompts = computed(() => (chatModelReady.value ? suggestionsForRoute(route) : []));
|
||||
// A prompt already asked in this conversation is not suggested again.
|
||||
const prompts = computed(() => {
|
||||
if (!chatModelReady.value) return [];
|
||||
const asked = new Set(messages.value.map((m) => m.text?.trim()));
|
||||
return suggestionsForRoute(route).filter((p) => !asked.has(p));
|
||||
});
|
||||
|
||||
function send(prompt: string): void {
|
||||
placeholderHint.value = "";
|
||||
|
||||
Reference in new issue
Block a user