Download src/hooks/query/use-conversation-hooks.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/query/use-conversation-hooks.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/hooks/query/use-conversation-hooks.ts
-
curl -L -o use-conversation-hooks.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/query/use-conversation-hooks.ts
1.01 kB
| import { useQuery } from "@tanstack/react-query"; | |
| import AgentServerConversationService from "#/api/conversation-service/agent-server-conversation-service.api"; | |
| import { useConversationId } from "../use-conversation-id"; | |
| import { AgentState } from "#/types/agent-state"; | |
| import { useAgentState } from "#/hooks/use-agent-state"; | |
| export const useConversationHooks = () => { | |
| const { conversationId } = useConversationId(); | |
| const { curAgentState } = useAgentState(); | |
| return useQuery({ | |
| queryKey: ["conversation", conversationId, "hooks"], | |
| queryFn: async () => { | |
| if (!conversationId) { | |
| throw new Error("No conversation ID provided"); | |
| } | |
| const { hooks } = | |
| await AgentServerConversationService.getHooks(conversationId); | |
| return hooks; | |
| }, | |
| enabled: | |
| !!conversationId && | |
| curAgentState !== AgentState.LOADING && | |
| curAgentState !== AgentState.INIT, | |
| staleTime: 1000 * 60 * 5, // 5 minutes | |
| gcTime: 1000 * 60 * 15, // 15 minutes | |
| }); | |
| }; | |