feat: remove search rerank

This commit is contained in:
Zoe
2026-09-27 09:45:19 -05:00
parent bb5795e00d
commit d48d8163a7
17 changed files with 243 additions and 336 deletions
+1 -10
View File
@@ -46,8 +46,6 @@ const props = defineProps<{
const searchConfig = ref({
enabled: props.agent?.config?.search?.enabled ?? false,
maxResults: props.agent?.config?.search?.maxResults ?? 10,
rerank: props.agent?.config?.search?.rerank ?? false,
});
const toolsConfig = ref({
@@ -57,8 +55,6 @@ const toolsConfig = ref({
watch(() => props.agent?.config?.search, (val) => {
searchConfig.value = {
enabled: val?.enabled ?? false,
maxResults: val?.maxResults ?? 10,
rerank: val?.rerank ?? false,
};
}, { deep: true });
@@ -79,8 +75,6 @@ const saveAgentConfig = async (partial: {
...(partial.search !== undefined ? {
search: {
enabled: partial.search.enabled,
maxResults: partial.search.maxResults,
rerank: partial.search.rerank,
},
} : {}),
...(partial.tools !== undefined ? {
@@ -414,10 +408,7 @@ onUnmounted(() => {
<ModelSelector v-if="providers !== undefined" :add-hotkey="true" v-model="selectedModel"
:providers="providers" />
<SearchSelector v-if="selectedModel?.capabilities.includes('tools')" :enabled="searchConfig.enabled"
:max-results="searchConfig.maxResults" :rerank="searchConfig.rerank"
@update:enabled="(v: boolean) => { searchConfig.enabled = v; saveSearchConfig() }"
@update:max-results="(v: number) => { searchConfig.maxResults = v; saveSearchConfig() }"
@update:rerank="(v: boolean) => { searchConfig.rerank = v; saveSearchConfig() }" />
@update:enabled="(v: boolean) => { searchConfig.enabled = v; saveSearchConfig() }" />
<ToolSelector v-if="selectedModel?.capabilities.includes('tools')" :python="toolsConfig.python"
@update:python="(v: boolean) => { toolsConfig.python = v; saveToolsConfig() }" />
<FileSelector ref="fileSelectorRef" :selected-model="selectedModel" v-model="files" />
+24 -5
View File
@@ -8,6 +8,7 @@ import {
getFaviconUrl,
parseToolValue,
readSearchSources,
readSearchWarnings,
} from "~/utils/tool-rendering";
const props = defineProps<{
@@ -19,7 +20,10 @@ const emit = defineEmits<{
retry: [];
}>();
const sources = computed(() => readSearchSources(parseToolValue(props.toolCall.output)));
const output = computed(() => parseToolValue(props.toolCall.output));
const sources = computed(() => readSearchSources(output.value));
const warnings = computed(() => readSearchWarnings(output.value));
const warningSummary = computed(() => warnings.value.map(warning => `${warning.engine}: ${warning.reason}`).join("; "));
const query = computed(() => {
const input = parseToolValue(props.toolCall.input);
@@ -103,6 +107,17 @@ const customTab = computed(() => {
@retry="emit('retry')"
>
<template #summary>
<Tooltip
v-if="warnings.length"
class="flex items-center text-amber-500 mr-2"
:text="`Some search engines failed: ${warningSummary}`"
>
<span
class="i-mynaui-danger-triangle w-4 h-4"
role="img"
:aria-label="`Some search engines failed: ${warningSummary}`"
></span>
</Tooltip>
<div v-if="topDomains.length && toolCall.status !== 'pending'" class="flex items-center mr-1" aria-hidden="true">
<span
v-for="(domain, idx) in topDomains"
@@ -132,7 +147,11 @@ const customTab = computed(() => {
</template>
<template #sources>
<div v-if="sources?.length" class="flex flex-col gap-2 max-h-80 overflow-y-auto scrollbar-thin p-3">
<div class="flex flex-col gap-2 max-h-80 overflow-y-auto scrollbar-thin p-3">
<p v-if="warnings.length" class="flex items-start gap-2 text-xs text-amber-500 m-0">
<span class="i-mynaui-danger-triangle w-4 h-4 shrink-0" aria-hidden="true"></span>
<span>Some search engines failed: {{ warningSummary }}</span>
</p>
<a
v-for="source in sources"
:key="source.url"
@@ -172,10 +191,10 @@ const customTab = computed(() => {
{{ source.snippet }}
</p>
</a>
<p v-if="!sources?.length" class="text-xs text-[var(--text-tertiary)] m-0">
{{ toolCall.status === "pending" ? "Waiting for results…" : "No usable sources returned." }}
</p>
</div>
<p v-else class="text-xs text-[var(--text-tertiary)] p-3 m-0">
{{ toolCall.status === "pending" ? "Waiting for results…" : "No usable sources returned." }}
</p>
</template>
</Disclosure>
</template>
+3 -82
View File
@@ -1,39 +1,9 @@
<script setup lang="ts">
import { DialogType } from '~/composables/useDialog';
const { openDialog } = await useDialog();
const props = defineProps<{
enabled: boolean;
maxResults: number;
rerank: boolean;
}>();
defineProps<{ enabled: boolean }>();
const emit = defineEmits<{
'update:enabled': [value: boolean];
'update:maxResults': [value: number];
'update:rerank': [value: boolean];
}>();
const adjustMaxResults = (delta: number) => {
const next = Math.min(50, Math.max(1, props.maxResults + delta));
emit('update:maxResults', next);
};
const { settings } = await useUserSettings();
const systemAssistantsRerank = computed(() => {
return settings.value.systemAssistants?.rerank ?? null;
});
const isRerankConfigured = computed(() => {
const sa = systemAssistantsRerank.value;
return sa?.enabled === true && sa?.modelId != null && sa.modelId !== '';
});
const openSettings = () => {
openDialog(DialogType.Settings, undefined, { page: 'systemAssistants' });
};
</script>
<template>
@@ -46,10 +16,8 @@ const openSettings = () => {
</button>
</template>
<template #dropdown="{ close }">
<div class="flex p-1 gap-4">
<!-- Left: mode toggle group -->
<div class="flex flex-col gap-1">
<template #dropdown>
<div class="flex flex-col gap-1 p-1">
<button @click="emit('update:enabled', false)"
class="flex items-start gap-3 rounded-xl px-3 py-2.5 text-left transition-colors duration-150"
:class="!enabled
@@ -87,53 +55,6 @@ const openSettings = () => {
</span>
</div>
</button>
</div>
<!-- Right: settings (only when enabled) -->
<div v-if="enabled" class="flex flex-col gap-3 border-l border-[var(--color-border)] pl-4">
<!-- Max results stepper -->
<div class="flex flex-col gap-1.5">
<span class="text-xs font-medium text-[var(--text-tertiary)] uppercase tracking-wider">
Max results
</span>
<div class="flex items-center gap-2">
<button @click="adjustMaxResults(-1)"
class="h-7 w-7 flex items-center justify-center rounded-lg @hover:bg-[var(--color-hover)] text-[var(--text-secondary)] @hover:text-[var(--text-primary)] transition-colors duration-150">
<span class="text-sm i-mynaui-minus"></span>
</button>
<span class="w-8 text-center text-sm font-medium tabular-nums text-[var(--text-primary)]">
{{ maxResults }}
</span>
<button @click="adjustMaxResults(1)"
class="h-7 w-7 flex items-center justify-center rounded-lg @hover:bg-[var(--color-hover)] text-[var(--text-secondary)] @hover:text-[var(--text-primary)] transition-colors duration-150">
<span class="text-sm i-mynaui-plus-solid"></span>
</button>
</div>
</div>
<!-- Rerank toggle -->
<div class="flex flex-col gap-1.5">
<span class="text-xs font-medium text-[var(--color-tertiary)] uppercase tracking-wider">
Rerank
</span>
<div v-if="!isRerankConfigured"
class="flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[var(--bg-container)] border border-[var(--color-border)]">
<button @click="() => { openSettings(); close() }"
class="flex items-center gap-2 text-xs text-[var(--text-dim)] hover:text-[var(--text-primary)] transition-colors duration-150">
<span class="i-mynaui-sparkles text-3.5"></span>
<span>Setup reranking</span>
<span class="i-mynaui-arrow-right text-3 ml-auto"></span>
</button>
</div>
<label v-else
class="flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[var(--bg-container)] border border-[var(--color-border)] cursor-pointer @hover:border-[var(--color-hover)] transition-colors duration-150">
<input type="checkbox" :checked="props.rerank"
@change="emit('update:rerank', ($event.target as HTMLInputElement).checked)"
class="w-4 h-4 rounded border-[var(--color-border)] bg-transparent text-[var(--color-accent)] focus:ring-[var(--color-accent)] focus:ring-offset-0 cursor-pointer" />
<span class="text-xs text-[var(--text-secondary)]">Rerank results</span>
</label>
</div>
</div>
</div>
</template>
</Dropdown>
+13 -17
View File
@@ -1,18 +1,14 @@
<script setup lang="ts">
import type { ModelWithProvider } from '~/composables/useModels';
const props = defineProps<{
params?: string;
}>();
const { providers, allModels } = await useModels();
const { settings, updateSettings } = await useUserSettings();
const toggle = async (key: string) => {
const current = (settings.value.systemAssistants as any)[key];
const toggle = async () => {
const current = settings.value.systemAssistants.rename;
await updateSettings({
systemAssistants: {
[key]: {
rename: {
...current,
enabled: !current.enabled
}
@@ -20,11 +16,11 @@ const toggle = async (key: string) => {
});
};
const updateModel = async (key: string, model: ModelWithProvider | undefined | null) => {
const current = (settings.value.systemAssistants as any)[key];
const updateModel = async (model: ModelWithProvider | undefined | null) => {
const current = settings.value.systemAssistants.rename;
await updateSettings({
systemAssistants: {
[key]: {
rename: {
...current,
modelId: model?.id ?? null
}
@@ -44,15 +40,15 @@ defineEmits(['navigate']);
<template>
<div
class="flex flex-col gap-4 py-4 flex-grow overflow-auto [scrollbar-width:thin] [scrollbar-color:#888_transparent] [scrollbar-gutter:stable]">
<div class="flex flex-col" v-for="(systemAssistant, key) in settings.systemAssistants" :key="key">
<label :for="`slider-${key}`" class="flex justify-between gap-4 items-center">
<h4 class="case-capital">{{ key }}</h4>
<Slider :id="`slider-${key}`" :checked="systemAssistant?.enabled ?? false"
@click="toggle(String(key))" />
<div class="flex flex-col">
<label for="slider-rename" class="flex justify-between gap-4 items-center">
<h4 class="case-capital">Rename</h4>
<Slider id="slider-rename" :checked="settings.systemAssistants.rename?.enabled ?? false"
@click="toggle" />
</label>
<div class="flex-1 justify-between gap-4 items-center">
<ModelSelector :providers="providers" :model-value="getModel(systemAssistant?.modelId)"
@update:model-value="(model) => updateModel(String(key), model)" />
<ModelSelector :providers="providers" :model-value="getModel(settings.systemAssistants.rename?.modelId)"
@update:model-value="updateModel" />
</div>
</div>
</div>
+2 -1
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
const props = defineProps<{
hotkey?: string[];
text?: string;
}>();
const { show, hide } = useTooltip();
@@ -14,7 +15,7 @@ onMounted(() => {
const onMouseEnter = () => {
if (triggerRef.value && hasCursor.value) {
show(triggerRef.value, props.hotkey);
show(triggerRef.value, props.hotkey, props.text);
}
};
</script>
+3 -2
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useFloating, offset, flip, shift, autoUpdate, hide } from '@floating-ui/vue';
const { activeElement, activeHotkey, isVisible } = useTooltip();
const { activeElement, activeHotkey, activeText, isVisible } = useTooltip();
const tooltipRef = ref<HTMLElement | null>(null);
@@ -61,7 +61,8 @@ const transformOrigin = computed(() => placement.value.includes('top') ? 'transf
}
]" :class="transformOrigin"
class="pointer-events-none fixed z-35 flex flex-col bg-[var(--bg-surface)] rounded-lg shadow-xl px-1.5 py-1 text-xs">
<div class="flex gap-1 items-center">
<span v-if="activeText" class="max-w-xs whitespace-normal">{{ activeText }}</span>
<div v-if="displayHotkey?.length" class="flex gap-1 items-center">
<span v-for="key in displayHotkey" :key="key"
class="bg-[var(--bg-container)] px-1 rounded border border-[var(--color-border)]">
<kbd class="font-mono text-[10px] case-capital">{{ key }}</kbd>
-20
View File
@@ -450,31 +450,11 @@ export const useChat = async (topicId: MaybeRef<string>, connect = true) => {
return Err(ChatErrorType.NoAgent);
}
const { settings } = await useUserSettings();
let rerank = undefined;
if (agent.config?.search?.rerank && settings.value.systemAssistants.rerank.enabled) {
const rerankModel = await useModels().then(m => m.allModels.value.find(m => m.id === settings.value.systemAssistants.rerank.modelId));
if (rerankModel) {
const rerankProviderApiKeyRes = await getProviderAPIKey(rerankModel.provider);
if (rerankProviderApiKeyRes.ok === false) {
return rerankProviderApiKeyRes;
}
const rerankProviderApiKey = rerankProviderApiKeyRes.data;
rerank = {
modelId: rerankModel.id,
providerApiKey: rerankProviderApiKey,
};
}
}
await $fetch(`/api/topic/${unref(topicId)}/chat`, {
method: 'POST',
body: {
modelId: model.id,
providerApiKey,
rerank,
parentMessageId,
},
});
+5 -1
View File
@@ -3,12 +3,13 @@ const persistTimeout = 150;
export const useTooltip = () => {
const activeElement = useState<HTMLElement | null>('tooltip:activeElement', () => null);
const activeText = useState<string | null>('tooltip:activeText', () => null);
const activeHotkey = useState<string[] | null>('tooltip:activeHotkey', () => null);
const isVisible = useState<boolean>('tooltip:isVisible', () => false);
const dwellTimeoutId = useState<NodeJS.Timeout | null>('tooltip:dwellTimeoutId', () => null);
const closeTimeoutId = useState<NodeJS.Timeout | null>('tooltip:closeTimeout', () => null);
const show = (el: HTMLElement, hotkey?: string[]) => {
const show = (el: HTMLElement, hotkey?: string[], text?: string) => {
if (closeTimeoutId.value) {
clearTimeout(closeTimeoutId.value);
}
@@ -16,10 +17,12 @@ export const useTooltip = () => {
if (isVisible.value) {
activeElement.value = el;
activeHotkey.value = hotkey || null;
activeText.value = text || null;
} else {
dwellTimeoutId.value = setTimeout(() => {
activeElement.value = el;
activeHotkey.value = hotkey || null;
activeText.value = text || null;
isVisible.value = true;
}, dwellTimeout);
}
@@ -44,6 +47,7 @@ export const useTooltip = () => {
return {
activeElement: readonly(activeElement),
activeHotkey: readonly(activeHotkey),
activeText: readonly(activeText),
isVisible: readonly(isVisible),
show,
hide,
+18
View File
@@ -27,7 +27,25 @@ export interface SearchSource {
snippet: string;
}
export const readSearchWarnings = (value: unknown): { engine: string; reason: string }[] => {
if (typeof value !== "object" || value === null || !("warnings" in value) || !Array.isArray(value.warnings)) {
return [];
}
return value.warnings.flatMap((warning: unknown) => {
if (typeof warning !== "object" || warning === null
|| !("engine" in warning) || typeof warning.engine !== "string"
|| !("reason" in warning) || typeof warning.reason !== "string") {
return [];
}
return [{ engine: warning.engine, reason: warning.reason }];
});
};
export const readSearchSources = (value: unknown): SearchSource[] | null => {
// Older tool calls stored the results array directly.
if (typeof value === "object" && value !== null && "results" in value) {
value = value.results;
}
if (!Array.isArray(value)) {
return null;
}