Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
a63758a
refactor: pass model in message edit payload, use encoder in standalo…
danny-avila Sep 19, 2023
715509a
feat: add summaryBuffer helper
danny-avila Sep 19, 2023
e90bfe2
refactor(api/messages): use new countTokens helper and add auth middl…
danny-avila Sep 19, 2023
0aed8cc
wip: ConversationSummaryBufferMemory
danny-avila Sep 19, 2023
51d7e1b
refactor: move pre-generation helpers to prompts dir
danny-avila Sep 20, 2023
c627b26
chore: remove console log
danny-avila Sep 20, 2023
6a138eb
chore: remove test as payload will no longer carry tokenCount
danny-avila Sep 20, 2023
c4105ac
chore: update getMessagesWithinTokenLimit JSDoc
danny-avila Sep 22, 2023
a417dc8
refactor: optimize getMessagesForConversation and also break on summa…
danny-avila Sep 22, 2023
4669cdc
refactor(getMessagesForConvo): count '00000000-0000-0000-0000-0000000…
danny-avila Sep 24, 2023
99b5984
chore: add newer model to token map
danny-avila Sep 24, 2023
d9fff9d
fix: condition was point to prop of array instead of message prop
danny-avila Sep 24, 2023
fcb1985
refactor(BaseClient): use object for refineMessages param, rename 'su…
danny-avila Sep 24, 2023
bed06ab
chore: log previous_summary if debugging
danny-avila Sep 24, 2023
dfd09a6
refactor(formatMessage): assume if role is defined that it's a valid …
danny-avila Sep 24, 2023
10cfc2e
refactor(getMessagesWithinTokenLimit): remove summary logic
danny-avila Sep 24, 2023
7687aa9
fix: undefined handling and summarizing only when shouldRefineContext…
danny-avila Sep 25, 2023
1e3ddc7
chore(BaseClient): fix test results omitting system role for summarie…
danny-avila Sep 25, 2023
ec6f405
chore: export summaryBuffer from index file
danny-avila Sep 25, 2023
67a40d6
refactor(OpenAIClient/BaseClient): move refineMessages to subclass, i…
danny-avila Sep 25, 2023
4c17830
feat: add OPENAI_SUMMARIZE to enable summarizing, refactor: rename cl…
danny-avila Sep 25, 2023
db4c01d
refactor: rename refineMessages method to summarizeMessages for clarity
danny-avila Sep 25, 2023
e1228eb
chore: clarify summary future intent in .env.example
danny-avila Sep 25, 2023
364e12a
refactor(initializeLLM): handle case for either 'model' or 'modelName…
danny-avila Sep 25, 2023
8ebb399
feat(gptPlugins): enable summarization for plugins
danny-avila Sep 25, 2023
6adb0f3
refactor(gptPlugins): utilize new initializeLLM method and formatting…
danny-avila Sep 25, 2023
02b76e2
refactor(agents): use ConversationSummaryBufferMemory for both agent …
danny-avila Sep 25, 2023
396239a
refactor(formatMessage): optimize original method for langchain, add …
danny-avila Sep 25, 2023
0d1fc69
refactor(summaryBuffer): add helper to createSummaryBufferMemory, and…
danny-avila Sep 25, 2023
239a8de
fix: forgot to spread formatMessages also took opportunity to plurali…
danny-avila Sep 25, 2023
5da312d
refactor: pass memory to tools, namely openapi specs. not used and ma…
danny-avila Sep 25, 2023
043972d
ci(formatMessages): add more exhaustive checks for langchain messages
danny-avila Sep 25, 2023
1da7c9f
feat: add debug env var for OpenAI
danny-avila Sep 25, 2023
eb31b94
chore: delete unnecessary comments
danny-avila Sep 26, 2023
e65675f
chore: add extra note about summary feature
danny-avila Sep 26, 2023
fd38f88
fix: remove tokenCount from payload instructions
danny-avila Sep 26, 2023
a79742d
fix: test fail
danny-avila Sep 26, 2023
33fcb31
fix: only pass instructions to payload when defined or not empty object
danny-avila Sep 26, 2023
2f52f78
refactor: fromPromptMessages is deprecated, use renamed method fromMe…
danny-avila Sep 26, 2023
8b4189a
refactor: use 'includes' instead of 'startsWith' for extended OpenRou…
danny-avila Sep 26, 2023
4741473
fix(PluginsClient.buildPromptBody): handle undefined message strings
danny-avila Sep 26, 2023
4555b17
chore: log langchain titling error
danny-avila Sep 26, 2023
a4db0e3
feat: getModelMaxTokens helper
danny-avila Sep 26, 2023
5856309
feat: tokenSplit helper
danny-avila Sep 26, 2023
cde3c25
feat: summary prompts updated
danny-avila Sep 26, 2023
daa724f
fix: optimize _CUT_OFF_SUMMARIZER prompt
danny-avila Sep 26, 2023
7f2f8fc
refactor(summaryBuffer): use custom summary prompt, allow prompt to b…
danny-avila Sep 26, 2023
13bb961
fix(summaryBuffer): handle edge case where messagesToRefine exceeds s…
danny-avila Sep 26, 2023
dcec559
fix(handleContextStrategy): handle case where incoming prompt is bigg…
danny-avila Sep 26, 2023
25ca4b5
chore: rename refinedContent to splitText
danny-avila Sep 26, 2023
d01ee64
chore: remove unnecessary debug log
danny-avila Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ MONGO_URI=mongodb://127.0.0.1:27018/LibreChat
# Set to "user_provided" to allow the user to provide their API key from the UI.
OPENAI_API_KEY=user_provided

