Skip to content

Multi-Tenant Index Routing with Moss#230

Open
CoderOMaster wants to merge 2 commits into
mainfrom
keshav/multi-index-demo
Open

Multi-Tenant Index Routing with Moss#230
CoderOMaster wants to merge 2 commits into
mainfrom
keshav/multi-index-demo

Conversation

@CoderOMaster

Copy link
Copy Markdown
Collaborator

Pull Request Checklist

Please ensure that your PR meets the following requirements:

  • I have read the CONTRIBUTING guide.
  • I have updated the documentation (if applicable).
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Description

Adds a new cookbook: Multi-Tenant Index Routing with Moss (examples/cookbook/multi-tenant/).

Each business gets its own named Moss index (food-luigis-pizzeria, law-harrison-cole, tech-stackbase, health-vitacare, retail-urban-threads). The agent exposes one StructuredTool per index via llm.bind_tools(). GPT-4.1-mini selects which index(es) to query based purely on tool name and description — no hard-coded routing logic. Ambiguous questions trigger parallel Moss queries via asyncio.gather and the model synthesises a merged answer.

This demonstrates a key Moss use case: dynamically injecting the right business-specific context at runtime without system prompt bloat or context leakage across tenants.

Fixes # (issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Copilot AI review requested due to automatic review settings May 11, 2026 10:10
@CoderOMaster CoderOMaster force-pushed the keshav/multi-index-demo branch from 4d96bb1 to 4dd494c Compare May 11, 2026 10:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Python cookbook demonstrating multi-tenant index routing in Moss by exposing one LangChain tool per tenant index and letting the LLM choose which index(es) to query at runtime.

Changes:

  • Adds examples/cookbook/multi-tenant/ cookbook with an async bind_tools agent, lazy per-index loading, and sample tenant datasets.
  • Updates ROADMAP.md to reflect shipped/in-progress items and reorganizes sections.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
ROADMAP.md Reorganizes roadmap sections and updates shipped/in-progress items.
examples/cookbook/multi-tenant/README.md Cookbook documentation: setup, running, and routing explanation.
examples/cookbook/multi-tenant/pyproject.toml Defines cookbook packaging + dependencies.
examples/cookbook/multi-tenant/moss_multitenant.py Implements lazy index store + tool factory for per-tenant search tools.
examples/cookbook/multi-tenant/agent.py Demo agent: tool-calling loop, index creation from JSON, CLI.
examples/cookbook/multi-tenant/.env.example Example env vars for Moss + OpenAI credentials.
examples/cookbook/multi-tenant/data/saas_company.json Sample tenant knowledge base (Stackbase).
examples/cookbook/multi-tenant/data/retail_urban_threads.json Sample tenant knowledge base (Urban Threads).
examples/cookbook/multi-tenant/data/pizza_shop.json Sample tenant knowledge base (Luigi’s Pizzeria).
examples/cookbook/multi-tenant/data/law_firm.json Sample tenant knowledge base (Harrison & Cole LLP).
examples/cookbook/multi-tenant/data/health_vitacare.json Sample tenant knowledge base (VitaCare Clinic).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread examples/cookbook/multi-tenant/pyproject.toml
Comment on lines +42 to +45
if index_name not in self._loaded:
await self._client.load_index(index_name)
self._loaded.add(index_name)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done as well

Comment thread examples/cookbook/multi-tenant/moss_multitenant.py Outdated
Comment thread examples/cookbook/multi-tenant/agent.py
Comment thread examples/cookbook/multi-tenant/agent.py
Comment thread examples/cookbook/multi-tenant/data/pizza_shop.json Outdated
Comment thread examples/cookbook/multi-tenant/data/law_firm.json Outdated
Comment thread examples/cookbook/multi-tenant/data/saas_company.json Outdated
Comment thread examples/cookbook/multi-tenant/moss_multitenant.py
Comment thread examples/cookbook/multi-tenant/agent.py
Comment thread examples/cookbook/multi-tenant/agent.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants