Remove local library context enrichment from chat generation workflow
This commit is contained in:
@@ -2,7 +2,6 @@ import { flushSync } from 'react-dom'
|
|||||||
import { attachmentIsImage, getAttachmentDisplayName } from './attachments'
|
import { attachmentIsImage, getAttachmentDisplayName } from './attachments'
|
||||||
import { getErrorText, isAbortError, readBackendErrorText } from './backendApi'
|
import { getErrorText, isAbortError, readBackendErrorText } from './backendApi'
|
||||||
import {
|
import {
|
||||||
fetchLocalLibraryContext,
|
|
||||||
fetchWebSearchContext,
|
fetchWebSearchContext,
|
||||||
postChatMessage,
|
postChatMessage,
|
||||||
postRegenerateMessage,
|
postRegenerateMessage,
|
||||||
@@ -59,7 +58,6 @@ export function createChatGenerationHandlers({
|
|||||||
composerAttachments,
|
composerAttachments,
|
||||||
createNewChat,
|
createNewChat,
|
||||||
finishCancelableRequest,
|
finishCancelableRequest,
|
||||||
getChatLibraryForSession,
|
|
||||||
getChatWorkflowForSession,
|
getChatWorkflowForSession,
|
||||||
imageAttachmentUnavailableReason,
|
imageAttachmentUnavailableReason,
|
||||||
input,
|
input,
|
||||||
@@ -109,7 +107,6 @@ export function createChatGenerationHandlers({
|
|||||||
regenerateIndex = null,
|
regenerateIndex = null,
|
||||||
isNewChat = false,
|
isNewChat = false,
|
||||||
}) {
|
}) {
|
||||||
const selectedLibrary = getChatLibraryForSession(sessionId)
|
|
||||||
const created = await createWorkflowRun(backendApiUrl, {
|
const created = await createWorkflowRun(backendApiUrl, {
|
||||||
session_id: sessionId,
|
session_id: sessionId,
|
||||||
message: userMessage.content,
|
message: userMessage.content,
|
||||||
@@ -117,7 +114,6 @@ export function createChatGenerationHandlers({
|
|||||||
selection_mode: selection.mode,
|
selection_mode: selection.mode,
|
||||||
workflow_id: selection.workflowId || null,
|
workflow_id: selection.workflowId || null,
|
||||||
workflow_revision_id: workflowRevisionId,
|
workflow_revision_id: workflowRevisionId,
|
||||||
library_slug: selectedLibrary?.slug || null,
|
|
||||||
web_search_enabled: Boolean(webSearchEnabled),
|
web_search_enabled: Boolean(webSearchEnabled),
|
||||||
searx_url: searxUrl || null,
|
searx_url: searxUrl || null,
|
||||||
searx_engines: searxEngines || [],
|
searx_engines: searxEngines || [],
|
||||||
@@ -269,25 +265,9 @@ export function createChatGenerationHandlers({
|
|||||||
let citationSources = []
|
let citationSources = []
|
||||||
const contextBlocks = []
|
const contextBlocks = []
|
||||||
try {
|
try {
|
||||||
const selectedLibrary = getChatLibraryForSession(sessionId)
|
|
||||||
const promptText = overrideUserText != null ? overrideUserText : (msgs[lastUserIdx]?.content || '')
|
const promptText = overrideUserText != null ? overrideUserText : (msgs[lastUserIdx]?.content || '')
|
||||||
const hasPromptText = Boolean((promptText || '').trim())
|
const hasPromptText = Boolean((promptText || '').trim())
|
||||||
|
|
||||||
if (hasPromptText && selectedLibrary?.states?.is_indexed) {
|
|
||||||
try {
|
|
||||||
const localContext = await fetchLocalLibraryContext(backendApiUrl, selectedLibrary.slug, promptText, requestController.signal)
|
|
||||||
if (localContext.contextBlock) {
|
|
||||||
contextBlocks.push(localContext.contextBlock)
|
|
||||||
}
|
|
||||||
if (Array.isArray(localContext.sources)) {
|
|
||||||
citationSources.push(...localContext.sources)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (isAbortError(error)) throw error
|
|
||||||
console.warn('local library enrichment (regenerate) failed', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasPromptText && webSearchEnabled) {
|
if (hasPromptText && webSearchEnabled) {
|
||||||
try {
|
try {
|
||||||
const historyForSearch = msgs
|
const historyForSearch = msgs
|
||||||
@@ -515,23 +495,6 @@ export function createChatGenerationHandlers({
|
|||||||
let citationSources = []
|
let citationSources = []
|
||||||
const contextBlocks = []
|
const contextBlocks = []
|
||||||
|
|
||||||
const selectedLibrary = getChatLibraryForSession(targetSessionId)
|
|
||||||
|
|
||||||
if (userMsg.content && selectedLibrary?.states?.is_indexed) {
|
|
||||||
try {
|
|
||||||
const localContext = await fetchLocalLibraryContext(backendApiUrl, selectedLibrary.slug, userMsg.content, requestController.signal)
|
|
||||||
if (localContext.contextBlock) {
|
|
||||||
contextBlocks.push(localContext.contextBlock)
|
|
||||||
}
|
|
||||||
if (Array.isArray(localContext.sources)) {
|
|
||||||
citationSources.push(...localContext.sources)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
if (isAbortError(error)) throw error
|
|
||||||
console.warn('local library enrichment failed', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userMsg.content && webSearchEnabled) {
|
if (userMsg.content && webSearchEnabled) {
|
||||||
try {
|
try {
|
||||||
const searchContext = await fetchWebSearchContext({
|
const searchContext = await fetchWebSearchContext({
|
||||||
|
|||||||
Reference in New Issue
Block a user