Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

메모리 구성

개요

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 필드는 두 가지 서로 다른 구성 형식을 지원합니다:

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'

참고 사항

  • 메모리 기능은 대화의 연속성과 개인화를 향상시킵니다.
  • personalize가 true로 설정되면, 사용자는 채팅 인터페이스에서 메모리 사용을 제어할 수 있는 토글을 사용할 수 있습니다.
  • 토큰 제한은 메모리 사용량과 처리 비용을 제어하는 데 도움이 됩니다.
  • maxInputTokens는 자동 메모리 에이전트로 전송되는 채팅 컨텍스트의 범위를 제한하며, tokenLimit는 저장된 메모리 사용량을 제어합니다.
  • 유효한 키는 어떤 정보가 저장될 수 있는지에 대한 세밀한 제어 기능을 제공합니다.
  • 사용자 지정 instructions는 기본 메모리 처리 지침을 대체하며 validKeys와 함께 사용해야 합니다.
  • 에이전트 구성(Agent configuration)을 통해 메모리 처리 동작을 사용자 지정할 수 있습니다.
  • 비활성화되면 다른 설정과 관계없이 모든 메모리 기능이 꺼집니다.
  • 메시지 창 크기는 메모리 업데이트를 위해 고려되는 최근 컨텍스트의 양에 영향을 미칩니다.

이 가이드는 어떤가요?