Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.2 KB
Raw Blame
import { memo } from 'react';
import type { ProviderId } from 'librechat-data-provider';
import type { NamedExoticComponent } from 'react';
import type { JSX } from 'react/jsx-runtime';
import { getProviderIconDef } from './registry';
import { pxToRem } from '../../utils/theme';
import { cn } from '../../utils';

export interface ProviderIconProps {
  provider?: ProviderId | null;
  model?: string | null;
  size?: number;
  className?: string;
}

function ProviderIconComponent({
  provider,
  model,
  size = 20,
  className,
}: ProviderIconProps): JSX.Element {
  const def = getProviderIconDef(provider, model);
  const classes = cn(
    def.mono === true && className == null ? 'text-text-primary' : '',
    def.className,
    className,
  );

  const { Component } = def.art;
  return (
    <span
      role="img"
      aria-label={def.label}
      style={{ width: pxToRem(size), height: pxToRem(size) }}
      className={cn('inline-flex items-center justify-center', classes)}
    >
      <Component size={size} className={cn(classes, 'h-full w-full')} />
    </span>
  );
}

export const ProviderIcon: NamedExoticComponent<ProviderIconProps> = memo(ProviderIconComponent);