mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-12-02 01:53:14 +00:00
Merge branch 'main' into feat/remote-mcp
This commit is contained in:
@@ -7,7 +7,7 @@ export function handleFetchAnswer(
|
||||
question: string,
|
||||
signal: AbortSignal,
|
||||
token: string | null,
|
||||
selectedDocs: Doc | null,
|
||||
selectedDocs: Doc[] | null,
|
||||
conversationId: string | null,
|
||||
promptId: string | null,
|
||||
chunks: string,
|
||||
@@ -52,10 +52,17 @@ export function handleFetchAnswer(
|
||||
payload.attachments = attachments;
|
||||
}
|
||||
|
||||
if (selectedDocs && 'id' in selectedDocs) {
|
||||
payload.active_docs = selectedDocs.id as string;
|
||||
if (selectedDocs && Array.isArray(selectedDocs)) {
|
||||
if (selectedDocs.length > 1) {
|
||||
// Handle multiple documents
|
||||
payload.active_docs = selectedDocs.map((doc) => doc.id!);
|
||||
payload.retriever = selectedDocs[0]?.retriever as string;
|
||||
} else if (selectedDocs.length === 1 && 'id' in selectedDocs[0]) {
|
||||
// Handle single document (backward compatibility)
|
||||
payload.active_docs = selectedDocs[0].id as string;
|
||||
payload.retriever = selectedDocs[0].retriever as string;
|
||||
}
|
||||
}
|
||||
payload.retriever = selectedDocs?.retriever as string;
|
||||
return conversationService
|
||||
.answer(payload, token, signal)
|
||||
.then((response) => {
|
||||
@@ -84,7 +91,7 @@ export function handleFetchAnswerSteaming(
|
||||
question: string,
|
||||
signal: AbortSignal,
|
||||
token: string | null,
|
||||
selectedDocs: Doc | null,
|
||||
selectedDocs: Doc[] | null,
|
||||
conversationId: string | null,
|
||||
promptId: string | null,
|
||||
chunks: string,
|
||||
@@ -112,10 +119,17 @@ export function handleFetchAnswerSteaming(
|
||||
payload.attachments = attachments;
|
||||
}
|
||||
|
||||
if (selectedDocs && 'id' in selectedDocs) {
|
||||
payload.active_docs = selectedDocs.id as string;
|
||||
if (selectedDocs && Array.isArray(selectedDocs)) {
|
||||
if (selectedDocs.length > 1) {
|
||||
// Handle multiple documents
|
||||
payload.active_docs = selectedDocs.map((doc) => doc.id!);
|
||||
payload.retriever = selectedDocs[0]?.retriever as string;
|
||||
} else if (selectedDocs.length === 1 && 'id' in selectedDocs[0]) {
|
||||
// Handle single document (backward compatibility)
|
||||
payload.active_docs = selectedDocs[0].id as string;
|
||||
payload.retriever = selectedDocs[0].retriever as string;
|
||||
}
|
||||
}
|
||||
payload.retriever = selectedDocs?.retriever as string;
|
||||
|
||||
return new Promise<Answer>((resolve, reject) => {
|
||||
conversationService
|
||||
@@ -171,7 +185,7 @@ export function handleFetchAnswerSteaming(
|
||||
export function handleSearch(
|
||||
question: string,
|
||||
token: string | null,
|
||||
selectedDocs: Doc | null,
|
||||
selectedDocs: Doc[] | null,
|
||||
conversation_id: string | null,
|
||||
chunks: string,
|
||||
token_limit: number,
|
||||
@@ -183,9 +197,17 @@ export function handleSearch(
|
||||
token_limit: token_limit,
|
||||
isNoneDoc: selectedDocs === null,
|
||||
};
|
||||
if (selectedDocs && 'id' in selectedDocs)
|
||||
payload.active_docs = selectedDocs.id as string;
|
||||
payload.retriever = selectedDocs?.retriever as string;
|
||||
if (selectedDocs && Array.isArray(selectedDocs)) {
|
||||
if (selectedDocs.length > 1) {
|
||||
// Handle multiple documents
|
||||
payload.active_docs = selectedDocs.map((doc) => doc.id!);
|
||||
payload.retriever = selectedDocs[0]?.retriever as string;
|
||||
} else if (selectedDocs.length === 1 && 'id' in selectedDocs[0]) {
|
||||
// Handle single document (backward compatibility)
|
||||
payload.active_docs = selectedDocs[0].id as string;
|
||||
payload.retriever = selectedDocs[0].retriever as string;
|
||||
}
|
||||
}
|
||||
return conversationService
|
||||
.search(payload, token)
|
||||
.then((response) => response.json())
|
||||
|
||||
@@ -54,7 +54,7 @@ export interface Query {
|
||||
|
||||
export interface RetrievalPayload {
|
||||
question: string;
|
||||
active_docs?: string;
|
||||
active_docs?: string | string[];
|
||||
retriever?: string;
|
||||
conversation_id: string | null;
|
||||
prompt_id?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user