mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-12-01 09:33:14 +00:00
added support for multi select sources
This commit is contained in:
@@ -90,9 +90,9 @@ export function getLocalApiKey(): string | null {
|
||||
return key;
|
||||
}
|
||||
|
||||
export function getLocalRecentDocs(): string | null {
|
||||
const doc = localStorage.getItem('DocsGPTRecentDocs');
|
||||
return doc;
|
||||
export function getLocalRecentDocs(): Doc[] | null {
|
||||
const docs = localStorage.getItem('DocsGPTRecentDocs');
|
||||
return docs ? JSON.parse(docs) as Doc[] : null;
|
||||
}
|
||||
|
||||
export function getLocalPrompt(): string | null {
|
||||
@@ -108,19 +108,20 @@ export function setLocalPrompt(prompt: string): void {
|
||||
localStorage.setItem('DocsGPTPrompt', prompt);
|
||||
}
|
||||
|
||||
export function setLocalRecentDocs(doc: Doc | null): void {
|
||||
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(doc));
|
||||
export function setLocalRecentDocs(docs: Doc[] | null): void {
|
||||
if (docs && docs.length > 0) {
|
||||
localStorage.setItem('DocsGPTRecentDocs', JSON.stringify(docs));
|
||||
|
||||
let docPath = 'default';
|
||||
if (doc?.type === 'local') {
|
||||
docPath = 'local' + '/' + doc.name + '/';
|
||||
docs.forEach((doc) => {
|
||||
let docPath = 'default';
|
||||
if (doc.type === 'local') {
|
||||
docPath = 'local' + '/' + doc.name + '/';
|
||||
}
|
||||
userService
|
||||
.checkDocs({ docs: docPath }, null)
|
||||
.then((response) => response.json());
|
||||
});
|
||||
} else {
|
||||
localStorage.removeItem('DocsGPTRecentDocs');
|
||||
}
|
||||
userService
|
||||
.checkDocs(
|
||||
{
|
||||
docs: docPath,
|
||||
},
|
||||
null,
|
||||
)
|
||||
.then((response) => response.json());
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface Preference {
|
||||
prompt: { name: string; id: string; type: string };
|
||||
chunks: string;
|
||||
token_limit: number;
|
||||
selectedDocs: Doc | null;
|
||||
selectedDocs: Doc[] | null;
|
||||
sourceDocs: Doc[] | null;
|
||||
conversations: {
|
||||
data: { name: string; id: string }[] | null;
|
||||
@@ -34,7 +34,7 @@ const initialState: Preference = {
|
||||
prompt: { name: 'default', id: 'default', type: 'public' },
|
||||
chunks: '2',
|
||||
token_limit: 2000,
|
||||
selectedDocs: {
|
||||
selectedDocs: [{
|
||||
id: 'default',
|
||||
name: 'default',
|
||||
type: 'remote',
|
||||
@@ -42,7 +42,7 @@ const initialState: Preference = {
|
||||
docLink: 'default',
|
||||
model: 'openai_text-embedding-ada-002',
|
||||
retriever: 'classic',
|
||||
} as Doc,
|
||||
}] as Doc[],
|
||||
sourceDocs: null,
|
||||
conversations: {
|
||||
data: null,
|
||||
|
||||
Reference in New Issue
Block a user