tabby/ee/tabby-ui/lib/hooks/use-health.tsx

26 lines
529 B
TypeScript
Raw Normal View History

'use client'
import useSWR, { SWRResponse } from 'swr'
import fetcher from '@/lib/tabby/fetcher'
import { useSession } from '../tabby/auth'
export interface HealthInfo {
2023-10-30 21:47:38 +00:00
device: 'metal' | 'cpu' | 'cuda'
model?: string
chat_model?: string
cpu_info: string
cpu_count: number
cuda_devices: string[]
version: {
build_date: string
git_describe: string
}
}
export function useHealth(): SWRResponse<HealthInfo> {
const { data } = useSession()
return useSWR(['/v1/health', data?.accessToken], fetcher)
}