feat: support firecrawl frontend code (#5226)

This commit is contained in:
Joel 2024-06-14 22:02:41 +08:00 • committed by GitHub
commit 28554350de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
51 changed files with 1979 additions and 145 deletions

View file

@ -152,6 +152,10 @@ export const syncDocument: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId,
return get<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/notion/sync`)
}
export const syncWebsite: Fetcher<CommonResponse, CommonDocReq> = ({ datasetId, documentId }) => {
return get<CommonResponse>(`/datasets/${datasetId}/documents/${documentId}/website-sync`)
}
export const preImportNotionPages: Fetcher<{ notion_info: DataSourceNotionWorkspace[] }, { url: string; datasetId?: string }> = ({ url, datasetId }) => {
return get<{ notion_info: DataSourceNotionWorkspace[] }>(url, { params: { dataset_id: datasetId } })
}
@ -227,6 +231,37 @@ export const fetchDatasetApiBaseUrl: Fetcher<{ api_base_url: string }, string> =
return get<{ api_base_url: string }>(url)
}
export const fetchFirecrawlApiKey = () => {
return get<CommonResponse>('api-key-auth/data-source')
}
export const createFirecrawlApiKey: Fetcher<CommonResponse, Record<string, any>> = (body) => {
return post<CommonResponse>('api-key-auth/data-source/binding', { body })
}
export const removeFirecrawlApiKey: Fetcher<CommonResponse, string> = (id: string) => {
return del<CommonResponse>(`api-key-auth/data-source/${id}`)
}
export const createFirecrawlTask: Fetcher<CommonResponse, Record<string, any>> = (body) => {
return post<CommonResponse>('website/crawl', {
body: {
...body,
provider: 'firecrawl',
},
})
}
export const checkFirecrawlTaskStatus: Fetcher<CommonResponse, string> = (jobId: string) => {
return get<CommonResponse>(`website/crawl/status/${jobId}`, {
params: {
provider: 'firecrawl',
},
}, {
silent: true,
})
}
type FileTypesRes = {
allowed_extensions: string[]
}