mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
🧠 feat: Cohere support as Custom Endpoint (#2328)
* chore: bump cohere-ai, fix firebase vulnerabilities by going down versions * feat: cohere rates and context windows * feat(createCoherePayload): transform openai payload for cohere compatibility * feat: cohere backend support * refactor(UnknownIcon): optimize icon render and add cohere * docs: add cohere to Compatible AI Endpoints * Update ai_endpoints.md
This commit is contained in:
parent
daa5f43ac6
commit
cd7f3a51e1
18 changed files with 1007 additions and 622 deletions
|
|
@ -1,5 +1,44 @@
|
|||
import { EModelEndpoint, KnownEndpoints } from 'librechat-data-provider';
|
||||
import { CustomMinimalIcon } from '~/components/svg';
|
||||
import { IconContext } from '~/common';
|
||||
|
||||
const knownEndpointAssets = {
|
||||
[KnownEndpoints.mistral]: '/assets/mistral.png',
|
||||
[KnownEndpoints.openrouter]: '/assets/openrouter.png',
|
||||
[KnownEndpoints.groq]: '/assets/groq.png',
|
||||
[KnownEndpoints.shuttleai]: '/assets/shuttleai.png',
|
||||
[KnownEndpoints.anyscale]: '/assets/anyscale.png',
|
||||
[KnownEndpoints.fireworks]: '/assets/fireworks.png',
|
||||
[KnownEndpoints.ollama]: '/assets/ollama.png',
|
||||
[KnownEndpoints.perplexity]: '/assets/perplexity.png',
|
||||
[KnownEndpoints['together.ai']]: '/assets/together.png',
|
||||
[KnownEndpoints.cohere]: '/assets/cohere.png',
|
||||
};
|
||||
|
||||
const knownEndpointClasses = {
|
||||
[KnownEndpoints.cohere]: {
|
||||
[IconContext.landing]: 'p-2',
|
||||
},
|
||||
};
|
||||
|
||||
const getKnownClass = ({
|
||||
currentEndpoint,
|
||||
context = '',
|
||||
className,
|
||||
}: {
|
||||
currentEndpoint: string;
|
||||
context?: string;
|
||||
className: string;
|
||||
}) => {
|
||||
if (currentEndpoint === KnownEndpoints.openrouter) {
|
||||
return className;
|
||||
}
|
||||
|
||||
const match = knownEndpointClasses[currentEndpoint]?.[context];
|
||||
const defaultClass = context === IconContext.landing ? '' : className;
|
||||
|
||||
return match ?? defaultClass;
|
||||
};
|
||||
|
||||
export default function UnknownIcon({
|
||||
className = '',
|
||||
|
|
@ -20,73 +59,23 @@ export default function UnknownIcon({
|
|||
|
||||
if (iconURL) {
|
||||
return <img className={className} src={iconURL} alt={`${endpoint} Icon`} />;
|
||||
} else if (currentEndpoint === KnownEndpoints.mistral) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/mistral.png"
|
||||
alt="Mistral AI Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints.openrouter) {
|
||||
return <img className={className} src="/assets/openrouter.png" alt="OpenRouter Icon" />;
|
||||
} else if (currentEndpoint === KnownEndpoints.groq) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/groq.png"
|
||||
alt="Groq Cloud Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints.shuttleai) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/shuttleai.png"
|
||||
alt="ShuttleAI Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints.anyscale) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/anyscale.png"
|
||||
alt="Anyscale Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints.fireworks) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/fireworks.png"
|
||||
alt="Fireworks Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints.ollama) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/ollama.png"
|
||||
alt="Ollama Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints.perplexity) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/perplexity.png"
|
||||
alt="Perplexity Icon"
|
||||
/>
|
||||
);
|
||||
} else if (currentEndpoint === KnownEndpoints['together.ai']) {
|
||||
return (
|
||||
<img
|
||||
className={context === 'landing' ? '' : className}
|
||||
src="/assets/together.png"
|
||||
alt="together.ai Icon"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <CustomMinimalIcon className={className} />;
|
||||
const assetPath = knownEndpointAssets[currentEndpoint];
|
||||
|
||||
if (!assetPath) {
|
||||
return <CustomMinimalIcon className={className} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<img
|
||||
className={getKnownClass({
|
||||
currentEndpoint,
|
||||
context: context,
|
||||
className,
|
||||
})}
|
||||
src={assetPath}
|
||||
alt={`${currentEndpoint} Icon`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue