MCPcopy
hub / github.com/janhq/jan / Index

Function Index

web-app/src/routes/index.tsx:38–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36})
37
38function Index() {
39 const { t } = useTranslation()
40 const { providers } = useModelProvider()
41 const search = useSearch({ from: route.home as any })
42 const threadModel = search.threadModel
43 const { setCurrentThreadId } = useThreads()
44 useTools()
45
46 // Conditional to check if there are any valid providers
47 // required min 1 api_key or 1 model in llama.cpp or jan provider
48 // Custom providers (not in predefinedProviders) don't require api_key but need models
49 const hasValidProviders = providers.some((provider) => {
50 const isPredefinedProvider = predefinedProviders.some(
51 (p) => p.provider === provider.provider
52 )
53
54 // Custom providers don't need API key validation but must have models
55 if (!isPredefinedProvider) {
56 return provider.models.length > 0
57 }
58
59 // Predefined providers need either API key or models (for llamacpp/jan)
60 return (
61 providerHasRemoteApiKeys(provider) ||
62 (provider.provider === 'llamacpp' && provider.models.length) ||
63 (provider.provider === 'jan' && provider.models.length)
64 )
65 })
66
67 useEffect(() => {
68 setCurrentThreadId(undefined)
69 }, [setCurrentThreadId])
70
71 if (!hasValidProviders) {
72 return <SetupScreen />
73 }
74
75 return (
76 <div className="flex h-full flex-col justify-center">
77 <HeaderPage>
78 <div className="flex items-center gap-2 w-full">
79 <DropdownModelProvider model={threadModel} />
80 </div>
81 </HeaderPage>
82 <div
83 className={cn(
84 'h-full overflow-y-auto inline-flex flex-col gap-2 justify-center px-3'
85 )}
86 >
87 <div
88 className={cn(
89 'mx-auto w-full md:w-4/5 xl:w-4/6 -mt-20',
90 )}
91 >
92 <div className={cn('text-center mb-4')}>
93 <h1
94 className={cn(
95 'text-2xl mt-2 font-studio font-medium',

Callers

nothing calls this directly

Calls 5

useTranslationFunction · 0.90
useToolsFunction · 0.90
providerHasRemoteApiKeysFunction · 0.90
cnFunction · 0.90
tFunction · 0.85

Tested by

no test coverage detected