fix(AI): removes long-dead default rewrite model warning
This commit is contained in:
parent
e6acf9938a
commit
d022c2de90
|
|
@ -62,8 +62,6 @@ export const FALLBACK_RECOMMENDED_OLLAMA_MODELS: NomadOllamaModel[] = [
|
|||
},
|
||||
]
|
||||
|
||||
export const DEFAULT_QUERY_REWRITE_MODEL = 'qwen2.5:3b' // default to qwen2.5 for query rewriting with good balance of text task performance and resource usage
|
||||
|
||||
export const EMBEDDING_MODEL_NAME = 'nomic-embed-text:v1.5'
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,10 +5,6 @@ import { ChatMessage } from '../../../types/chat'
|
|||
import ChatMessageBubble from './ChatMessageBubble'
|
||||
import ChatAssistantAvatar from './ChatAssistantAvatar'
|
||||
import BouncingDots from '../BouncingDots'
|
||||
import StyledModal from '../StyledModal'
|
||||
import api from '~/lib/api'
|
||||
import { DEFAULT_QUERY_REWRITE_MODEL } from '../../../constants/ollama'
|
||||
import { useNotifications } from '~/context/NotificationContext'
|
||||
import { usePage } from '@inertiajs/react'
|
||||
|
||||
interface ChatInterfaceProps {
|
||||
|
|
@ -28,29 +24,12 @@ export default function ChatInterface({
|
|||
chatSuggestions = [],
|
||||
chatSuggestionsEnabled = false,
|
||||
chatSuggestionsLoading = false,
|
||||
rewriteModelAvailable = false,
|
||||
}: ChatInterfaceProps) {
|
||||
const { aiAssistantName } = usePage<{ aiAssistantName: string }>().props
|
||||
const { addNotification } = useNotifications()
|
||||
const [input, setInput] = useState('')
|
||||
const [downloadDialogOpen, setDownloadDialogOpen] = useState(false)
|
||||
const [isDownloading, setIsDownloading] = useState(false)
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null)
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
|
||||
const handleDownloadModel = async () => {
|
||||
setIsDownloading(true)
|
||||
try {
|
||||
await api.downloadModel(DEFAULT_QUERY_REWRITE_MODEL)
|
||||
addNotification({ type: 'success', message: 'Model download queued' })
|
||||
} catch (error) {
|
||||
addNotification({ type: 'error', message: 'Failed to queue model download' })
|
||||
} finally {
|
||||
setIsDownloading(false)
|
||||
setDownloadDialogOpen(false)
|
||||
}
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||
}
|
||||
|
|
@ -192,38 +171,6 @@ export default function ChatInterface({
|
|||
)}
|
||||
</button>
|
||||
</form>
|
||||
{!rewriteModelAvailable && (
|
||||
<div className="text-sm text-text-muted mt-2">
|
||||
The {DEFAULT_QUERY_REWRITE_MODEL} model is not installed. Consider{' '}
|
||||
<button
|
||||
onClick={() => setDownloadDialogOpen(true)}
|
||||
className="text-desert-green underline hover:text-desert-green/80 cursor-pointer"
|
||||
>
|
||||
downloading it
|
||||
</button>{' '}
|
||||
for improved retrieval-augmented generation (RAG) performance.
|
||||
</div>
|
||||
)}
|
||||
<StyledModal
|
||||
open={downloadDialogOpen}
|
||||
title={`Download ${DEFAULT_QUERY_REWRITE_MODEL}?`}
|
||||
confirmText="Download"
|
||||
cancelText="Cancel"
|
||||
confirmIcon="IconDownload"
|
||||
confirmVariant="primary"
|
||||
confirmLoading={isDownloading}
|
||||
onConfirm={handleDownloadModel}
|
||||
onCancel={() => setDownloadDialogOpen(false)}
|
||||
onClose={() => setDownloadDialogOpen(false)}
|
||||
>
|
||||
<p className="text-text-primary">
|
||||
This will dispatch a background download job for{' '}
|
||||
<span className="font-mono font-medium">{DEFAULT_QUERY_REWRITE_MODEL}</span> and may
|
||||
take some time to complete. The model will be used to rewrite queries for improved RAG
|
||||
retrieval performance. Note that download is only supported when using Ollama. If using
|
||||
an OpenAI API interface, please download the model with that software.
|
||||
</p>
|
||||
</StyledModal>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useState, useCallback, useEffect, useRef, useMemo } from 'react'
|
||||
import { useState, useCallback, useEffect, useRef } from 'react'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import ChatSidebar from './ChatSidebar'
|
||||
import ChatInterface from './ChatInterface'
|
||||
|
|
@ -10,7 +10,6 @@ import { useModals } from '~/context/ModalContext'
|
|||
import { ChatMessage } from '../../../types/chat'
|
||||
import classNames from '~/lib/classNames'
|
||||
import { IconMenu2, IconX } from '@tabler/icons-react'
|
||||
import { DEFAULT_QUERY_REWRITE_MODEL } from '../../../constants/ollama'
|
||||
import { useSystemSetting } from '~/hooks/useSystemSetting'
|
||||
import Switch from '~/components/inputs/Switch'
|
||||
import InfoTooltip from '~/components/InfoTooltip'
|
||||
|
|
@ -133,7 +132,7 @@ export default function Chat({
|
|||
try {
|
||||
const stored = localStorage.getItem(`nomad:thinking:${m.name}`)
|
||||
if (stored !== null) next[m.name] = stored === 'true'
|
||||
} catch {}
|
||||
} catch { }
|
||||
}
|
||||
setThinkingOverrides(next)
|
||||
}, [installedModels])
|
||||
|
|
@ -152,7 +151,7 @@ export default function Chat({
|
|||
setThinkingOverrides((prev) => ({ ...prev, [model]: value }))
|
||||
try {
|
||||
localStorage.setItem(`nomad:thinking:${model}`, String(value))
|
||||
} catch {}
|
||||
} catch { }
|
||||
}, [])
|
||||
|
||||
const { data: chatSuggestions, isLoading: chatSuggestionsLoading } = useQuery<string[]>({
|
||||
|
|
@ -166,10 +165,6 @@ export default function Chat({
|
|||
refetchOnMount: false,
|
||||
})
|
||||
|
||||
const rewriteModelAvailable = useMemo(() => {
|
||||
return installedModels.some((model) => model.name === DEFAULT_QUERY_REWRITE_MODEL)
|
||||
}, [installedModels])
|
||||
|
||||
const deleteAllSessionsMutation = useMutation({
|
||||
mutationFn: () => api.deleteAllChatSessions(),
|
||||
onSuccess: () => {
|
||||
|
|
@ -449,13 +444,13 @@ export default function Chat({
|
|||
prev.map((m) =>
|
||||
m.id === assistantMsgId
|
||||
? {
|
||||
...m,
|
||||
content: m.content + chunkContent,
|
||||
thinking: (m.thinking ?? '') + chunkThinking,
|
||||
isStreaming: !done,
|
||||
isThinking: isThinkingPhase,
|
||||
thinkingDuration: thinkingDuration ?? undefined,
|
||||
}
|
||||
...m,
|
||||
content: m.content + chunkContent,
|
||||
thinking: (m.thinking ?? '') + chunkThinking,
|
||||
isStreaming: !done,
|
||||
isThinking: isThinkingPhase,
|
||||
thinkingDuration: thinkingDuration ?? undefined,
|
||||
}
|
||||
: m
|
||||
)
|
||||
)
|
||||
|
|
@ -586,24 +581,24 @@ export default function Chat({
|
|||
</span>
|
||||
)}
|
||||
{ragEnabled && (
|
||||
<div className="flex items-center gap-2">
|
||||
<label htmlFor="collection-select" className="text-sm text-text-secondary">
|
||||
Search in:
|
||||
</label>
|
||||
<select
|
||||
id="collection-select"
|
||||
value={collectionFilter}
|
||||
onChange={(e) => setCollectionFilter(e.target.value)}
|
||||
className="px-3 py-1.5 border border-border-default rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-desert-green focus:border-transparent bg-surface-primary"
|
||||
>
|
||||
<option value="">All</option>
|
||||
{knownCollections.map((c) => (
|
||||
<option key={c} value={c}>{c}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<label htmlFor="collection-select" className="text-sm text-text-secondary">
|
||||
Search in:
|
||||
</label>
|
||||
<select
|
||||
id="collection-select"
|
||||
value={collectionFilter}
|
||||
onChange={(e) => setCollectionFilter(e.target.value)}
|
||||
className="px-3 py-1.5 border border-border-default rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-desert-green focus:border-transparent bg-surface-primary"
|
||||
>
|
||||
<option value="">All</option>
|
||||
{knownCollections.map((c) => (
|
||||
<option key={c} value={c}>{c}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<label htmlFor="model-select" className="text-sm text-text-secondary">
|
||||
Model:
|
||||
</label>
|
||||
|
|
@ -641,21 +636,21 @@ export default function Chat({
|
|||
/>
|
||||
</div>
|
||||
{selectedModelSupportsThinking && (
|
||||
<div className="flex items-center">
|
||||
<span className="text-sm text-text-secondary select-none">Thinking:</span>
|
||||
<InfoTooltip
|
||||
position="bottom"
|
||||
align="right"
|
||||
text="When on, this model works through its reasoning before answering. Slower, but often better on tricky questions. Your choice is remembered for this model; the default for other models is set in AI Assistant settings."
|
||||
/>
|
||||
<Switch
|
||||
id="chat-thinking-toggle"
|
||||
checked={effectiveThinking(selectedModel)}
|
||||
onChange={(v) => setModelThinking(selectedModel, v)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{isInModal && (
|
||||
<div className="flex items-center">
|
||||
<span className="text-sm text-text-secondary select-none">Thinking:</span>
|
||||
<InfoTooltip
|
||||
position="bottom"
|
||||
align="right"
|
||||
text="When on, this model works through its reasoning before answering. Slower, but often better on tricky questions. Your choice is remembered for this model; the default for other models is set in AI Assistant settings."
|
||||
/>
|
||||
<Switch
|
||||
id="chat-thinking-toggle"
|
||||
checked={effectiveThinking(selectedModel)}
|
||||
onChange={(v) => setModelThinking(selectedModel, v)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{isInModal && (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Close chat"
|
||||
|
|
@ -678,7 +673,6 @@ export default function Chat({
|
|||
chatSuggestions={chatSuggestions}
|
||||
chatSuggestionsEnabled={suggestionsEnabled}
|
||||
chatSuggestionsLoading={chatSuggestionsLoading}
|
||||
rewriteModelAvailable={rewriteModelAvailable}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue