Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat
設定LibreChat YAMLオブジェクト構造メモリ設定

メモリ設定

概要

memory オブジェクトを使用すると、アプリケーションの会話メモリおよびパーソナライゼーション機能を設定できます。この設定は、トークン制限、メッセージコンテキストウィンドウ、エージェントベースのメモリ処理など、システムがどのように会話を記憶し、パーソナライズするかを制御します。

memory:
  disabled: false
  validKeys: ['user_preferences', 'conversation_context', 'personal_info']
  tokenLimit: 2000
  charLimit: 10000
  maxInputTokens: 12000
  personalize: true
  messageWindowSize: 5
  agent:
    provider: 'openAI'
    model: 'gpt-4'
    instructions: 'You are a helpful assistant that remembers user preferences and context.'
    model_parameters:
      temperature: 0.7
      max_tokens: 1000

disabled

KeyTypeDescriptionExample
disabledBooleantrueに設定すると、メモリ機能を無効にします。無効にすると、システムは会話メモリを保存または使用しません。disabled: false

デフォルト: false

memory:
  disabled: true

validKeys

KeyTypeDescriptionExample
validKeysArray of Stringsメモリに保存可能なキーを指定します。これにより、メモリに保存できる情報の種類を制御できます。validKeys: ["user_name", "preferences", "コンテキスト"]

デフォルト: 制限なし(すべてのキーが有効)

memory:
  validKeys:
    - 'user_preferences'
    - 'conversation_context'
    - 'personal_information'
    - 'learned_facts'

tokenLimit

KeyTypeDescriptionExample
tokenLimitNumberメモリの保存および処理に使用できるトークンの最大数を設定します。tokenLimit: 2000

デフォルト: 制限なし

memory:
  tokenLimit: 2000

charLimit

KeyTypeDescriptionExample
charLimitNumber個々のメモリ・エントリに許可される最大文字数を設定します。これにより、パフォーマンスに影響を与えたり、API制限を超えたりする可能性のある過大なメモリ・ペイロードを防ぎます。charLimit: 10000

デフォルト: 10000

memory:
  charLimit: 10000

maxInputTokens

KeyTypeDescriptionExample
maxInputTokensNumberメモリ抽出の前に自動メモリ・エージェントに送信される最近のチャットトークンの最大数を設定します。長い入力は先頭から切り捨てられるため、最新のコンテキストが保持されます。maxInputTokens: 12000

デフォルト: 12000

memory:
  maxInputTokens: 12000

personalize

KeyTypeDescriptionExample
personalizeBooleantrueに設定すると、ユーザーはメモリ機能の使用を選択または解除できるようになります。ユーザーはチャットインターフェースでメモリのオン/オフを切り替えることができます。falseに設定すると、メモリ機能は完全に無効になります。personalize: true

デフォルト: true

memory:
  personalize: false

messageWindowSize

KeyTypeDescriptionExample
messageWindowSizeNumberメモリコンテキストウィンドウに含める直近のメッセージ数を指定します。messageWindowSize: 5

デフォルト: 5

memory:
  messageWindowSize: 10

agent

KeyTypeDescriptionExample
agentObject | Unionメモリ処理を担当するエージェントを設定します。IDによる既存エージェントへの参照、またはエージェント設定全体のいずれかを指定できます。agent: { provider: "openAI", model: "gpt-4" }

agent フィールドは、2つの異なる設定フォーマットをサポートしています:

IDによるエージェント

事前に設定されたエージェントがある場合、そのIDを使用して参照できます:

memory:
  agent:
    id: 'memory-agent-001'

カスタムエージェントの設定

より詳細な制御を行うには、完全なエージェント設定を定義することができます:

memory:
  agent:
    provider: 'openAI'
    model: 'gpt-4'
    instructions: 'You are a memory assistant that helps maintain conversation context and user preferences.'
    model_parameters:
      temperature: 0.3
      max_tokens: 1500
      top_p: 0.9

エージェント設定フィールド

カスタムエージェント設定を使用する場合、以下のフィールドが利用可能です:

provider (必須)

