Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from danny-avila:main #2

Merged
merged 68 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d59b621
🪨 feat: AWS Bedrock support (#3935)
danny-avila Sep 9, 2024
748b41e
🔒 feat: RBAC for Multi-Convo Feature (#3964)
danny-avila Sep 9, 2024
0148b9b
🔒 refactor: Apply interface settings to all Roles (#3967)
danny-avila Sep 10, 2024
341e086
🛠️ fix: Completion Edge Cases & Improve Error Handling UX (#3968)
danny-avila Sep 10, 2024
1a1e685
🪨 fix: Minor AWS Bedrock/Misc. Improvements (#3974)
danny-avila Sep 10, 2024
d6c0121
⌨️ a11y(Settings): Improved Keyboard Navigation & Consistent Styling …
berry-13 Sep 10, 2024
0209955
✨ v0.7.5-rc2 (#3976)
danny-avila Sep 10, 2024
35a89bf
🔐 style: update auth and loading screen (#3875)
berry-13 Sep 11, 2024
07e5531
⚙️ fix: Ensure Azure AI Search TOP is a number (#3891)
s-diez Sep 11, 2024
aea01f0
🚀 feat: Banner (#3952)
ohneda Sep 11, 2024
c3dc03b
🔐 fix: token not using webcrypto (#4005)
berry-13 Sep 12, 2024
9a393be
🪨 fix: Formatting Edge Case Handling for Bedrock Messages (#4016)
danny-avila Sep 12, 2024
45b4283
🚀 feat: o1 (#4019)
danny-avila Sep 12, 2024
e293ff6
🪨 feat: AWS Bedrock Default Credentials Chain (#4038)
danny-avila Sep 13, 2024
4ef5ae6
💡 style: switched to Ariakit's tooltip (#3748)
berry-13 Sep 13, 2024
c792e32
🍪 fix: input validation for `lang` cookie (#4024)
DanielAlt Sep 13, 2024
f1ae267
🪙 fix: usage check for reasoning_tokens
danny-avila Sep 13, 2024
ab82966
🔐 feat: Enhance Bedrock Credential Handling (#4051)
danny-avila Sep 14, 2024
fc887ba
📁 feat: Add C# Support for Native File Search (#4058)
danny-avila Sep 15, 2024
ebdbfe8
🛠️ fix: Chrome App Crash on Endpoint Selection in Edit Preset Dialog …
danny-avila Sep 17, 2024
8dc5b32
📊 refactor: use Parameters from Side Panel for OpenAI, Anthropic, and…
danny-avila Sep 18, 2024
5f28682
🔧 fix: OpenAIClient Response Handling for Legacy `/v1/completions` (#…
danny-avila Sep 19, 2024
3ea2d90
🛠️ fix: `getStreamUsage` Method in OpenAIClient (#4133)
danny-avila Sep 19, 2024
33f80cd
🤖 ci: Configure Dependabot for Security Updates (#4134)
danny-avila Sep 19, 2024
486db57
🤖 ci: Configure Dependabot for Security Updates (#4134)
danny-avila Sep 19, 2024
fd056d2
🤖 ci: Dependabot for Security Updates (#4134)
danny-avila Sep 19, 2024
f734133
🤖 ci: Dependabot for Security Updates (#4134)
danny-avila Sep 19, 2024
94d1afe
🛡️ chore: address several npm vulnerabilities (#4151)
danny-avila Sep 20, 2024
d096c28
👐 a11y: New Chat button - focus, mobile label, collapsed sidebar labe…
Tanvez Sep 20, 2024
42b7373
🎨 fix: Terms and Conditions Modal Styling (#4169)
danny-avila Sep 20, 2024
be44caa
🖋️ feat: Add option to render User Messages as Markdown (#4170)
danny-avila Sep 21, 2024
44458d3
🔖 fix: URI Encoding for Bookmarks (#4172)
danny-avila Sep 21, 2024
c1c13a6
🗂️ fix: Optimize Conversation Grouping and Sorting (#4173)
danny-avila Sep 21, 2024
561650d
🐛 fix(analytics): prevent multiple GTM initializations (#4174)
riya-amemiya Sep 21, 2024
b0a48fd
📧 feat: LDAP Authentication Enhancement for Email Handling (#4177)
danny-avila Sep 21, 2024
eba2c9a
📅 fix: Conversation grouping and labeling for prior years (#4180)
danny-avila Sep 21, 2024
2d62eca
👐 style: Improve a11y/theming for Settings Dialog, Dropdown Menus; fi…
berry-13 Sep 22, 2024
4328a25
🧹 fix: Resolve Unarchive Conversation Bug, Archive Pagination (#4189)
danny-avila Sep 22, 2024
17e5934
📎 feat: Attachment Handling for `v1/completions` (#4205)
danny-avila Sep 23, 2024
321260e
🔄 refactor: Apply Config Preset for Model Spec Enforcement (#4214)
danny-avila Sep 24, 2024
6f498ee
🏷️ fix: Ensure modelLabel Field Usage for ModelSpecs/GPTPlugins (#4224)
danny-avila Sep 24, 2024
ba1014a
🏷️ fix: Ensure modelLabel Field Usage for ModelSpecs pt. 2 (#4225)
danny-avila Sep 24, 2024
9e371d6
🧹 chore: bump `vite-plugin-pwa` to `^0.20.5`, and use `overrides` to …
danny-avila Sep 24, 2024
f33e75e
🏷️ fix: Ensure `modelLabel` Field Usage for ModelSpecs (custom/openAI…
danny-avila Sep 24, 2024
ad74350
🚧 chore: merge latest dev build (#4288)
danny-avila Sep 30, 2024
2ce8647
👷 refactor(removeNullishValues): allow empty strings configured in pa…
danny-avila Sep 30, 2024
2ca257d
⚙️ fix: minor issues related to agents (#4297)
danny-avila Oct 1, 2024
ee5b96a
🔖 fix: bookmark error using CosmosDB - Added `index` to position fiel…
bijucyborg Oct 3, 2024
77bcb80
🛠️ fix: Remove `expiresAt` field when setting expiry to "never" (#4294)
normunds-wipo Oct 3, 2024
cb0b69e
🪖 refactor: Helm chart release workflow (#4311)
pranshu-m Oct 3, 2024
104341e
🖼️ fix: Prevent Empty Avatar Source (#4321)
danny-avila Oct 3, 2024
519df46
🪨 feat: RAG API Support for AWS Bedrock (#4322)
danny-avila Oct 3, 2024
5da7766
💬 fix: adjust regex in ModelService to recognize o1 models
juwalter Oct 7, 2024
bdc2fd3
🔨 fix(ToolCall): Check output string type before performing `.toLower…
hanna-daoud Oct 8, 2024
873e047
🧠 feat: Implement O1 Model Support for Max Tokens Handling (#4376)
danny-avila Oct 10, 2024
2846779
🔨 fix(AzureOpenAI): o1 model, `stream` parameter check (#4381)
ABHIJITH-EA Oct 10, 2024
bab0152
🤖 feat: Enhance Assistant Model Handling for Model Specs (#4390)
danny-avila Oct 11, 2024
bf5b87e
🪙 feat: Update token value for gpt-4o (#4387)
hongkai-neu Oct 11, 2024
ef11800
✨ feat: Add `GOOGLE_LOC` environment variable (#4395)
berry-13 Oct 15, 2024
c54a570
🕒 feat: Add 5-second timeout for Fetching Model Lists (#4423)
danny-avila Oct 15, 2024
0870acd
📦 chore: npm package audit (#4424)
danny-avila Oct 16, 2024
65888c2
⬆️ feat: Cancel chat file uploads; fix: Assistant uploads (#4433)
danny-avila Oct 16, 2024
b85c620
🤖 fix: Minor Assistants Issues (#4436)
danny-avila Oct 16, 2024
f3e2bd0
🐋 chore: remove Docker version syntax as its no longer (#4375)
matsubo Oct 19, 2024
20fb7f0
🔃 refactor: rename all server endpoints to use same file names (#4364)
adrianfagerland Oct 19, 2024
8f3de7d
🎨 refactor: UI stlye (#4438)
berry-13 Oct 19, 2024
e25c16c
🖼️ feat: Add dat.gui to Artifacts UI libs (#4344)
lx-0 Oct 19, 2024
ecf5699
🧪 chore: raise max temperature to 2 for OpenAI/Custom Endpoints
danny-avila Oct 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 0 additions & 2 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
app:
build:
Expand Down
23 changes: 23 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ ANTHROPIC_API_KEY=user_provided
BINGAI_TOKEN=user_provided
# BINGAI_HOST=https://cn.bing.com

#=================#
# AWS Bedrock #
#=================#

# BEDROCK_AWS_DEFAULT_REGION=us-east-1 # A default region must be provided
# BEDROCK_AWS_ACCESS_KEY_ID=someAccessKey
# BEDROCK_AWS_SECRET_ACCESS_KEY=someSecretAccessKey

# Note: This example list is not meant to be exhaustive. If omitted, all known, supported model IDs will be included for you.
# BEDROCK_AWS_MODELS=anthropic.claude-3-5-sonnet-20240620-v1:0,meta.llama3-1-8b-instruct-v1:0

# See all Bedrock model IDs here: https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html#model-ids-arns

# Notes on specific models:
# The following models are not support due to not supporting streaming:
# ai21.j2-mid-v1

# The following models are not support due to not supporting conversation history:
# ai21.j2-ultra-v1, cohere.command-text-v14, cohere.command-light-text-v14

#============#
# Google #
#============#
Expand All @@ -126,6 +146,8 @@ GOOGLE_KEY=user_provided

# GOOGLE_TITLE_MODEL=gemini-pro

# GOOGLE_LOC=us-central1

# Google Safety Settings
# NOTE: These settings apply to both Vertex AI and Gemini API (AI Studio)
#
Expand Down Expand Up @@ -392,6 +414,7 @@ LDAP_CA_CERT_PATH=
# LDAP_LOGIN_USES_USERNAME=true
# LDAP_ID=
# LDAP_USERNAME=
# LDAP_EMAIL=
# LDAP_FULL_NAME=

#========================#
Expand Down
47 changes: 0 additions & 47 deletions .github/dependabot.yml

This file was deleted.

6 changes: 2 additions & 4 deletions .github/workflows/helmcharts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ jobs:
- name: Install Helm
uses: azure/setup-helm@v4
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: helmchart
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v0.7.5-rc1
# v0.7.5-rc2

# Base node image
FROM node:20-alpine AS node
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.multi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile.multi
# v0.7.5-rc1
# v0.7.5-rc2

# Base for all builds
FROM node:20-alpine AS base
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@

- 🖥️ UI matching ChatGPT, including Dark mode, Streaming, and latest updates
- 🤖 AI model selection:
- OpenAI, Azure OpenAI, BingAI, ChatGPT, Google Vertex AI, Anthropic (Claude), Plugins, Assistants API (including Azure Assistants)
- Anthropic (Claude), AWS Bedrock, OpenAI, Azure OpenAI, BingAI, ChatGPT, Google Vertex AI, Plugins, Assistants API (including Azure Assistants)
- ✅ Compatible across both **[Remote & Local AI services](https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints):**
- groq, Ollama, Cohere, Mistral AI, Apple MLX, koboldcpp, OpenRouter, together.ai, Perplexity, ShuttleAI, and more
- 🪄 Generative UI with [Code Artifacts](https://youtu.be/GfTj7O4gmd0?si=WJbdnemZpJzBrJo3)
- 🪄 Generative UI with **[Code Artifacts](https://youtu.be/GfTj7O4gmd0?si=WJbdnemZpJzBrJo3)**
- Create React, HTML code, and Mermaid diagrams right in chat
- 💾 Create, Save, & Share Custom Presets
- 🔀 Switch between AI Endpoints and Presets, mid-chat
Expand Down
38 changes: 22 additions & 16 deletions api/app/clients/AnthropicClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const {
parseParamFromPrompt,
createContextHandlers,
} = require('./prompts');
const { getModelMaxTokens, getModelMaxOutputTokens, matchModelName } = require('~/utils');
const { spendTokens, spendStructuredTokens } = require('~/models/spendTokens');
const { getModelMaxTokens, matchModelName } = require('~/utils');
const { sleep } = require('~/server/utils');
const BaseClient = require('./BaseClient');
const { logger } = require('~/config');
Expand Down Expand Up @@ -64,6 +64,12 @@ class AnthropicClient extends BaseClient {
/** Whether or not the model supports Prompt Caching
* @type {boolean} */
this.supportsCacheControl;
/** The key for the usage object's input tokens
* @type {string} */
this.inputTokensKey = 'input_tokens';
/** The key for the usage object's output tokens
* @type {string} */
this.outputTokensKey = 'output_tokens';
}

setOptions(options) {
Expand Down Expand Up @@ -114,7 +120,14 @@ class AnthropicClient extends BaseClient {
this.options.maxContextTokens ??
getModelMaxTokens(this.modelOptions.model, EModelEndpoint.anthropic) ??
100000;
this.maxResponseTokens = this.modelOptions.maxOutputTokens || 1500;
this.maxResponseTokens =
this.modelOptions.maxOutputTokens ??
getModelMaxOutputTokens(
this.modelOptions.model,
this.options.endpointType ?? this.options.endpoint,
this.options.endpointTokenConfig,
) ??
1500;
this.maxPromptTokens =
this.options.maxPromptTokens || this.maxContextTokens - this.maxResponseTokens;

Expand All @@ -138,17 +151,6 @@ class AnthropicClient extends BaseClient {
this.endToken = '';
this.gptEncoder = this.constructor.getTokenizer('cl100k_base');

if (!this.modelOptions.stop) {
const stopTokens = [this.startToken];
if (this.endToken && this.endToken !== this.startToken) {
stopTokens.push(this.endToken);
}
stopTokens.push(`${this.userLabel}`);
stopTokens.push('<|diff_marker|>');

this.modelOptions.stop = stopTokens;
}

return this;
}

Expand Down Expand Up @@ -200,15 +202,15 @@ class AnthropicClient extends BaseClient {
}

/**
* Calculates the correct token count for the current message based on the token count map and API usage.
* Calculates the correct token count for the current user message based on the token count map and API usage.
* Edge case: If the calculation results in a negative value, it returns the original estimate.
* If revisiting a conversation with a chat history entirely composed of token estimates,
* the cumulative token count going forward should become more accurate as the conversation progresses.
* @param {Object} params - The parameters for the calculation.
* @param {Record<string, number>} params.tokenCountMap - A map of message IDs to their token counts.
* @param {string} params.currentMessageId - The ID of the current message to calculate.
* @param {AnthropicStreamUsage} params.usage - The usage object returned by the API.
* @returns {number} The correct token count for the current message.
* @returns {number} The correct token count for the current user message.
*/
calculateCurrentTokenCount({ tokenCountMap, currentMessageId, usage }) {
const originalEstimate = tokenCountMap[currentMessageId] || 0;
Expand Down Expand Up @@ -680,7 +682,11 @@ class AnthropicClient extends BaseClient {
*/
checkPromptCacheSupport(modelName) {
const modelMatch = matchModelName(modelName, EModelEndpoint.anthropic);
if (modelMatch === 'claude-3-5-sonnet' || modelMatch === 'claude-3-haiku') {
if (
modelMatch === 'claude-3-5-sonnet' ||
modelMatch === 'claude-3-haiku' ||
modelMatch === 'claude-3-opus'
) {
return true;
}
return false;
Expand Down
42 changes: 37 additions & 5 deletions api/app/clients/BaseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const crypto = require('crypto');
const fetch = require('node-fetch');
const {
supportsBalanceCheck,
isAgentsEndpoint,
isParamEndpoint,
ErrorTypes,
Constants,
CacheKeys,
Expand Down Expand Up @@ -40,6 +42,14 @@ class BaseClient {
this.conversationId;
/** @type {string} */
this.responseMessageId;
/** @type {TAttachment[]} */
this.attachments;
/** The key for the usage object's input tokens
* @type {string} */
this.inputTokensKey = 'prompt_tokens';
/** The key for the usage object's output tokens
* @type {string} */
this.outputTokensKey = 'completion_tokens';
}

setOptions() {
Expand All @@ -66,6 +76,17 @@ class BaseClient {
throw new Error('Subclasses attempted to call summarizeMessages without implementing it');
}

/**
* @returns {string}
*/
getResponseModel() {
if (isAgentsEndpoint(this.options.endpoint) && this.options.agent && this.options.agent.id) {
return this.options.agent.id;
}

return this.modelOptions.model;
}

/**
* Abstract method to get the token count for a message. Subclasses must implement this method.
* @param {TMessage} responseMessage
Expand Down Expand Up @@ -217,6 +238,7 @@ class BaseClient {
userMessage,
conversationId,
responseMessageId,
sender: this.sender,
});
}

Expand Down Expand Up @@ -548,6 +570,7 @@ class BaseClient {
});
}

/** @type {string|string[]|undefined} */
const completion = await this.sendCompletion(payload, opts);
this.abortController.requestCompleted = true;

Expand All @@ -557,7 +580,7 @@ class BaseClient {
parentMessageId: userMessage.messageId,
isCreatedByUser: false,
isEdited,
model: this.modelOptions.model,
model: this.getResponseModel(),
sender: this.sender,
promptTokens,
iconURL: this.options.iconURL,
Expand All @@ -567,9 +590,14 @@ class BaseClient {

if (typeof completion === 'string') {
responseMessage.text = addSpaceIfNeeded(generation) + completion;
} else if (completion) {
} else if (
Array.isArray(completion) &&
isParamEndpoint(this.options.endpoint, this.options.endpointType)
) {
responseMessage.text = '';
responseMessage.content = completion;
} else if (Array.isArray(completion)) {
responseMessage.text = addSpaceIfNeeded(generation) + completion.join('');
}

if (
Expand All @@ -587,8 +615,8 @@ class BaseClient {
* @type {StreamUsage | null} */
const usage = this.getStreamUsage != null ? this.getStreamUsage() : null;

if (usage != null && Number(usage.output_tokens) > 0) {
responseMessage.tokenCount = usage.output_tokens;
if (usage != null && Number(usage[this.outputTokensKey]) > 0) {
responseMessage.tokenCount = usage[this.outputTokensKey];
completionTokens = responseMessage.tokenCount;
await this.updateUserMessageTokenCount({ usage, tokenCountMap, userMessage, opts });
} else {
Expand All @@ -603,6 +631,10 @@ class BaseClient {
await this.userMessagePromise;
}

if (this.artifactPromises) {
responseMessage.attachments = (await Promise.all(this.artifactPromises)).filter((a) => a);
}

this.responsePromise = this.saveMessageToDatabase(responseMessage, saveOptions, user);
const messageCache = getLogStores(CacheKeys.MESSAGES);
messageCache.set(
Expand Down Expand Up @@ -638,7 +670,7 @@ class BaseClient {
/** @type {boolean} */
const shouldUpdateCount =
this.calculateCurrentTokenCount != null &&
Number(usage.input_tokens) > 0 &&
Number(usage[this.inputTokensKey]) > 0 &&
(this.options.resendFiles ||
(!this.options.resendFiles && !this.options.attachments?.length)) &&
!this.options.promptPrefix;
Expand Down
Loading