Skip to content
Snippets Groups Projects
Commit dec98185 authored by thucpn's avatar thucpn
Browse files

refactor: getEnv -> getConfig

parent 5873267a
No related branches found
No related tags found
No related merge requests found
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
"use client"; "use client";
/** export const getConfig = (name: string) => {
* A helper function to get environment variables from the window object
* @param name - The name of the environment variable to get
* @returns The value of the environment variable
*/
export const getEnv = (name: string) => {
if (typeof window === "undefined") return undefined; if (typeof window === "undefined") return undefined;
return (window as any).LLAMAINDEX?.[name]; return (window as any).LLAMAINDEX?.[name];
}; };
"use client"; "use client";
import { ChatSection } from "@llamaindex/chat-ui"; import { ChatSection } from "@llamaindex/chat-ui";
import { useChat } from "ai/react"; import { useChat } from "ai/react";
import { getEnv } from "./env"; import { getConfig } from "./env";
export default function Page() { export default function Page() {
const handler = useChat({ api: getEnv("CHAT_API") }); const handler = useChat({ api: getConfig("CHAT_API") });
return ( return (
<div className="flex h-screen items-center justify-center"> <div className="flex h-screen items-center justify-center">
<ChatSection <ChatSection
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment