Skip to content

Commit

Permalink
❎ feat: Known Endpoint, xAI (#4632)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
danny-avila authored Nov 4, 2024
1 parent fc41032 commit 3428c3c
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ PROXY=
# SHUTTLEAI_API_KEY=
# TOGETHERAI_API_KEY=
# UNIFY_API_KEY=
# XAI_API_KEY=

#============#
# Anthropic #
Expand Down
1 change: 0 additions & 1 deletion api/app/clients/ChatGPTClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ ${botMessage.message}

const instructionsPayload = {
role: 'system',
name: 'instructions',
content: promptPrefix,
};

Expand Down
1 change: 0 additions & 1 deletion api/app/clients/OpenAIClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ class OpenAIClient extends BaseClient {
promptPrefix = `Instructions:\n${promptPrefix.trim()}`;
instructions = {
role: 'system',
name: 'instructions',
content: promptPrefix,
};

Expand Down
1 change: 0 additions & 1 deletion api/app/clients/PluginsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ class PluginsClient extends OpenAIClient {

const instructionsPayload = {
role: 'system',
name: 'instructions',
content: promptPrefix,
};

Expand Down
8 changes: 5 additions & 3 deletions api/app/clients/specs/OpenAIClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down Expand Up @@ -476,15 +476,17 @@ 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');
});

it('should handle case when neither promptPrefix argument nor options.promptPrefix is set', async () => {
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();
});

Expand Down
1 change: 1 addition & 0 deletions client/public/assets/xai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions client/src/components/Chat/Menus/Endpoints/UnknownIcon.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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 = ({
Expand All @@ -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({
Expand All @@ -61,7 +69,6 @@ export default function UnknownIcon({
return <CustomMinimalIcon className={className} />;
}

console.log('UnknownIcon', endpoint);
const currentEndpoint = endpoint.toLowerCase();

if (iconURL) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/data-provider/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion packages/data-provider/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export enum KnownEndpoints {
shuttleai = 'shuttleai',
'together.ai' = 'together.ai',
unify = 'unify',
xai = 'xai',
}

export enum FetchTokenConfig {
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 3428c3c

Please sign in to comment.