Skip to content

Commit af6356a

Browse files
committed
πŸš€ feat: GPT-4.5, Anthropic Tool Header, and OpenAPI Ref Resolution (#6118)
* πŸ”§ refactor: Update settings to use 'as const' for improved type safety and make gpt-4o-mini default model (cheapest) * πŸ“– docs: Update README to reflect support for GPT-4.5 in image analysis feature * πŸ”§ refactor: Update model handling to use default settings and improve encoding logic * πŸ”§ refactor: Enhance model version extraction logic for improved compatibility with future GPT and omni models * feat: GPT-4.5 tx/token update, vision support * fix: $ref resolution logic in OpenAPI handling * feat: add new 'anthropic-beta' header for Claude 3.7 to include token-efficient tools; ref: https://docs.anthropic.com/en/docs/build-with-claude/tool-use/token-efficient-tool-use
1 parent 076f99f commit af6356a

File tree

15 files changed

+323
-139
lines changed

15 files changed

+323
-139
lines changed

β€Ž.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ GOOGLE_KEY=user_provided
175175
#============#
176176

177177
OPENAI_API_KEY=user_provided
178-
# OPENAI_MODELS=o1,o1-mini,o1-preview,gpt-4o,chatgpt-4o-latest,gpt-4o-mini,gpt-3.5-turbo-0125,gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k
178+
# OPENAI_MODELS=o1,o1-mini,o1-preview,gpt-4o,gpt-4.5-preview,chatgpt-4o-latest,gpt-4o-mini,gpt-3.5-turbo-0125,gpt-3.5-turbo-0301,gpt-3.5-turbo,gpt-4,gpt-4-0613,gpt-4-vision-preview,gpt-3.5-turbo-0613,gpt-3.5-turbo-16k-0613,gpt-4-0125-preview,gpt-4-turbo-preview,gpt-4-1106-preview,gpt-3.5-turbo-1106,gpt-3.5-turbo-instruct,gpt-3.5-turbo-instruct-0914,gpt-3.5-turbo-16k
179179

180180
DEBUG_OPENAI=false
181181

β€ŽREADME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
- [Fork Messages & Conversations](https://www.librechat.ai/docs/features/fork) for Advanced Context control
8282

8383
- πŸ’¬ **Multimodal & File Interactions**:
84-
- Upload and analyze images with Claude 3, GPT-4o, o1, Llama-Vision, and Gemini πŸ“Έ
84+
- Upload and analyze images with Claude 3, GPT-4.5, GPT-4o, o1, Llama-Vision, and Gemini πŸ“Έ
8585
- Chat with Files using Custom Endpoints, OpenAI, Azure, Anthropic, AWS Bedrock, & Google πŸ—ƒοΈ
8686

8787
- 🌎 **Multilingual UI**:

β€Žapi/app/clients/OpenAIClient.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ class OpenAIClient extends BaseClient {
298298
}
299299

300300
getEncoding() {
301-
return this.model?.includes('gpt-4o') ? 'o200k_base' : 'cl100k_base';
301+
return this.modelOptions?.model && /gpt-4[^-\s]/.test(this.modelOptions.model)
302+
? 'o200k_base'
303+
: 'cl100k_base';
302304
}
303305

304306
/**
@@ -605,7 +607,7 @@ class OpenAIClient extends BaseClient {
605607
}
606608

607609
initializeLLM({
608-
model = 'gpt-4o-mini',
610+
model = openAISettings.model.default,
609611
modelName,
610612
temperature = 0.2,
611613
max_tokens,
@@ -706,7 +708,7 @@ class OpenAIClient extends BaseClient {
706708

707709
const { OPENAI_TITLE_MODEL } = process.env ?? {};
708710

709-
let model = this.options.titleModel ?? OPENAI_TITLE_MODEL ?? 'gpt-4o-mini';
711+
let model = this.options.titleModel ?? OPENAI_TITLE_MODEL ?? openAISettings.model.default;
710712
if (model === Constants.CURRENT_MODEL) {
711713
model = this.modelOptions.model;
712714
}
@@ -899,7 +901,7 @@ ${convo}
899901
let prompt;
900902

901903
// TODO: remove the gpt fallback and make it specific to endpoint
902-
const { OPENAI_SUMMARY_MODEL = 'gpt-4o-mini' } = process.env ?? {};
904+
const { OPENAI_SUMMARY_MODEL = openAISettings.model.default } = process.env ?? {};
903905
let model = this.options.summaryModel ?? OPENAI_SUMMARY_MODEL;
904906
if (model === Constants.CURRENT_MODEL) {
905907
model = this.modelOptions.model;

β€Žapi/models/tx.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const tokenValues = Object.assign(
7979
'o1-mini': { prompt: 1.1, completion: 4.4 },
8080
'o1-preview': { prompt: 15, completion: 60 },
8181
o1: { prompt: 15, completion: 60 },
82+
'gpt-4.5': { prompt: 75, completion: 150 },
8283
'gpt-4o-mini': { prompt: 0.15, completion: 0.6 },
8384
'gpt-4o': { prompt: 2.5, completion: 10 },
8485
'gpt-4o-2024-05-13': { prompt: 5, completion: 15 },
@@ -167,6 +168,8 @@ const getValueKey = (model, endpoint) => {
167168
return 'o1-mini';
168169
} else if (modelName.includes('o1')) {
169170
return 'o1';
171+
} else if (modelName.includes('gpt-4.5')) {
172+
return 'gpt-4.5';
170173
} else if (modelName.includes('gpt-4o-2024-05-13')) {
171174
return 'gpt-4o-2024-05-13';
172175
} else if (modelName.includes('gpt-4o-mini')) {

β€Žapi/models/tx.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ describe('getValueKey', () => {
5050
expect(getValueKey('gpt-4-0125')).toBe('gpt-4-1106');
5151
});
5252

53+
it('should return "gpt-4.5" for model type of "gpt-4.5"', () => {
54+
expect(getValueKey('gpt-4.5-preview')).toBe('gpt-4.5');
55+
expect(getValueKey('gpt-4.5-2024-08-06')).toBe('gpt-4.5');
56+
expect(getValueKey('gpt-4.5-2024-08-06-0718')).toBe('gpt-4.5');
57+
expect(getValueKey('openai/gpt-4.5')).toBe('gpt-4.5');
58+
expect(getValueKey('openai/gpt-4.5-2024-08-06')).toBe('gpt-4.5');
59+
expect(getValueKey('gpt-4.5-turbo')).toBe('gpt-4.5');
60+
expect(getValueKey('gpt-4.5-0125')).toBe('gpt-4.5');
61+
});
62+
5363
it('should return "gpt-4o" for model type of "gpt-4o"', () => {
5464
expect(getValueKey('gpt-4o-2024-08-06')).toBe('gpt-4o');
5565
expect(getValueKey('gpt-4o-2024-08-06-0718')).toBe('gpt-4o');

β€Žapi/server/services/Endpoints/anthropic/helpers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ function getClaudeHeaders(model, supportsCacheControl) {
4848
};
4949
} else if (/claude-3[-.]7/.test(model)) {
5050
return {
51-
'anthropic-beta': 'output-128k-2025-02-19,prompt-caching-2024-07-31',
51+
'anthropic-beta':
52+
'token-efficient-tools-2025-02-19,output-128k-2025-02-19,prompt-caching-2024-07-31',
5253
};
5354
} else {
5455
return {

β€Žapi/utils/tokens.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const openAIModels = {
1313
'gpt-4-32k-0613': 32758, // -10 from max
1414
'gpt-4-1106': 127500, // -500 from max
1515
'gpt-4-0125': 127500, // -500 from max
16+
'gpt-4.5': 127500, // -500 from max
1617
'gpt-4o': 127500, // -500 from max
1718
'gpt-4o-mini': 127500, // -500 from max
1819
'gpt-4o-2024-05-13': 127500, // -500 from max

β€Žapi/utils/tokens.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ describe('getModelMaxTokens', () => {
103103
);
104104
});
105105

106+
test('should return correct tokens for gpt-4.5 matches', () => {
107+
expect(getModelMaxTokens('gpt-4.5')).toBe(maxTokensMap[EModelEndpoint.openAI]['gpt-4.5']);
108+
expect(getModelMaxTokens('gpt-4.5-preview')).toBe(
109+
maxTokensMap[EModelEndpoint.openAI]['gpt-4.5'],
110+
);
111+
expect(getModelMaxTokens('openai/gpt-4.5-preview')).toBe(
112+
maxTokensMap[EModelEndpoint.openAI]['gpt-4.5'],
113+
);
114+
});
115+
106116
test('should return correct tokens for Anthropic models', () => {
107117
const models = [
108118
'claude-2.1',

β€Žpackage-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackages/data-provider/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "librechat-data-provider",
3-
"version": "0.7.6993",
3+
"version": "0.7.6994",
44
"description": "data services for librechat apps",
55
"main": "dist/index.js",
66
"module": "dist/index.es.js",

0 commit comments

Comments
Β (0)