Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update crawl and upload endpoints #1142

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/routes/crawl_routes.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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),
):
Expand Down
3 changes: 2 additions & 1 deletion backend/routes/upload_routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Optional
from uuid import UUID

from auth import AuthBearer, get_current_user
Expand Down Expand Up @@ -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),
):
Expand Down
14 changes: 9 additions & 5 deletions frontend/lib/api/crawl/crawl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
13 changes: 8 additions & 5 deletions frontend/lib/api/upload/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Loading