KeyTypeDescriptionExample
providerStringメモリエージェントのAIプロバイダーを指定します。組み込みのプロバイダー(例: "openAI", "anthropic", "google")またはカスタムのendpoint名を指定できます。provider: "openAI"

model (必須)

KeyTypeDescriptionExample
modelStringメモリ処理に使用するモデルを指定します。model: "gpt-4"

instructions (オプション)

KeyTypeDescriptionExample
instructionsStringメモリを設定または削除するタイミングを規定するデフォルトの指示を置き換えるカスタム指示。主に、特定の情報処理を必要とするvalidKeysを使用する場合に使用してください。instructions: "Only store user preferences and facts when explicitly mentioned."

model_parameters (オプション)

KeyTypeDescriptionExample
model_parametersObjectモデルの動作を微調整するために渡す追加のパラメータ。値は文字列、数値、またはブール値である必要があります。model_parameters: { temperature: 0.7 }

完全な設定例

メモリ設定のすべてのオプションを示す包括的な例を以下に示します:

version: 1.3.10
cache: true

memory:
  disabled: false
  validKeys:
    - 'user_preferences'
    - 'conversation_context'
    - 'learned_facts'
    - 'personal_information'
  tokenLimit: 3000
  charLimit: 10000
  maxInputTokens: 12000
  personalize: true
  messageWindowSize: 8
  agent:
    provider: 'openAI'
    model: 'gpt-4'
    instructions: |
      Store memory using only the specified validKeys. For user_preferences: save 
      explicitly stated preferences about communication style, topics of interest, 
      or workflow preferences. For conversation_context: save important facts or 
      ongoing projects mentioned. For learned_facts: save objective information 
      about the user. For personal_information: save only what the user explicitly 
      shares about themselves. Delete outdated or incorrect information promptly.
    model_parameters:
      temperature: 0.2
      max_tokens: 2000
      top_p: 0.8
      frequency_penalty: 0.1

カスタム endpoint の使用

memory機能はカスタムendpointをサポートしています。カスタムendpointを使用する場合、providerフィールドはカスタムendpointのnameと完全に一致している必要があります。環境変数やユーザープレースホルダーを含むカスタムヘッダーは、適切に解決されます。


endpoints:
    custom:
        - name: 'Custom Memory Endpoint'
           apiKey: 'dummy'
           baseURL: 'https://api.gateway.ai/v1'
           headers:
             x-gateway-api-key: '${GATEWAY_API_KEY}'
             x-gateway-virtual-key: '${GATEWAY_OPENAI_VIRTUAL_KEY}'
             X-User-Identifier: '{{LIBRECHAT_USER_EMAIL}}'
             X-Application-Identifier: 'LibreChat - Test'
             api-key: '${TEST_CUSTOM_API_KEY}'
           models:
             default:
               - 'gpt-4o-mini'
               - 'gpt-4o'
             fetch: false

memory:
  disabled: false
  tokenLimit: 3000
  maxInputTokens: 12000
  personalize: true
  messageWindowSize: 10
  agent:
    provider: 'Custom Memory Endpoint'
    model: 'gpt-4o-mini'
  • 利用可能なすべてのプレースホルダーについては、Custom Endpoint Headers を参照してください。

注記

  • メモリ機能は、会話の継続性とパーソナライズを強化します。
  • When personalize is true, users get a toggle in their chat interface to control memory usage
  • トークン制限は、メモリ使用量と処理コストを制御するのに役立ちます。
  • maxInputTokens は自動メモリ・エージェントに送信されるチャットコンテキストを制限し、tokenLimit は保存されるメモリ使用量を制御します。
  • 有効なキーを使用することで、どの情報を保存できるかを詳細に制御できます。
  • カスタム instructions はデフォルトのメモリ処理指示を置き換えるものであり、validKeys と併用する必要があります。
  • エージェント設定により、メモリ処理の動作をカスタマイズできます。
  • 無効にすると、他の設定に関係なくすべてのメモリ機能がオフになります。
  • メッセージウィンドウサイズは、メモリ更新のために考慮される最近のコンテキストの量に影響します。

このガイドはいかがでしたか?