Accessing Knowledge¶
The KnowledgeHub
class provides a centralized way for agents to access and update knowledge in the system. It handles both workflow and non-workflow contexts automatically, ensuring proper execution of knowledge operations.
Fetching Knowledge¶
To retrieve knowledge from the system, use the Fetch
method:
This method will:
- Return the latest version of the specified knowledge
- If a tenant-specific version exists, it will be returned
- If no tenant-specific version exists, it will return the latest global version
- Returns
null
if no knowledge is found
The method automatically handles:
- Workflow contexts through Temporal activities
- Direct execution in non-workflow contexts
Updating Knowledge¶
To update or create new knowledge, use the Update
method:
Parameters:
knowledgeName
: The identifier for the knowledgeknowledgeType
: The type/format of the knowledgeknowledgeContent
: The actual content of the knowledge
The method:
- Returns
true
if the update was successful - Throws an exception with details if the update fails
- Handles both workflow and non-workflow contexts automatically