mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-23 11:19:42 +00:00
nextauth
# What does this PR do? ## Test Plan
This commit is contained in:
parent
83c89265e0
commit
464b96cb09
23 changed files with 577 additions and 81 deletions
24
llama_stack/ui/hooks/use-auth-client.ts
Normal file
24
llama_stack/ui/hooks/use-auth-client.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { useSession } from "next-auth/react";
|
||||
import { useMemo } from "react";
|
||||
import LlamaStackClient from "llama-stack-client";
|
||||
|
||||
export function useAuthClient() {
|
||||
const { data: session } = useSession();
|
||||
|
||||
const client = useMemo(() => {
|
||||
const clientHostname =
|
||||
typeof window !== "undefined" ? window.location.origin : "";
|
||||
|
||||
const options: any = {
|
||||
baseURL: `${clientHostname}/api`,
|
||||
};
|
||||
|
||||
if (session?.accessToken) {
|
||||
options.apiKey = session.accessToken;
|
||||
}
|
||||
|
||||
return new LlamaStackClient(options);
|
||||
}, [session?.accessToken]);
|
||||
|
||||
return client;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue