Skip to content

Commit

Permalink
trunk fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-uiuc committed Jan 2, 2025
1 parent abc4909 commit 2a1a4e9
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 132 deletions.
256 changes: 128 additions & 128 deletions src/components/UIUC-Components/api-inputs/LLMsApiKeyInputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,145 +192,145 @@ const NewModelDropdown: React.FC<
state,
showWebLLmModels,
}) => {
const allModels = [
...(models.Ollama || []).map((model: any) => ({
...model,
provider: ProviderNames.Ollama,
group: 'NCSA Hosted Models, 100% free',
})),
...(models.OpenAI || []).map((model: any) => ({
...model,
provider: ProviderNames.OpenAI,
group: 'OpenAI',
})),
...(models.Anthropic || []).map((model: any) => ({
...model,
provider: ProviderNames.Anthropic,
group: 'Anthropic',
})),
...(models.WebLLM && models.WebLLM.length > 0
? models.WebLLM.map((model: any) => ({
const allModels = [
...(models.Ollama || []).map((model: any) => ({
...model,
provider: ProviderNames.Ollama,
group: 'NCSA Hosted Models, 100% free',
})),
...(models.OpenAI || []).map((model: any) => ({
...model,
provider: ProviderNames.OpenAI,
group: 'OpenAI',
})),
...(models.Anthropic || []).map((model: any) => ({
...model,
provider: ProviderNames.Anthropic,
group: 'Anthropic',
})),
...(models.WebLLM && models.WebLLM.length > 0
? models.WebLLM.map((model: any) => ({
...model,
provider: ProviderNames.WebLLM,
group: 'Local in Browser LLMs, runs on your device',
}))
: []),
]
const selectedModel = allModels.find((model) => model.id === value)
: []),
]
const selectedModel = allModels.find((model) => model.id === value)

return (
<>
<div
tabIndex={0}
className="relative flex w-full flex-col items-start px-2"
>
<Select
className="menu z-[50] w-full"
size="md"
placeholder="Select a model"
searchable
value={value}
onChange={async (modelId: any) => {
if (state.webLLMModelIdLoading.isLoading) {
setLoadingModelId(modelId)
console.log('model id', modelId)
console.log('loading model id', loadingModelId)
console.log('model is loading', state.webLLMModelIdLoading.id)
} else if (!state.webLLMModelIdLoading.isLoading) {
setLoadingModelId(null)
}
await onChange(modelId!)
}}
data={allModels.map((model: any) => ({
value: model.id,
label: model.name,
downloadSize: model.downloadSize,
modelId: model.id,
selectedModelId: value,
modelType: model.provider,
group: model.group,
vram_required_MB: model.vram_required_MB,
}))}
itemComponent={(props: any) => (
<ModelItem
{...props}
loadingModelId={loadingModelId}
setLoadingModelId={setLoadingModelId}
showWebLLmModels={showWebLLmModels}
/>
)}
maxDropdownHeight={480}
rightSectionWidth="auto"
icon={
selectedModel ? (
<Image
src={getModelLogo(selectedModel.provider)}
alt={`${selectedModel.provider} logo`}
width={20}
height={20}
style={{ marginLeft: '4px', borderRadius: '4px' }}
/>
) : null
return (
<>
<div
tabIndex={0}
className="relative flex w-full flex-col items-start px-2"
>
<Select
className="menu z-[50] w-full"
size="md"
placeholder="Select a model"
searchable
value={value}
onChange={async (modelId: any) => {
if (state.webLLMModelIdLoading.isLoading) {
setLoadingModelId(modelId)
console.log('model id', modelId)
console.log('loading model id', loadingModelId)
console.log('model is loading', state.webLLMModelIdLoading.id)
} else if (!state.webLLMModelIdLoading.isLoading) {
setLoadingModelId(null)
}
rightSection={<IconChevronDown size="1rem" />}
classNames={{
root: 'w-full',
wrapper: 'w-full',
input: `${montserrat_paragraph.variable} font-montserratParagraph ${isSmallScreen ? 'text-xs' : 'text-sm'} w-full`,
rightSection: 'pointer-events-none',
item: `${montserrat_paragraph.variable} font-montserratParagraph ${isSmallScreen ? 'text-xs' : 'text-sm'}`,
}}
styles={(theme: {
radius: { md: any }
shadows: { xs: any }
white: any
}) => ({
input: {
backgroundColor: 'rgb(107, 33, 168)',
border: 'none',
// color: theme.white,
// borderRadius: theme.radius.md,
// width: '24rem',
// [`@media (max-width: 960px)`]: {
// width: '17rem', // Smaller width for small screens
// },
},
dropdown: {
backgroundColor: '#1d1f33',
border: '1px solid rgba(42,42,120,1)',
borderRadius: theme.radius.md,
marginTop: '2px',
boxShadow: theme.shadows.xs,
width: '100%',
maxWidth: '100%',
position: 'absolute',
},
item: {
backgroundColor: '#1d1f33',
borderRadius: theme.radius.md,
margin: '2px',
'&[data-selected]': {
'&': {
backgroundColor: 'transparent',
},
'&:hover': {
backgroundColor: 'rgb(107, 33, 168)',
color: theme.white,
},
await onChange(modelId!)
}}
data={allModels.map((model: any) => ({
value: model.id,
label: model.name,
downloadSize: model.downloadSize,
modelId: model.id,
selectedModelId: value,
modelType: model.provider,
group: model.group,
vram_required_MB: model.vram_required_MB,
}))}
itemComponent={(props: any) => (
<ModelItem
{...props}
loadingModelId={loadingModelId}
setLoadingModelId={setLoadingModelId}
showWebLLmModels={showWebLLmModels}
/>
)}
maxDropdownHeight={480}
rightSectionWidth="auto"
icon={
selectedModel ? (
<Image
src={getModelLogo(selectedModel.provider)}
alt={`${selectedModel.provider} logo`}
width={20}
height={20}
style={{ marginLeft: '4px', borderRadius: '4px' }}
/>
) : null
}
rightSection={<IconChevronDown size="1rem" />}
classNames={{
root: 'w-full',
wrapper: 'w-full',
input: `${montserrat_paragraph.variable} font-montserratParagraph ${isSmallScreen ? 'text-xs' : 'text-sm'} w-full`,
rightSection: 'pointer-events-none',
item: `${montserrat_paragraph.variable} font-montserratParagraph ${isSmallScreen ? 'text-xs' : 'text-sm'}`,
}}
styles={(theme: {
radius: { md: any }
shadows: { xs: any }
white: any
}) => ({
input: {
backgroundColor: 'rgb(107, 33, 168)',
border: 'none',
// color: theme.white,
// borderRadius: theme.radius.md,
// width: '24rem',
// [`@media (max-width: 960px)`]: {
// width: '17rem', // Smaller width for small screens
// },
},
dropdown: {
backgroundColor: '#1d1f33',
border: '1px solid rgba(42,42,120,1)',
borderRadius: theme.radius.md,
marginTop: '2px',
boxShadow: theme.shadows.xs,
width: '100%',
maxWidth: '100%',
position: 'absolute',
},
item: {
backgroundColor: '#1d1f33',
borderRadius: theme.radius.md,
margin: '2px',
'&[data-selected]': {
'&': {
backgroundColor: 'transparent',
},
'&[data-hovered]': {
'&:hover': {
backgroundColor: 'rgb(107, 33, 168)',
color: theme.white,
},
},
})}
dropdownPosition="bottom"
withinPortal
/>
</div>
</>
)
}
'&[data-hovered]': {
backgroundColor: 'rgb(107, 33, 168)',
color: theme.white,
},
},
})}
dropdownPosition="bottom"
withinPortal
/>
</div>
</>
)
}

export default function APIKeyInputForm() {
const projectName = GetCurrentPageName()
Expand Down
1 change: 0 additions & 1 deletion src/utils/apiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { CoreMessage } from 'ai'

// Configuration for runtime environment


export const getBaseUrl = () => {
if (typeof window !== 'undefined') return '' // browser should use relative url
if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}` // SSR should use vercel url
Expand Down
2 changes: 1 addition & 1 deletion src/utils/modelProviders/NCSAHosted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const getNCSAHostedModels = async (
return ncsaHostedProvider as NCSAHostedProvider
}

// ✅ HARD CODE ONLY ONE MODEL
// ✅ HARD CODE ONLY ONE MODEL
const ollamaModels = [NCSAHostedModels['llama3.1:8b-instruct-fp16']]

// ❌ DYNAMICALLY show all HOT AND LOADED models
Expand Down
4 changes: 2 additions & 2 deletions src/utils/streamProcessing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,12 +768,12 @@ export async function handleImageContent(
)

if (imgDescIndex !== -1) {
; (message.content as Content[])[imgDescIndex] = {
;(message.content as Content[])[imgDescIndex] = {
type: 'text',
text: `Image description: ${imgDesc}`,
}
} else {
; (message.content as Content[]).push({
;(message.content as Content[]).push({
type: 'text',
text: `Image description: ${imgDesc}`,
})
Expand Down

0 comments on commit 2a1a4e9

Please sign in to comment.