mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-10-17 05:14:19 +02:00
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'
|
export const EMBEDDING_MODEL_NAME = 'nomic-embed-text:v1.5'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,6 @@ import { ChatMessage } from '../../../types/chat'
|
||||||
import ChatMessageBubble from './ChatMessageBubble'
|
import ChatMessageBubble from './ChatMessageBubble'
|
||||||
import ChatAssistantAvatar from './ChatAssistantAvatar'
|
import ChatAssistantAvatar from './ChatAssistantAvatar'
|
||||||
import BouncingDots from '../BouncingDots'
|
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'
|
import { usePage } from '@inertiajs/react'
|
||||||
|
|
||||||
interface ChatInterfaceProps {
|
interface ChatInterfaceProps {
|
||||||
|
|
@ -28,29 +24,12 @@ export default function ChatInterface({
|
||||||
chatSuggestions = [],
|
chatSuggestions = [],
|
||||||
chatSuggestionsEnabled = false,
|
chatSuggestionsEnabled = false,
|
||||||
chatSuggestionsLoading = false,
|
chatSuggestionsLoading = false,
|
||||||
rewriteModelAvailable = false,
|
|
||||||
}: ChatInterfaceProps) {
|
}: ChatInterfaceProps) {
|
||||||
const { aiAssistantName } = usePage<{ aiAssistantName: string }>().props
|
const { aiAssistantName } = usePage<{ aiAssistantName: string }>().props
|
||||||
const { addNotification } = useNotifications()
|
|
||||||
const [input, setInput] = useState('')
|
const [input, setInput] = useState('')
|
||||||
const [downloadDialogOpen, setDownloadDialogOpen] = useState(false)
|
|
||||||
const [isDownloading, setIsDownloading] = useState(false)
|
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null)
|
const messagesEndRef = useRef<HTMLDivElement>(null)
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(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 = () => {
|
const scrollToBottom = () => {
|
||||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||||
}
|
}
|
||||||
|
|
@ -192,38 +171,6 @@ export default function ChatInterface({
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</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>
|
||||||
</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 { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import ChatSidebar from './ChatSidebar'
|
import ChatSidebar from './ChatSidebar'
|
||||||
import ChatInterface from './ChatInterface'
|
import ChatInterface from './ChatInterface'
|
||||||
|
|
@ -10,7 +10,6 @@ import { useModals } from '~/context/ModalContext'
|
||||||
import { ChatMessage } from '../../../types/chat'
|
import { ChatMessage } from '../../../types/chat'
|
||||||
import classNames from '~/lib/classNames'
|
import classNames from '~/lib/classNames'
|
||||||
import { IconMenu2, IconX } from '@tabler/icons-react'
|
import { IconMenu2, IconX } from '@tabler/icons-react'
|
||||||
import { DEFAULT_QUERY_REWRITE_MODEL } from '../../../constants/ollama'
|
|
||||||
import { useSystemSetting } from '~/hooks/useSystemSetting'
|
import { useSystemSetting } from '~/hooks/useSystemSetting'
|
||||||
import Switch from '~/components/inputs/Switch'
|
import Switch from '~/components/inputs/Switch'
|
||||||
import InfoTooltip from '~/components/InfoTooltip'
|
import InfoTooltip from '~/components/InfoTooltip'
|
||||||
|
|
@ -133,7 +132,7 @@ export default function Chat({
|
||||||
try {
|
try {
|
||||||
const stored = localStorage.getItem(`nomad:thinking:${m.name}`)
|
const stored = localStorage.getItem(`nomad:thinking:${m.name}`)
|
||||||
if (stored !== null) next[m.name] = stored === 'true'
|
if (stored !== null) next[m.name] = stored === 'true'
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
setThinkingOverrides(next)
|
setThinkingOverrides(next)
|
||||||
}, [installedModels])
|
}, [installedModels])
|
||||||
|
|
@ -152,7 +151,7 @@ export default function Chat({
|
||||||
setThinkingOverrides((prev) => ({ ...prev, [model]: value }))
|
setThinkingOverrides((prev) => ({ ...prev, [model]: value }))
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(`nomad:thinking:${model}`, String(value))
|
localStorage.setItem(`nomad:thinking:${model}`, String(value))
|
||||||
} catch {}
|
} catch { }
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const { data: chatSuggestions, isLoading: chatSuggestionsLoading } = useQuery<string[]>({
|
const { data: chatSuggestions, isLoading: chatSuggestionsLoading } = useQuery<string[]>({
|
||||||
|
|
@ -166,10 +165,6 @@ export default function Chat({
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const rewriteModelAvailable = useMemo(() => {
|
|
||||||
return installedModels.some((model) => model.name === DEFAULT_QUERY_REWRITE_MODEL)
|
|
||||||
}, [installedModels])
|
|
||||||
|
|
||||||
const deleteAllSessionsMutation = useMutation({
|
const deleteAllSessionsMutation = useMutation({
|
||||||
mutationFn: () => api.deleteAllChatSessions(),
|
mutationFn: () => api.deleteAllChatSessions(),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
|
@ -449,13 +444,13 @@ export default function Chat({
|
||||||
prev.map((m) =>
|
prev.map((m) =>
|
||||||
m.id === assistantMsgId
|
m.id === assistantMsgId
|
||||||
? {
|
? {
|
||||||
...m,
|
...m,
|
||||||
content: m.content + chunkContent,
|
content: m.content + chunkContent,
|
||||||
thinking: (m.thinking ?? '') + chunkThinking,
|
thinking: (m.thinking ?? '') + chunkThinking,
|
||||||
isStreaming: !done,
|
isStreaming: !done,
|
||||||
isThinking: isThinkingPhase,
|
isThinking: isThinkingPhase,
|
||||||
thinkingDuration: thinkingDuration ?? undefined,
|
thinkingDuration: thinkingDuration ?? undefined,
|
||||||
}
|
}
|
||||||
: m
|
: m
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -586,24 +581,24 @@ export default function Chat({
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{ragEnabled && (
|
{ragEnabled && (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<label htmlFor="collection-select" className="text-sm text-text-secondary">
|
<label htmlFor="collection-select" className="text-sm text-text-secondary">
|
||||||
Search in:
|
Search in:
|
||||||
</label>
|
</label>
|
||||||
<select
|
<select
|
||||||
id="collection-select"
|
id="collection-select"
|
||||||
value={collectionFilter}
|
value={collectionFilter}
|
||||||
onChange={(e) => setCollectionFilter(e.target.value)}
|
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"
|
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>
|
<option value="">All</option>
|
||||||
{knownCollections.map((c) => (
|
{knownCollections.map((c) => (
|
||||||
<option key={c} value={c}>{c}</option>
|
<option key={c} value={c}>{c}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="flex items-center gap-2 min-w-0">
|
<div className="flex items-center gap-2 min-w-0">
|
||||||
<label htmlFor="model-select" className="text-sm text-text-secondary">
|
<label htmlFor="model-select" className="text-sm text-text-secondary">
|
||||||
Model:
|
Model:
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -641,21 +636,21 @@ export default function Chat({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{selectedModelSupportsThinking && (
|
{selectedModelSupportsThinking && (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<span className="text-sm text-text-secondary select-none">Thinking:</span>
|
<span className="text-sm text-text-secondary select-none">Thinking:</span>
|
||||||
<InfoTooltip
|
<InfoTooltip
|
||||||
position="bottom"
|
position="bottom"
|
||||||
align="right"
|
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."
|
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
|
<Switch
|
||||||
id="chat-thinking-toggle"
|
id="chat-thinking-toggle"
|
||||||
checked={effectiveThinking(selectedModel)}
|
checked={effectiveThinking(selectedModel)}
|
||||||
onChange={(v) => setModelThinking(selectedModel, v)}
|
onChange={(v) => setModelThinking(selectedModel, v)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{isInModal && (
|
{isInModal && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Close chat"
|
aria-label="Close chat"
|
||||||
|
|
@ -678,7 +673,6 @@ export default function Chat({
|
||||||
chatSuggestions={chatSuggestions}
|
chatSuggestions={chatSuggestions}
|
||||||
chatSuggestionsEnabled={suggestionsEnabled}
|
chatSuggestionsEnabled={suggestionsEnabled}
|
||||||
chatSuggestionsLoading={chatSuggestionsLoading}
|
chatSuggestionsLoading={chatSuggestionsLoading}
|
||||||
rewriteModelAvailable={rewriteModelAvailable}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user