DEBUG_OPENAI=false # Set to true to enable debug mode for the OpenAI endpoint

# Identify the available models, separated by commas *without spaces*.
# The first will be default.
# Leave it blank to use internal settings.
Expand All @@ -77,12 +79,25 @@ OPENAI_API_KEY=user_provided
# Uncomment the following variable to disable this feature.
# TITLE_CONVO=false

# The model used for titling by default is gpt-3.5-turbo-0613 to assure it works with the default method.
# gpt-3.5-turbo should also work when using the official API (and not a reverse proxy).
# You can change the model used by uncommenting the following and setting it to the model you want
# (Optional) The default model used for titling by is gpt-3.5-turbo-0613
# You can change it by uncommenting the following and setting the desired model
# Must be compatible with the OpenAI Endpoint.
# OPENAI_TITLE_MODEL=gpt-3.5-turbo

# (Optional/Experimental) Enable message summarization by uncommenting the following:
# Note: this may affect response time when a summary is being generated.
# OPENAI_SUMMARIZE=true

# Not yet implemented: this will be a conversation option enabled by default to save users on tokens
# We are using the ConversationSummaryBufferMemory method to summarize messages.
# To learn more about this, see this article:
# https://www.pinecone.io/learn/series/langchain/langchain-conversational-memory/

# (Optional) The default model used for summarizing is gpt-3.5-turbo
# You can change it by uncommenting the following and setting the desired model
# Must be compatible with the OpenAI Endpoint.
# OPENAI_SUMMARY_MODEL=gpt-3.5-turbo

# Reverse proxy settings for OpenAI:
# https://github.com/waylaidwanderer/node-chatgpt-api#using-a-reverse-proxy
# OPENAI_REVERSE_PROXY=
Expand Down
14 changes: 4 additions & 10 deletions api/app/clients/AnthropicClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ class AnthropicClient extends BaseClient {
}

async buildMessages(messages, parentMessageId) {
const orderedMessages = this.constructor.getMessagesForConversation(messages, parentMessageId);
const orderedMessages = this.constructor.getMessagesForConversation({
messages,
parentMessageId,
});
if (this.options.debug) {
console.debug('AnthropicClient: orderedMessages', orderedMessages, parentMessageId);
}
Expand Down Expand Up @@ -239,7 +242,6 @@ class AnthropicClient extends BaseClient {
console.log('AnthropicClient doesn\'t use getCompletion (all handled in sendCompletion)');
}

// TODO: implement abortController usage
async sendCompletion(payload, { onProgress, abortController }) {
if (!abortController) {
abortController = new AbortController();
Expand Down Expand Up @@ -317,14 +319,6 @@ class AnthropicClient extends BaseClient {
return text.trim();
}

// I commented this out because I will need to refactor this for the BaseClient/all clients
// getMessageMapMethod() {
// return ((message) => ({
// author: message.isCreatedByUser ? this.userLabel : this.assistantLabel,
// content: message?.content ?? message.text
// })).bind(this);
// }

getSaveOptions() {
return {
promptPrefix: this.options.promptPrefix,
Expand Down
Loading