Abuja Digital Studio · Est. 2018
Start a Project
DocsOAssistTools and RAG
Reference

Tools and RAG

OAssistorravo.com/docs/oassist/tools-rag

Tools and RAG

OAssist combines retrieval-augmented generation (RAG) over your indexed content with a tool registry that the LLM can call to take actions in your store.

Built-in tools

Registered on activation in OAssist_Activator::register_built_in_tools(). Each row in oas_tools has a JSON schema, scope (anonymous or authenticated), and handler function.

ToolScopeWhat it does
search_productsanonymousSearch catalog by query, category, price range, stock
get_productanonymousFull details for one product by ID or slug
check_stockanonymousStock status for a product (and variation)
get_order_statusauthenticatedLook up order by number + email
track_shipmentauthenticatedLatest shipment/tracking info
apply_couponanonymousApply a coupon to the visitor's cart
get_loyalty_balanceauthenticatedOLoyalty points + tier
get_subscription_statusauthenticatedOSubscribe active subs
get_wishlistauthenticatedOWishlist contents
get_booking_availabilityanonymousOBook availability check
escalate_to_humananonymousHand off to a human agent
create_support_ticketanonymousCreate a ticket
log_feedbackanonymousLog CSAT/satisfaction score

Tool scope

  • anonymous: available to all visitors.
  • authenticated: requires the visitor to be a logged-in WP user, or to pass email verification for guest checkout lookups.

Disable individual tools under OAssist -> Tools without removing the row.

Adding a custom tool

phpadd_action( 'plugins_loaded', function() {
    global $wpdb;
    $wpdb->insert( OAssist_DB::table( 'tools' ), [
        'name'        => 'recommend_bundle',
        'description' => 'Recommend a product bundle based on cart contents.',
        'schema_json' => wp_json_encode([
            'type'       => 'object',
            'properties' => [
                'cart_items' => [ 'type' => 'array' ],
            ],
            'required' => [ 'cart_items' ],
        ]),
        'scope'    => 'anonymous',
        'handler'  => 'My_Tools::recommend_bundle',
        'enabled'  => 1,
        'built_in' => 0,
    ]);
});

The handler must be a static method or function name that accepts a single args array and returns a JSON-serialisable response.

RAG pipeline

  1. Sources are chunked and embedded into oas_chunks via your configured embedding provider.
  2. On each user message, OAssist embeds the query and retrieves top-K relevant chunks via cosine similarity.
  3. Retrieved chunks are injected into the prompt as context.
  4. Citations are stored per message in oas_messages.citations so the admin inbox can show which sources backed each response.

Reindexing runs daily via oassist_cron_reindex. Trigger manually via Knowledge tab -> Reindex All.

Tools and RAG · OAssist Docs | Orravo