feat: Known Endpoint, xAI (#4632)

* feat: Known Endpoint, xAI

* chore: update librechat-data-provider version to 0.7.53

* ci: name property removal

* feat: add XAI_API_KEY to example environment variables
This commit is contained in:
Danny Avila 2024-11-04 16:27:54 -05:00 committed by GitHub
parent fc41032923
commit 3428c3c647
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 22 additions and 12 deletions

View file

@ -76,6 +76,7 @@ PROXY=
# SHUTTLEAI_API_KEY=
# TOGETHERAI_API_KEY=
# UNIFY_API_KEY=
# XAI_API_KEY=
#============#
# Anthropic #

View file

@ -678,7 +678,6 @@ ${botMessage.message}
const instructionsPayload = {
role: 'system',
name: 'instructions',
content: promptPrefix,
};

View file

@ -553,7 +553,6 @@ class OpenAIClient extends BaseClient {
promptPrefix = `Instructions:\n${promptPrefix.trim()}`;
instructions = {
role: 'system',
name: 'instructions',
content: promptPrefix,
};

View file

@ -458,7 +458,6 @@ class PluginsClient extends OpenAIClient {
const instructionsPayload = {
role: 'system',
name: 'instructions',
content: promptPrefix,
};

View file

@ -446,7 +446,7 @@ describe('OpenAIClient', () => {
promptPrefix: 'Test Prefix',
});
expect(result).toHaveProperty('prompt');
const instructions = result.prompt.find((item) => item.name === 'instructions');
const instructions = result.prompt.find((item) => item.content.includes('Test Prefix'));
expect(instructions).toBeDefined();
expect(instructions.content).toContain('Test Prefix');
});
@ -476,7 +476,9 @@ describe('OpenAIClient', () => {
const result = await client.buildMessages(messages, parentMessageId, {
isChatCompletion: true,
});
const instructions = result.prompt.find((item) => item.name === 'instructions');
const instructions = result.prompt.find((item) =>
item.content.includes('Test Prefix from options'),
);
expect(instructions.content).toContain('Test Prefix from options');
});
@ -484,7 +486,7 @@ describe('OpenAIClient', () => {
const result = await client.buildMessages(messages, parentMessageId, {
isChatCompletion: true,
});
const instructions = result.prompt.find((item) => item.name === 'instructions');
const instructions = result.prompt.find((item) => item.content.includes('Test Prefix'));
expect(instructions).toBeUndefined();
});

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false" fill="currentColor" class="bg-white"><path d="m3.005 8.858 8.783 12.544h3.904L6.908 8.858zM6.905 15.825 3 21.402h3.907l1.951-2.788zM16.585 2l-6.75 9.64 1.953 2.79L20.492 2zM17.292 7.965v13.437h3.2V3.395z"></path></svg>

After

Width:  |  Height:  |  Size: 315 B

View file

@ -1,6 +1,7 @@
import { EModelEndpoint, KnownEndpoints } from 'librechat-data-provider';
import { CustomMinimalIcon } from '~/components/svg';
import { IconContext } from '~/common';
import { cn } from '~/utils';
const knownEndpointAssets = {
[KnownEndpoints.anyscale]: '/assets/anyscale.png',
@ -18,12 +19,19 @@ const knownEndpointAssets = {
[KnownEndpoints.shuttleai]: '/assets/shuttleai.png',
[KnownEndpoints['together.ai']]: '/assets/together.png',
[KnownEndpoints.unify]: '/assets/unify.webp',
[KnownEndpoints.xai]: '/assets/xai.svg',
};
const knownEndpointClasses = {
[KnownEndpoints.cohere]: {
[IconContext.landing]: 'p-2',
},
[KnownEndpoints.xai]: {
[IconContext.landing]: 'p-2',
[IconContext.menuItem]: 'bg-white',
[IconContext.message]: 'bg-white',
[IconContext.nav]: 'bg-white',
},
};
const getKnownClass = ({
@ -39,10 +47,10 @@ const getKnownClass = ({
return className;
}
const match = knownEndpointClasses[currentEndpoint]?.[context];
const match = knownEndpointClasses[currentEndpoint]?.[context] ?? '';
const defaultClass = context === IconContext.landing ? '' : className;
return match ?? defaultClass;
return cn(match, defaultClass);
};
export default function UnknownIcon({
@ -61,7 +69,6 @@ export default function UnknownIcon({
return <CustomMinimalIcon className={className} />;
}
console.log('UnknownIcon', endpoint);
const currentEndpoint = endpoint.toLowerCase();
if (iconURL) {

2
package-lock.json generated
View file

@ -36283,7 +36283,7 @@
},
"packages/data-provider": {
"name": "librechat-data-provider",
"version": "0.7.52",
"version": "0.7.53",
"license": "ISC",
"dependencies": {
"@types/js-yaml": "^4.0.9",

View file

@ -1,6 +1,6 @@
{
"name": "librechat-data-provider",
"version": "0.7.52",
"version": "0.7.53",
"description": "data services for librechat apps",
"main": "dist/index.js",
"module": "dist/index.es.js",

View file

@ -550,6 +550,7 @@ export enum KnownEndpoints {
shuttleai = 'shuttleai',
'together.ai' = 'together.ai',
unify = 'unify',
xai = 'xai',
}
export enum FetchTokenConfig {
@ -584,7 +585,8 @@ export const alternateName = {
[EModelEndpoint.anthropic]: 'Anthropic',
[EModelEndpoint.custom]: 'Custom',
[EModelEndpoint.bedrock]: 'AWS Bedrock',
ollama: 'Ollama',
[KnownEndpoints.ollama]: 'Ollama',
[KnownEndpoints.xai]: 'xAI',
};
const sharedOpenAIModels = [