BRK
BRX Knowledge Representations - the building blocks of BRX
BRK: BRX Knowledge Representations
BRKs (BRX Knowledge Representations) are the fundamental building blocks of the BRX platform. They represent reusable AI components that can be composed together to build complex applications.
What is a BRK?
A BRK is a prompt with the ability to include variables and other BRKs as dependencies with recursion. Think of it as a function in programming - it takes inputs, processes them, and produces outputs. However, instead of executing code, a BRK processes natural language and interacts with LLMs.
Key characteristics of BRKs:
- Reusable: Create once, use anywhere
- Composable: BRKs can include other BRKs as dependencies
- Parameterized: Accept input variables that can be customized at runtime
- Versioned: Track changes and maintain compatibility
- Shareable: Can be shared with other users and teams
BRK Structure
A BRK consists of:
- BRX ID: A unique identifier for the BRK
- Name: A human-readable name
- Description: A description of what the BRK does
- Input Fields: Variables that can be provided at runtime
- Prompt: The template that will be sent to the LLM
- Dependencies: Other BRKs that this BRK depends on
- Process Parameters: Configuration for how the BRK should be executed
Creating a BRK
BRKs can be created through the BRX platform UI or programmatically using the BRX API. Here’s an example of creating a BRK using the Node.js SDK:
Using a BRK
Once a BRK is created, you can use it by fetching its schema and providing input values:
BRK Dependencies
One of the most powerful features of BRKs is the ability to include other BRKs as dependencies. This allows you to build complex AI applications by composing simpler components.
For example, you might have:
- A BRK that extracts key information from a text
- A BRK that summarizes information
- A BRK that formats the summary in a specific way
You can compose these together by making the summarization BRK depend on the extraction BRK, and the formatting BRK depend on the summarization BRK.
When you run the formatting BRK, it will automatically run the summarization BRK, which will in turn run the extraction BRK. The output of each BRK is passed to the next one in the chain.
Best Practices
- Keep BRKs focused: Each BRK should do one thing well
- Use descriptive names: Make it clear what each BRK does
- Document inputs and outputs: Clearly describe what each input field expects and what the output will be
- Test thoroughly: Ensure your BRKs work as expected with various inputs
- Version control: Keep track of changes to your BRKs