Spaces:
Configuration error
Configuration error
Download frontend/src/hooks/query/use-list-files.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 997 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/query/use-list-files.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/hooks/query/use-list-files.ts
-
curl -L -o use-list-files.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/query/use-list-files.ts
997 Bytes
| import { useQuery } from "@tanstack/react-query"; | |
| import { useSelector } from "react-redux"; | |
| import OpenHands from "#/api/open-hands"; | |
| import { useConversation } from "#/context/conversation-context"; | |
| import { RootState } from "#/store"; | |
| import { RUNTIME_INACTIVE_STATES } from "#/types/agent-state"; | |
| interface UseListFilesConfig { | |
| path?: string; | |
| enabled?: boolean; | |
| } | |
| const DEFAULT_CONFIG: UseListFilesConfig = { | |
| enabled: true, | |
| }; | |
| export const useListFiles = (config: UseListFilesConfig = DEFAULT_CONFIG) => { | |
| const { conversationId } = useConversation(); | |
| const { curAgentState } = useSelector((state: RootState) => state.agent); | |
| const isActive = !RUNTIME_INACTIVE_STATES.includes(curAgentState); | |
| return useQuery({ | |
| queryKey: ["files", conversationId, config?.path], | |
| queryFn: () => OpenHands.getFiles(conversationId, config?.path), | |
| enabled: !!(isActive && config?.enabled), | |
| staleTime: 1000 * 60 * 5, // 5 minutes | |
| gcTime: 1000 * 60 * 15, // 15 minutes | |
| }); | |
| }; | |