mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
opencode chat frontend implementation
This commit is contained in:
15
packages/frontend/src/lib/query/hooks/chat.ts
Normal file
15
packages/frontend/src/lib/query/hooks/chat.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { ChatRequest, ChatResponse } from "@sprint/shared";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { apiClient } from "@/lib/server";
|
||||
|
||||
export function useChatMutation() {
|
||||
return useMutation<ChatResponse, Error, ChatRequest>({
|
||||
mutationKey: ["ai", "chat"],
|
||||
mutationFn: async (input) => {
|
||||
const { data, error } = await apiClient.aiChat({ query: input });
|
||||
if (error) throw new Error(error);
|
||||
if (!data) throw new Error("failed to get chat response");
|
||||
return data as ChatResponse;
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "@/lib/query/hooks/chat";
|
||||
export * from "@/lib/query/hooks/derived";
|
||||
export * from "@/lib/query/hooks/issue-comments";
|
||||
export * from "@/lib/query/hooks/issues";
|
||||
|
||||
Reference in New Issue
Block a user