fix: update crawl and upload endpoints (#1142)

This commit is contained in:
Mamadou DICKO 2023-09-08 11:03:14 +02:00 committed by GitHub
parent 7e1e13fab5
commit 72659709a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 12 deletions

View File

@ -1,6 +1,7 @@
import os
import shutil
from tempfile import SpooledTemporaryFile
from typing import Optional
from uuid import UUID
from auth import AuthBearer, get_current_user
@ -33,7 +34,7 @@ async def crawl_endpoint(
request: Request,
crawl_website: CrawlWebsite,
brain_id: UUID = Query(..., description="The ID of the brain"),
chat_id: UUID = Query(..., description="The ID of the chat"),
chat_id: Optional[UUID] = Query(None, description="The ID of the chat"),
enable_summarization: bool = False,
current_user: UserIdentity = Depends(get_current_user),
):

View File

@ -1,4 +1,5 @@
import os
from typing import Optional
from uuid import UUID
from auth import AuthBearer, get_current_user
@ -36,7 +37,7 @@ async def upload_file(
request: Request,
uploadFile: UploadFile,
brain_id: UUID = Query(..., description="The ID of the brain"),
chat_id: UUID = Query(..., description="The ID of the chat"),
chat_id: Optional[UUID] = Query(None, description="The ID of the chat"),
enable_summarization: bool = False,
current_user: UserIdentity = Depends(get_current_user),
):

View File

@ -22,8 +22,12 @@ export type CrawlResponse = {
export const crawlWebsiteUrl = async (
props: CrawlInputProps,
axiosInstance: AxiosInstance
): Promise<CrawlResponse> =>
axiosInstance.post(
`/crawl?brain_id=${props.brainId}&chat_id=${props.chat_id ?? ""}`,
props.config
);
): Promise<CrawlResponse> => {
let crawlUrl = `/crawl?brain_id=${props.brainId}`;
if (props.chat_id !== undefined) {
crawlUrl = crawlUrl.concat(`&chat_id=${props.chat_id}`);
}
return axiosInstance.post(crawlUrl, props.config);
};

View File

@ -16,8 +16,11 @@ export type UploadInputProps = {
export const uploadFile = async (
props: UploadInputProps,
axiosInstance: AxiosInstance
): Promise<UploadResponse> =>
axiosInstance.post(
`/upload?brain_id=${props.brainId}&chat_id=${props.chat_id ?? ""}`,
props.formData
);
): Promise<UploadResponse> => {
let uploadUrl = `/upload?brain_id=${props.brainId}`;
if (props.chat_id !== undefined) {
uploadUrl = uploadUrl.concat(`&chat_id=${props.chat_id}`);
}
return axiosInstance.post(uploadUrl, props.formData);
};