mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
/ai/models route
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ChatRequest, ChatResponse } from "@sprint/shared";
|
||||
import type { ChatRequest, ChatResponse, ModelsResponse } from "@sprint/shared";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { apiClient } from "@/lib/server";
|
||||
|
||||
@@ -13,3 +13,15 @@ export function useChatMutation() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useModels() {
|
||||
return useMutation<ModelsResponse, Error>({
|
||||
mutationKey: ["ai", "models"],
|
||||
mutationFn: async () => {
|
||||
const { data, error } = await apiClient.aiModels();
|
||||
if (error) throw new Error(error);
|
||||
if (!data) throw new Error("failed to get models");
|
||||
return data as ModelsResponse;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user