Introduction
Learn how to use JavaScript hooks to customize OramaCore
Orama ❤️ JavaScript. Since day zero, we've been working on JavaScript solutions and we're excited to bring this love to OramaCore.
We believe that JavaScript is the lingua franca of the web, and we want to make it easy for developers to use JavaScript to customize OramaCore.
What are JavaScript Hooks?
JavaScript hooks are a way to customize OramaCore using JavaScript. You can use JavaScript hooks to:
- Customize text extraction and transformation
- Implement custom business logic
- Integrate with third-party services
- Write your own agents and actions
- And much more!
At the time of writing, we're working on a set of JavaScript hooks that you can use to customize OramaCore.
Creating a Hooks
Once you have created a collection, you can create a JavaScript hook by using the .addHook
method from the official SDK.
Here's an example of what a JavaScript hook looks like:
As you can see, this hook takes a document as an input and produces a formatted MarkDown string as an output, which will then be used by OramaCore to generate embeddings.
Wehn using the official JavaScript SDK, you can insert the hook above by turning it into a string and passing it to the addHook
function:
Before inserting the hook, OramaCore will validate the JavaScript code to ensure it's safe to run. If the code is invalid, OramaCore will return an error.
Available Hooks
Right now, OramaCore supports only one JavaScript hook (with the plan of adding dozens in the near future).
The hook is called selectEmbeddingProperties
and allows you to customize the text extraction and transformation process for each document.