Skip to content

Commit

Permalink
✨ feat: Add xAI (resolve #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Nov 7, 2024
1 parent 946ab61 commit a1544e7
Show file tree
Hide file tree
Showing 17 changed files with 205 additions and 56 deletions.
6 changes: 3 additions & 3 deletions README.md

Large diffs are not rendered by default.

24 changes: 1 addition & 23 deletions src/Grok/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
import { memo } from 'react';

import IconAvatar, { type IconAvatarProps } from '@/features/IconAvatar';

import { COLOR_PRIMARY, TITLE } from '../style';
import Mono from './Mono';

export type AvatarProps = Omit<IconAvatarProps, 'Icon'>;

const Avatar = memo<AvatarProps>(({ background, ...rest }) => {
return (
<IconAvatar
Icon={Mono}
aria-label={TITLE}
background={background || COLOR_PRIMARY}
color={'#000'}
iconMultiple={0.65}
{...rest}
/>
);
});

export default Avatar;
export { default } from '@/XAI//components/Avatar';
2 changes: 1 addition & 1 deletion src/Grok/components/Combine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Combine = memo<CombineProps>(({ ...rest }) => {
Icon={Avatar}
Text={Text}
aria-label={TITLE}
iconProps={{ shape: 'square', style: { borderRadius: 0 } }}
iconProps={{ shape: 'square' }}
spaceMultiple={SPACE_MULTIPLE}
textMultiple={TEXT_MULTIPLE}
{...rest}
Expand Down
27 changes: 1 addition & 26 deletions src/Grok/components/Mono.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
import { forwardRef } from 'react';

import type { IconType } from '@/types';

import { TITLE } from '../style';

const Icon: IconType = forwardRef(({ size = '1em', style, ...rest }, ref) => {
return (
<svg
fill="currentColor"
fillRule="evenodd"
height={size}
ref={ref}
style={{ flex: 'none', lineHeight: 1, ...style }}
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<title>{TITLE}</title>
<path d="M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z"></path>
</svg>
);
});

export default Icon;
export { default } from '@/XAI//components/Mono';
4 changes: 2 additions & 2 deletions src/Grok/components/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const Icon: IconType = forwardRef(({ size = '1em', style, ...rest }, ref) => {
height={size}
ref={ref}
style={{ flex: 'none', lineHeight: 1, ...style }}
viewBox="0 0 59 24"
viewBox="0 0 60 24"
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<title>{TITLE}</title>
<path d="M15.57 21.352c-1.254.395-2.415.594-3.483.594-2.01 0-3.78-.419-5.31-1.255-1.53-.837-2.709-1.984-3.536-3.442C2.414 15.792 2 14.155 2 12.337c0-2.123.445-3.963 1.334-5.52.89-1.556 2.09-2.748 3.603-3.576C8.449 2.414 10.103 2 11.9 2c1.085 0 2.108.13 3.07.391.96.261 1.822.608 2.588 1.04l-.855 2.401c-.57-.323-1.285-.607-2.148-.85-.863-.243-1.641-.364-2.335-.364-1.494 0-2.815.306-3.963.918a6.401 6.401 0 00-2.655 2.618c-.623 1.133-.934 2.456-.934 3.967 0 1.404.31 2.655.934 3.752a6.42 6.42 0 002.642 2.55c1.138.603 2.437.905 3.896.905.676 0 1.334-.068 1.975-.203.64-.135 1.174-.328 1.601-.58v-3.86h-3.843v-2.51h6.458v7.881c-.538.43-1.356.828-2.455 1.196l-.306.1zm10.701-9.77a6.158 6.158 0 011.668-1.08c.587-.252 1.103-.387 1.548-.405l-.107 2.51c-.8-.036-1.526.126-2.175.486-.65.36-1.156.86-1.52 1.498a4.045 4.045 0 00-.548 2.038v5.101h-2.482V10.556h2.215l.187 2.645a4.9 4.9 0 011.023-1.44l.191-.18zm5.764 1.444a5.671 5.671 0 012.189-2.146c.934-.522 1.988-.783 3.162-.783s2.22.261 3.136.783a5.559 5.559 0 012.134 2.132c.507.9.761 1.908.761 3.023 0 1.116-.253 2.128-.76 3.037a5.506 5.506 0 01-2.149 2.145c-.925.522-1.984.783-3.176.783-1.191 0-2.197-.247-3.122-.742a5.433 5.433 0 01-2.175-2.092c-.525-.9-.787-1.943-.787-3.13 0-.998.217-1.918.65-2.76l.137-.25zm2.189 4.98a3.589 3.589 0 001.28 1.403 3.31 3.31 0 001.802.513c1.032 0 1.885-.369 2.562-1.107.676-.737 1.014-1.655 1.014-2.753 0-1.097-.338-2.02-1.014-2.766-.676-.747-1.53-1.12-2.562-1.12-.676 0-1.281.175-1.815.526-.533.35-.956.823-1.267 1.417a4.12 4.12 0 00-.467 1.943c0 .614.12 1.187.357 1.718l.11.225zm18.16-3.05l4.082-3.32-1.52-1.35-5.712 4.642V2h-2.481v19.73h2.481v-4.184l1.442-1.187 3.415 5.371H57l-4.617-6.775z"></path>
<path d="M46.461 2.48h2.294v11.093l6.453-5.84h2.8l-4.933 4.614 5.466 9.173h-2.64l-4.56-7.813-2.586 2.32v5.493H46.46V2.48zM36.632 21.947c-1.049 0-1.982-.17-2.8-.507a5.75 5.75 0 01-2.08-1.44c-.569-.622-1.004-1.387-1.306-2.293-.303-.907-.454-1.92-.454-3.04s.16-2.133.48-3.04c.32-.907.774-1.68 1.36-2.32A5.85 5.85 0 0133.94 7.84c.836-.355 1.76-.533 2.773-.533 1.031 0 1.956.169 2.774.506a5.602 5.602 0 012.08 1.467c.586.622 1.03 1.378 1.333 2.267.302.889.453 1.893.453 3.013 0 1.138-.16 2.16-.48 3.067-.302.907-.746 1.68-1.333 2.32a5.826 5.826 0 01-2.107 1.493c-.835.338-1.769.507-2.8.507zm.027-1.92c.747 0 1.387-.134 1.92-.4.533-.267.969-.64 1.307-1.12.355-.48.613-1.05.773-1.707a9.6 9.6 0 00.24-2.213c0-.782-.08-1.502-.24-2.16-.16-.658-.418-1.218-.773-1.68a3.467 3.467 0 00-1.307-1.12c-.533-.267-1.173-.4-1.92-.4-.747 0-1.387.133-1.92.4a3.76 3.76 0 00-1.307 1.12c-.338.462-.586 1.022-.746 1.68a9.257 9.257 0 00-.24 2.187c0 .8.08 1.528.24 2.186.16.658.408 1.227.746 1.707s.774.853 1.307 1.12c.533.267 1.173.4 1.92.4zM21.435 7.733h2.294v2.134c.515-.765 1.12-1.351 1.813-1.76a4.287 4.287 0 012.213-.614c.48 0 .89.036 1.227.107l-.293 2.16a5.521 5.521 0 00-.534-.08 2.997 2.997 0 00-.586-.053c-.427 0-.863.08-1.307.24a3.406 3.406 0 00-1.253.746 3.945 3.945 0 00-.934 1.174c-.213.444-.32.96-.32 1.546v8.187h-2.32V7.733zM11.013 11.733h7.12v7.627a8.826 8.826 0 01-1.6 1.173c-.569.32-1.173.596-1.813.827-.622.213-1.271.373-1.947.48-.657.107-1.306.16-1.946.16-1.405 0-2.658-.222-3.76-.667a7.754 7.754 0 01-2.774-1.973c-.746-.853-1.315-1.893-1.706-3.12C2.196 14.996 2 13.591 2 12.027c0-1.6.213-3.023.64-4.267.427-1.244 1.013-2.293 1.76-3.147a7.581 7.581 0 012.72-1.946C8.169 2.222 9.316 2 10.56 2c1.067 0 2.009.133 2.827.4.817.249 1.51.613 2.08 1.093a5.912 5.912 0 011.44 1.734c.373.657.657 1.395.853 2.213l-2.373.4a6.753 6.753 0 00-.587-1.52 3.71 3.71 0 00-.907-1.173c-.373-.338-.835-.596-1.386-.774-.534-.177-1.183-.266-1.947-.266-.996 0-1.867.195-2.613.586a5.051 5.051 0 00-1.867 1.6c-.498.694-.88 1.53-1.147 2.507-.249.96-.373 2.027-.373 3.2s.124 2.249.373 3.227c.25.96.631 1.786 1.147 2.48a5.385 5.385 0 001.973 1.6c.783.373 1.707.56 2.774.56.96 0 1.857-.116 2.693-.347a6.842 6.842 0 002.293-1.093v-4.56h-4.8v-2.134z"></path>
</svg>
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/Grok/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
nav: Components
group: Model
title: Grok
title: Grok (xAI)
atomId: Grok
description: https://grok.x.ai
---
Expand Down
23 changes: 23 additions & 0 deletions src/XAI/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { memo } from 'react';

import IconAvatar, { type IconAvatarProps } from '@/features/IconAvatar';

import { COLOR_PRIMARY, TITLE } from '../style';
import Mono from './Mono';

export type AvatarProps = Omit<IconAvatarProps, 'Icon'>;

const Avatar = memo<AvatarProps>(({ background, ...rest }) => {
return (
<IconAvatar
Icon={Mono}
aria-label={TITLE}
background={background || COLOR_PRIMARY}
color={'#000'}
iconMultiple={0.65}
{...rest}
/>
);
});

export default Avatar;
25 changes: 25 additions & 0 deletions src/XAI/components/Combine.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { memo } from 'react';

import IconCombine, { type IconCombineProps } from '@/features/IconCombine';

import { SPACE_MULTIPLE, TEXT_MULTIPLE, TITLE } from '../style';
import Avatar from './Avatar';
import Text from './Text';

export type CombineProps = Omit<IconCombineProps, 'Icon' | 'Text'>;

const Combine = memo<CombineProps>(({ ...rest }) => {
return (
<IconCombine
Icon={Avatar}
Text={Text}
aria-label={TITLE}
iconProps={{ shape: 'square' }}
spaceMultiple={SPACE_MULTIPLE}
textMultiple={TEXT_MULTIPLE}
{...rest}
/>
);
});

export default Combine;
26 changes: 26 additions & 0 deletions src/XAI/components/Mono.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { forwardRef } from 'react';

import type { IconType } from '@/types';

import { TITLE } from '../style';

const Icon: IconType = forwardRef(({ size = '1em', style, ...rest }, ref) => {
return (
<svg
fill="currentColor"
fillRule="evenodd"
height={size}
ref={ref}
style={{ flex: 'none', lineHeight: 1, ...style }}
viewBox="0 0 24 24"
width={size}
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<title>{TITLE}</title>
<path d="M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z"></path>
</svg>
);
});

export default Icon;
25 changes: 25 additions & 0 deletions src/XAI/components/Text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { forwardRef } from 'react';

import type { IconType } from '@/types';

import { TITLE } from '../style';

const Icon: IconType = forwardRef(({ size = '1em', style, ...rest }, ref) => {
return (
<svg
fill="currentColor"
fillRule="evenodd"
height={size}
ref={ref}
style={{ flex: 'none', lineHeight: 1, ...style }}
viewBox="0 0 41 24"
xmlns="http://www.w3.org/2000/svg"
{...rest}
>
<title>{TITLE}</title>
<path d="M36.867 2h2.577v20h-2.577V2zM23.875 2h2.717l7.759 20H31.55l-2.101-5.574h-8.571L18.777 22h-2.69l7.788-20zm4.79 12.185l-3.53-9.272-3.473 9.272h7.003zM7.35 14.381L2.504 7.518h2.857l3.446 5.126 3.585-5.126h2.605l-4.762 6.835L15.501 22h-2.829l-3.977-5.854L4.689 22H2l5.35-7.619z"></path>
</svg>
);
});

export default Icon;
66 changes: 66 additions & 0 deletions src/XAI/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
nav: Components
group: Provider
title: xAI
atomId: XAI
description: https://x.ai
---

## Icons

```tsx
import { XAI } from '@lobehub/icons';
import { Flexbox } from 'react-layout-kit';

export default () => <XAI size={64} />;
```

## Text

```tsx
import { XAI } from '@lobehub/icons';

export default () => <XAI.Text size={48} />;
```

## Combine

```tsx
import { XAI } from '@lobehub/icons';
import { Flexbox } from 'react-layout-kit';

export default () => (
<Flexbox gap={16}>
<XAI.Combine size={64} />
</Flexbox>
);
```

## Avatars

```tsx
import { XAI } from '@lobehub/icons';
import { Flexbox } from 'react-layout-kit';

export default () => (
<Flexbox gap={16} horizontal>
<XAI.Avatar size={64} />
<XAI.Avatar size={64} shape={'square'} />
</Flexbox>
);
```

## Colors

```tsx
import { XAI } from '@lobehub/icons';
import { Flexbox } from 'react-layout-kit';

import ColorPreview from '../components/ColorPreview';

export default () => (
<Flexbox gap={16} horizontal>
<ColorPreview color={XAI.colorPrimary} />
</Flexbox>
);
```
21 changes: 21 additions & 0 deletions src/XAI/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Avatar from './components/Avatar';
import Combine from './components/Combine';
import Mono from './components/Mono';
import Text from './components/Text';
import { COLOR_PRIMARY, TITLE } from './style';

export type CompoundedIcon = typeof Mono & {
Avatar: typeof Avatar;
Combine: typeof Combine;
Text: typeof Text;
colorPrimary: string;
title: string;
};

const Icons = Mono as CompoundedIcon;
Icons.Text = Text;
Icons.Combine = Combine;
Icons.Avatar = Avatar;
Icons.colorPrimary = COLOR_PRIMARY;
Icons.title = TITLE;
export default Icons;
4 changes: 4 additions & 0 deletions src/XAI/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const TITLE = 'Grok';
export const TEXT_MULTIPLE = 0.75;
export const SPACE_MULTIPLE = 0.25;
export const COLOR_PRIMARY = '#fff';
2 changes: 2 additions & 0 deletions src/features/modelConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import Flux from '@/Flux';
import Gemini from '@/Gemini';
import Gemma from '@/Gemma';
import Google from '@/Google';
import Grok from '@/Grok';
import Hunyuan from '@/Hunyuan';
import InternLM from '@/InternLM';
import LLaVA from '@/LLaVA';
Expand Down Expand Up @@ -130,6 +131,7 @@ export const modelMappings: ModelMapping[] = [
{ Icon: PaLM, keywords: ['palm'] },
{ Icon: Google, keywords: ['google'] },
{ Icon: SenseNova, keywords: ['SenseChat'] },
{ Icon: Grok, keywords: ['^grok-'] },
{
Icon: Spark,
keywords: [
Expand Down
2 changes: 2 additions & 0 deletions src/features/providerConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Stepfun from '@/Stepfun';
import Together from '@/Together';
import Upstage from '@/Upstage';
import Wenxin from '@/Wenxin';
import XAI from '@/XAI';
import ZeroOne from '@/ZeroOne';
import Zhipu from '@/Zhipu';
import type { IconType } from '@/types';
Expand Down Expand Up @@ -164,4 +165,5 @@ export const providerMappings: ProviderMapping[] = [
{ Icon: SenseNova, combineMultiple: 0.95, keywords: [ModelProvider.SenseNova] },
{ Icon: HuggingFace, combineMultiple: 1.16, keywords: [ModelProvider.HuggingFace] },
{ Icon: LmStudio, keywords: [ModelProvider.LmStudio] },
{ Icon: XAI, combineMultiple: 0.85, keywords: [ModelProvider.XAI] },
];
1 change: 1 addition & 0 deletions src/features/providerEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export enum ModelProvider {
TogetherAI = 'togetherai',
Upstage = 'upstage',
Wenxin = 'wenxin',
XAI = 'xai',
ZeroOne = 'zeroone',
ZhiPu = 'zhipu',
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export { default as VertexAI, type CompoundedIcon as VertexAIProps } from './Ver
export { default as Vllm, type CompoundedIcon as VllmProps } from './Vllm';
export { default as Wenxin, type CompoundedIcon as WenxinProps } from './Wenxin';
export { default as WorkersAI, type CompoundedIcon as WorkersAIProps } from './WorkersAI';
export { default as XAI, type CompoundedIcon as XAIProps } from './XAI';
export { default as Yi, type CompoundedIcon as YiProps } from './Yi';
export { default as Zeabur, type CompoundedIcon as ZeaburProps } from './Zeabur';
export { default as ZeroOne, type CompoundedIcon as ZeroOneProps } from './ZeroOne';
Expand Down

0 comments on commit a1544e7

Please sign in to comment.