Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLEAR KB

Remove knowledge bases from the current session.

Syntax

CLEAR KB "collection_name"   ' Remove specific collection
CLEAR KB ALL                 ' Remove all collections

Parameters

ParameterTypeDescription
collection_nameStringName of KB to remove (optional)
ALLKeywordRemoves all active KBs

Description

CLEAR KB removes previously loaded knowledge bases from the session’s context. This frees memory and ensures subsequent queries don’t search unwanted collections.

Examples

Clear Specific KB

USE KB "policies"
USE KB "products"

' Later, remove just policies
CLEAR KB "policies"
' Only products remains active

Clear All KBs

USE KB "hr-docs"
USE KB "it-docs"
USE KB "finance"

CLEAR KB ALL
' All collections removed

Context Switching

' Support flow
USE KB "troubleshooting"
USE KB "known-issues"
' ... handle support ...

' Switch to sales
CLEAR KB ALL
USE KB "products"
USE KB "pricing"

Return Value

Returns true if cleared successfully, false if KB wasn’t loaded.

Best Practices

DoDon’t
Clear when switching topicsLeave large KBs active unnecessarily
Clear before loading new contextAssume collections auto-clear
Use ALL for clean slateClear one-by-one when ALL works

Session Scope

  • Only affects current session
  • Other sessions keep their KBs
  • KBs remain in database for future use
  • Can reload cleared KBs anytime

See Also