diff --git a/application/app.py b/application/app.py index 357f00d3..164db166 100644 --- a/application/app.py +++ b/application/app.py @@ -136,6 +136,7 @@ def api_answer(): vectorstore = "" else: vectorstore = "" + print(vectorstore) # vectorstore = "outputs/inputs/" # loading the index and the store and the prompt template # Note if you have used other embeddings than OpenAI, you need to change the embeddings diff --git a/frontend/src/conversation/conversationApi.ts b/frontend/src/conversation/conversationApi.ts index a0575682..c7320342 100644 --- a/frontend/src/conversation/conversationApi.ts +++ b/frontend/src/conversation/conversationApi.ts @@ -13,17 +13,20 @@ export function fetchAnswerApi( namePath = '.project'; } - const docPath = - selectedDocs.name === 'default' - ? 'default' - : selectedDocs.language + - '/' + - namePath + - '/' + - selectedDocs.version + - '/' + - selectedDocs.model + - '/'; + let docPath = 'default'; + if (selectedDocs.location === 'local') { + docPath = 'local' + '/' + selectedDocs.name + '/'; + } else if (selectedDocs.location === 'remote') { + docPath = + selectedDocs.language + + '/' + + namePath + + '/' + + selectedDocs.version + + '/' + + selectedDocs.model + + '/'; + } return fetch(apiHost + '/api/answer', { method: 'POST', diff --git a/frontend/src/preferences/preferenceApi.ts b/frontend/src/preferences/preferenceApi.ts index d4d5979c..b9646a15 100644 --- a/frontend/src/preferences/preferenceApi.ts +++ b/frontend/src/preferences/preferenceApi.ts @@ -1,5 +1,6 @@ // not all properties in Doc are going to be present. Make some optional export type Doc = { + location: string; name: string; language: string; version: string; @@ -13,9 +14,10 @@ export type Doc = { //Fetches all JSON objects from the source. We only use the objects with the "model" property in SelectDocsModal.tsx. Hopefully can clean up the source file later. export async function getDocs(): Promise { try { - const response = await fetch( - 'https://d3dg1063dc54p9.cloudfront.net/combined.json', - ); + const apiHost = + import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; + + const response = await fetch(apiHost + '/api/combine'); const data = await response.json(); const docs: Doc[] = []; @@ -52,17 +54,13 @@ export function setLocalRecentDocs(doc: Doc): void { namePath = '.project'; } - const docPath = - doc.name === 'default' - ? 'default' - : doc.language + - '/' + - namePath + - '/' + - doc.version + - '/' + - doc.model + - '/'; + let docPath = 'default'; + if (doc.location === 'local') { + docPath = 'local' + '/' + doc.name + '/'; + } else if (doc.location === 'remote') { + docPath = + doc.language + '/' + namePath + '/' + doc.version + '/' + doc.model + '/'; + } const apiHost = import.meta.env.VITE_API_HOST || 'https://docsapi.arc53.com'; fetch(apiHost + '/api/docs_check', { method: 'POST', diff --git a/frontend/src/upload/Upload.tsx b/frontend/src/upload/Upload.tsx index 53f4772d..e404bd12 100644 --- a/frontend/src/upload/Upload.tsx +++ b/frontend/src/upload/Upload.tsx @@ -67,19 +67,26 @@ export default function Upload({ (progress?.percentage ?? 0) < 100 && setTimeout(() => { const apiHost = import.meta.env.VITE_API_HOST; - fetch(`${apiHost}/api/task_status}?task_id=${progress?.taskId}`) + fetch(`${apiHost}/api/task_status?task_id=${progress?.taskId}`) .then((data) => data.json()) .then((data) => { if (data.status == 'SUCCESS') { getDocs().then((data) => dispatch(setSourceDocs(data))); + setProgress( + (progress) => progress && { ...progress, percentage: 100 }, + ); + } else { + setProgress( + (progress) => + progress && { + ...progress, + percentage: data.result.current, + }, + ); } - setProgress( - (progress) => - progress && { ...progress, percentage: data.result.current }, - ); }); }, 5000); - }, []); + }, [progress, dispatch]); return (