mirror of
https://github.com/langgenius/dify.git
synced 2026-01-24 04:32:18 +08:00
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
Main CI Pipeline / Check Changed Files (push) Waiting to run
Main CI Pipeline / API Tests (push) Blocked by required conditions
Main CI Pipeline / Web Tests (push) Blocked by required conditions
Main CI Pipeline / Style Check (push) Waiting to run
Main CI Pipeline / VDB Tests (push) Blocked by required conditions
Main CI Pipeline / DB Migration Test (push) Blocked by required conditions
Check i18n Files and Create PR / check-and-update (push) Waiting to run
Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { useMutation, useQuery } from '@tanstack/react-query'
|
|
import { useInvalid } from '../use-base'
|
|
import type {
|
|
ExternalKnowledgeBaseHitTestingRequest,
|
|
ExternalKnowledgeBaseHitTestingResponse,
|
|
HitTestingRecordsRequest,
|
|
HitTestingRecordsResponse,
|
|
HitTestingRequest,
|
|
HitTestingResponse,
|
|
} from '@/models/datasets'
|
|
import { get, post } from '../base'
|
|
|
|
const NAME_SPACE = 'hit-testing'
|
|
|
|
const HitTestingRecordsKey = [NAME_SPACE, 'records']
|
|
|
|
export const useHitTestingRecords = (params: HitTestingRecordsRequest) => {
|
|
const { datasetId, page, limit } = params
|
|
return useQuery({
|
|
queryKey: [...HitTestingRecordsKey, datasetId, page, limit],
|
|
queryFn: () => get<HitTestingRecordsResponse>(`/datasets/${datasetId}/queries`, { params: { page, limit } }),
|
|
})
|
|
}
|
|
|
|
export const useInvalidateHitTestingRecords = (datasetId: string) => {
|
|
return useInvalid([...HitTestingRecordsKey, datasetId])
|
|
}
|
|
|
|
export const useHitTesting = (datasetId: string) => {
|
|
return useMutation({
|
|
mutationKey: [NAME_SPACE, 'hit-testing', datasetId],
|
|
mutationFn: (params: HitTestingRequest) => post<HitTestingResponse>(`/datasets/${datasetId}/hit-testing`, {
|
|
body: params,
|
|
}),
|
|
})
|
|
}
|
|
|
|
export const useExternalKnowledgeBaseHitTesting = (datasetId: string) => {
|
|
return useMutation({
|
|
mutationKey: [NAME_SPACE, 'external-knowledge-base-hit-testing', datasetId],
|
|
mutationFn: (params: ExternalKnowledgeBaseHitTestingRequest) => post<ExternalKnowledgeBaseHitTestingResponse>(`/datasets/${datasetId}/external-hit-testing`, {
|
|
body: params,
|
|
}),
|
|
})
|
|
}
|