mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-12 11:26:07 +03:00
34 lines
768 B
TypeScript
34 lines
768 B
TypeScript
import { AxiosInstance } from "axios";
|
|
import { UUID } from "crypto";
|
|
|
|
import { ToastData } from "@/lib/components/ui/Toast/domain/types";
|
|
|
|
export type CrawlInputProps = {
|
|
brainId: UUID;
|
|
chat_id?: UUID;
|
|
config: {
|
|
url: string;
|
|
js: boolean;
|
|
depth: number;
|
|
max_pages: number;
|
|
max_time: number;
|
|
};
|
|
};
|
|
|
|
export type CrawlResponse = {
|
|
data: { type: ToastData["variant"]; message: ToastData["text"] };
|
|
};
|
|
|
|
export const crawlWebsiteUrl = async (
|
|
props: CrawlInputProps,
|
|
axiosInstance: AxiosInstance
|
|
): 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);
|
|
};
|