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= # SHUTTLEAI_API_KEY=
# TOGETHERAI_API_KEY= # TOGETHERAI_API_KEY=
# UNIFY_API_KEY= # UNIFY_API_KEY=
# XAI_API_KEY=
#============# #============#
# Anthropic # # Anthropic #

View file

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

View file

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

View file

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

View file

@ -446,7 +446,7 @@ describe('OpenAIClient', () => {
promptPrefix: 'Test Prefix', promptPrefix: 'Test Prefix',
}); });
expect(result).toHaveProperty('prompt'); 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).toBeDefined();
expect(instructions.content).toContain('Test Prefix'); expect(instructions.content).toContain('Test Prefix');
}); });
@ -476,7 +476,9 @@ describe('OpenAIClient', () => {
const result = await client.buildMessages(messages, parentMessageId, { const result = await client.buildMessages(messages, parentMessageId, {
isChatCompletion: true, 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'); expect(instructions.content).toContain('Test Prefix from options');
}); });
@ -484,7 +486,7 @@ describe('OpenAIClient', () => {
const result = await client.buildMessages(messages, parentMessageId, { const result = await client.buildMessages(messages, parentMessageId, {
isChatCompletion: true, 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(); 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 { EModelEndpoint, KnownEndpoints } from 'librechat-data-provider';
import { CustomMinimalIcon } from '~/components/svg'; import { CustomMinimalIcon } from '~/components/svg';
import { IconContext } from '~/common'; import { IconContext } from '~/common';
import { cn } from '~/utils';
const knownEndpointAssets = { const knownEndpointAssets = {
[KnownEndpoints.anyscale]: '/assets/anyscale.png', [KnownEndpoints.anyscale]: '/assets/anyscale.png',
@ -18,12 +19,19 @@ const knownEndpointAssets = {
[KnownEndpoints.shuttleai]: '/assets/shuttleai.png', [KnownEndpoints.shuttleai]: '/assets/shuttleai.png',
[KnownEndpoints['together.ai']]: '/assets/together.png', [KnownEndpoints['together.ai']]: '/assets/together.png',
[KnownEndpoints.unify]: '/assets/unify.webp', [KnownEndpoints.unify]: '/assets/unify.webp',
[KnownEndpoints.xai]: '/assets/xai.svg',
}; };
const knownEndpointClasses = { const knownEndpointClasses = {
[KnownEndpoints.cohere]: { [KnownEndpoints.cohere]: {
[IconContext.landing]: 'p-2', [IconContext.landing]: 'p-2',
}, },
[KnownEndpoints.xai]: {
[IconContext.landing]: 'p-2',
[IconContext.menuItem]: 'bg-white',
[IconContext.message]: 'bg-white',
[IconContext.nav]: 'bg-white',
},
}; };
const getKnownClass = ({ const getKnownClass = ({
@ -39,10 +47,10 @@ const getKnownClass = ({
return className; return className;
} }
const match = knownEndpointClasses[currentEndpoint]?.[context]; const match = knownEndpointClasses[currentEndpoint]?.[context] ?? '';
const defaultClass = context === IconContext.landing ? '' : className; const defaultClass = context === IconContext.landing ? '' : className;
return match ?? defaultClass; return cn(match, defaultClass);
}; };
export default function UnknownIcon({ export default function UnknownIcon({
@ -61,7 +69,6 @@ export default function UnknownIcon({
return <CustomMinimalIcon className={className} />; return <CustomMinimalIcon className={className} />;
} }
console.log('UnknownIcon', endpoint);
const currentEndpoint = endpoint.toLowerCase(); const currentEndpoint = endpoint.toLowerCase();
if (iconURL) { if (iconURL) {

2
package-lock.json generated
View file

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

View file

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

View file

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