Crewai integration#77
Conversation
|
@staru09 is attempting to deploy a commit to the Moss Team Team on Vercel. A member of the Team first needs to authorize it. |
41a1d5c to
84d042a
Compare
| @@ -0,0 +1,40 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
Per #76, let's keep this cookbook-only - please drop packages/crewai-moss/
There was a problem hiding this comment.
Pull request overview
Adds a new crewai-moss integration package so CrewAI agents can use Moss for semantic search and basic index/document management, plus a cookbook example and top-level docs update to surface the integration.
Changes:
- Introduces
crewai-mossPython package with 8 CrewAIBaseToolwrappers and amoss_tools()factory. - Adds demo/cookbook example scripts and documentation for using CrewAI + Moss together.
- Updates the repo root README to include the new CrewAI cookbook entry.
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/crewai-moss/tests/test.py | Adds live (credentialed) test script for the CrewAI tool wrappers. |
| packages/crewai-moss/tests/init.py | Initializes the tests package (empty). |
| packages/crewai-moss/src/crewai_moss/tools.py | Implements CrewAI BaseTool wrappers for Moss search, docs, and index operations. |
| packages/crewai-moss/src/crewai_moss/init.py | Exposes the tools and selected Moss SDK types from the package root. |
| packages/crewai-moss/pyproject.toml | Defines package metadata, dependencies, and ruff config for crewai-moss. |
| packages/crewai-moss/examples/demo.py | Provides an example CrewAI + Moss script using FAQ data. |
| packages/crewai-moss/README.md | Documents installation, available tools, and usage patterns. |
| packages/crewai-moss/LICENSE | Adds a license file for the new package. |
| packages/crewai-moss/.gitignore | Adds Python/package build ignores for the new package. |
| examples/cookbook/crewai/example_usage.py | Adds a cookbook example script demonstrating CrewAI + Moss. |
| examples/cookbook/crewai/README.md | Adds cookbook documentation for setup and running the CrewAI example. |
| README.md | Updates root docs to list the CrewAI cookbook integration and adjusts formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| faqs_path = os.path.join( | ||
| os.path.dirname(__file__), "..", "..", "python", "faqs.json" | ||
| ) |
There was a problem hiding this comment.
faqs_path resolves to packages/python/faqs.json from this file location, but the FAQ data lives at examples/python/faqs.json in this repo. As written, the demo will raise FileNotFoundError unless a different file layout exists. Update the path calculation to point at the repo’s examples/python/faqs.json (or accept a path via env/CLI to avoid brittle relative paths).
| faqs_path = os.path.join( | |
| os.path.dirname(__file__), "..", "..", "python", "faqs.json" | |
| ) | |
| faqs_path = os.getenv("MOSS_FAQ_PATH") | |
| if not faqs_path: | |
| faqs_path = os.path.join( | |
| os.path.dirname(__file__), | |
| "..", | |
| "..", | |
| "..", | |
| "examples", | |
| "python", | |
| "faqs.json", | |
| ) |
| client = MossClient(os.getenv("MOSS_PROJECT_ID"), os.getenv("MOSS_PROJECT_KEY")) | ||
|
|
||
| faqs_path = os.path.join( | ||
| os.path.dirname(__file__), "..", "..", "python", "faqs.json" |
There was a problem hiding this comment.
faqs_path is computed by going up only two directories, which targets examples/cookbook/python/faqs.json. In this repo the file is examples/python/faqs.json, so the example will fail with FileNotFoundError. Adjust the relative path (or make it configurable) so it consistently finds examples/python/faqs.json.
| os.path.dirname(__file__), "..", "..", "python", "faqs.json" | |
| os.path.dirname(__file__), "..", "..", "..", "python", "faqs.json" |
| | [Next.js](https://nextjs.org) | Available | [`apps/next-js/`](apps/next-js/) | | ||
| | [VitePress](https://vitepress.dev) | Available | [`packages/vitepress-plugin-moss/`](packages/vitepress-plugin-moss/) | | ||
| | [Vercel AI SDK](https://sdk.vercel.ai) | Coming soon | — | | ||
| | [CrewAI](https://github.com/crewAIInc/crewAI) | Coming soon | — | |
There was a problem hiding this comment.
The integration table lists CrewAI twice (one row says Available and another says Coming soon). This is contradictory and will confuse users; remove the outdated entry so CrewAI appears only once with the correct status.
| | [CrewAI](https://github.com/crewAIInc/crewAI) | Coming soon | — | |
| python -m pytest tests/test_tools.py -v | ||
|
|
||
| # Live platform tests (needs MOSS_PROJECT_ID & MOSS_PROJECT_KEY in .env) | ||
| python tests/test_live.py |
There was a problem hiding this comment.
This package README instructs running tests/test_tools.py and tests/test_live.py, but neither file exists in this package (only tests/test.py is present). Update the README commands to match the actual filenames and/or rename the test files to match the documented commands.
| python -m pytest tests/test_tools.py -v | |
| # Live platform tests (needs MOSS_PROJECT_ID & MOSS_PROJECT_KEY in .env) | |
| python tests/test_live.py | |
| python -m pytest tests/test.py -v | |
| # Live platform tests (needs MOSS_PROJECT_ID & MOSS_PROJECT_KEY in .env) | |
| python tests/test.py |
| _client: Any = None | ||
| _index_loaded: bool = False |
There was a problem hiding this comment.
_client and _index_loaded are declared as normal model fields. In this repo’s LangChain integration, these are marked as PrivateAttr to avoid leaking into the tool schema/serialization. Consider switching these to PrivateAttr here as well (and similarly for _client in the other tool classes in this file).
| project_id: str = Field(description="Moss project ID") | ||
| project_key: str = Field(description="Moss project key") | ||
| index_name: str = Field(description="Name of the Moss index") | ||
|
|
||
| _client: Any = None | ||
|
|
There was a problem hiding this comment.
_client is defined as a standard field; per existing integrations in this repo, internal clients are modeled as PrivateAttr so they don’t become part of the pydantic schema/tool args. Update _client in this class (and the other tool classes below) to use PrivateAttr.
| @@ -0,0 +1,26 @@ | |||
| BSD 2-Clause License | |||
|
|
|||
| Copyright (c) 2024–2025, Daily | |||
There was a problem hiding this comment.
The copyright holder in this LICENSE file is Daily, but pyproject.toml lists InferEdge Inc. as the author and the repo root license is Moss Team. Please confirm the intended copyright holder for this package and update the header to match, to avoid licensing ambiguity.
| Copyright (c) 2024–2025, Daily | |
| Copyright (c) 2024–2025, Moss Team |
| examples/.env | ||
| __pycache__/ | ||
| *.pyc | ||
| src/pipecat_moss.egg-info/ |
There was a problem hiding this comment.
This .gitignore entry appears copy/pasted from pipecat-moss and ignores src/pipecat_moss.egg-info/. For this package it should ignore the egg-info directory for crewai_moss instead, otherwise local build artifacts won’t be ignored.
| src/pipecat_moss.egg-info/ | |
| src/crewai_moss.egg-info/ |
| async def run_tests(): | ||
| if not PROJECT_ID or not PROJECT_KEY: | ||
| print("ERROR: MOSS_PROJECT_ID and MOSS_PROJECT_KEY must be set.") | ||
| sys.exit(1) | ||
|
|
||
| print("Running live tests against Moss platform...\n") |
There was a problem hiding this comment.
This file is a live/integration test that requires real Moss credentials, but it’s named generically (test.py) and sits under tests/. Consider renaming it to test_live.py (matching the README) and/or marking it clearly so it’s not mistaken for a unit test suite.
84d042a to
0ec391f
Compare
|
Hi @staru09 , can you please properly resolve the comments from co-pilot ? |
I think most of these were for the package that I had added, the recent changes has all these addressed |
|
Can you please remove quick start and changes made to main read me ? |
|
please add .env.example |
| """Create a Moss index with the first 10 FAQ documents.""" | ||
| client = MossClient(os.getenv("MOSS_PROJECT_ID"), os.getenv("MOSS_PROJECT_KEY")) | ||
|
|
||
| faqs_path = os.path.join( |
There was a problem hiding this comment.
the directory has changed a lot, this path wont work
| docs = [ | ||
| DocumentInfo( | ||
| id=faq["id"], | ||
| text=faq["text"], |
There was a problem hiding this comment.
Simple FAQ.json example does not seem to be the best integration showcase between the Moss and Crew.
Please try adding more agents which handle multiple index from moss and they are inter collaborating to reach final conclusion.
There was a problem hiding this comment.
umm, let me add a different usecase then
| self._index_loaded = True | ||
|
|
||
| def _run(self, query: str) -> str: | ||
| """Synchronous search -- wraps the async implementation.""" |
There was a problem hiding this comment.
why sync ? what is the use ?
There was a problem hiding this comment.
The sync _run() is there because CrewAI's BaseTool marks it as abstractmethod, so I had to implement sync and async both for it.
| index_name: str = Field(description="Name of the Moss index to search") | ||
| top_k: int = Field(default=5, description="Number of results to return") | ||
| alpha: float = Field( | ||
| default=0.5, |
|
|
||
| def model_post_init(self, __context: Any) -> None: | ||
| """Initialize the MossClient after model construction.""" | ||
| self._client = MossClient(self.project_id, self.project_key) |
There was a problem hiding this comment.
every class instantiates its own mossclient, this is too redundunt
f6dff4a to
622f75b
Compare
|
please let me know when this is ready to review |
a06995e to
0f49947
Compare
There was a problem hiding this comment.
🚩 test_live.py is a credentials-required script, not a pytest-compatible test suite
Unlike the langchain cookbook which has test_integration.py using unittest.IsolatedAsyncioTestCase with mocked clients (no credentials needed), the crewai cookbook's test_live.py is a standalone script using global state (passed/failed counters) and sys.exit(1). It requires real API credentials and cannot run as part of pytest tests/. This means the tool logic in moss_crewai.py has no offline-runnable unit tests. The langchain example (examples/cookbook/langchain/test_integration.py) provides a better pattern to follow here — mocking MossClient to verify tool behavior without hitting the real API.
Was this helpful? React with 👍 or 👎 to provide feedback.
7265b3f to
3d517ba
Compare
yatharthk2
left a comment
There was a problem hiding this comment.
Over all looks good, will approve after these fixes
| crew = Crew( | ||
| agents=specialists + [writer], | ||
| tasks=search_tasks + [write_task], | ||
| verbose=True, |
There was a problem hiding this comment.
please do verbose=False,
| MOSS_PROJECT_ID=your-project-id | ||
| MOSS_PROJECT_KEY=your-project-key | ||
| GEMINI_API_KEY=your-gemini-key |
There was a problem hiding this comment.
Please add CREWAI_TRACING_ENABLED=false
| class MossListIndexesInput(BaseModel): | ||
| """Input schema for MossListIndexesTool.""" | ||
|
|
||
| pass # No input needed |
There was a problem hiding this comment.
It's there to match the schema required by crewai for tools even if it doesn't need any params
We need it cause the BaseTool needs an args_schema and without this, it'll fallback to default and the code can break
| @@ -0,0 +1,3 @@ | |||
| MOSS_PROJECT_ID=your-project-id | |||
There was a problem hiding this comment.
can you also please add pyproject.toml file
There was a problem hiding this comment.
I dont see pyproject.toml
There was a problem hiding this comment.
It got ignored by the git, please check now
3d517ba to
21cecc1
Compare
21cecc1 to
67bca81
Compare
| "crewai", | ||
| "moss>=1.0.0", | ||
| "pydantic", | ||
| "python-dotenv", |
There was a problem hiding this comment.
can you please add "crewai[google-genai]"
There was a problem hiding this comment.
Should we keep it vendor neutral add let user add any vendor uv add 'vendor_package' directly?
There was a problem hiding this comment.
for your example to run there should be as less friction as possible
178947d to
7111f96
Compare
| from moss_crewai import ( | ||
| MossAddDocsTool, | ||
| MossCreateIndexTool, | ||
| MossDeleteDocsTool, | ||
| MossDeleteIndexTool, | ||
| MossGetDocsTool, | ||
| MossListIndexesTool, | ||
| MossSearchTool, | ||
| ) |
There was a problem hiding this comment.
🟡 MossGetIndexTool has no test coverage in test_live.py
MossGetIndexTool is one of 8 tool classes defined in moss_crewai.py:187, documented in README.md:134, and returned by the moss_tools() factory at moss_crewai.py:313. However, test_live.py imports only 7 of the 8 tools (lines 8–16) and has no test scenario for MossGetIndexTool. Every other tool class has at least one test. This violates the CONTRIBUTING.md guideline: "If you've added code that should be tested, add tests." The existing langchain cookbook example (examples/cookbook/langchain/test_integration.py) demonstrates the expected practice of testing all added tool classes.
Prompt for agents
MossGetIndexTool is missing from test_live.py. It is one of 8 tool classes defined in moss_crewai.py, but the test file imports and tests only 7 of them. Add an import of MossGetIndexTool to the import block at lines 8-16 of test_live.py, and add a test section (e.g. between the list_indexes test and the add_docs test) that creates a MossGetIndexTool instance and calls _arun(index_name=TEST_INDEX), verifying the returned string contains the index name. Follow the same pattern as the other tests in the file (try/except with report() calls).
Was this helpful? React with 👍 or 👎 to provide feedback.
| version = "0.1.0" | ||
| description = "CrewAI integration for Moss semantic search" | ||
| readme = "README.md" | ||
| requires-python = ">=3.11" |
There was a problem hiding this comment.
your dependency dont build for python 3.14 , please cap it here
6e4c9f8 to
d41edc2
Compare
|
Approved and Thanks for the PR :) |
## Pull Request Checklist Please ensure that your PR meets the following requirements: - [x] I have read the [CONTRIBUTING](CONTRIBUTING.md) guide. - [x] I have updated the documentation (if applicable). - [x] My code follows the style guidelines of this project. - [x] I have performed a self-review of my own code. - [x] I have added tests that prove my fix is effective or that my feature works. - [x] New and existing unit tests pass locally with my changes. ## Description Add CrewAI integration for Moss semantic search. Tested with Gemini (gemini-3.1-flash-lite-preview) as the LLM, using FAQ data from the existing examples. All tools verified against the live Moss platform. Fixes usemoss#76 ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] 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 <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/usemoss/moss/pull/77" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end -->
Pull Request Checklist
Please ensure that your PR meets the following requirements:
Description
Add CrewAI integration for Moss semantic search.
Tested with Gemini (gemini-3.1-flash-lite-preview) as the LLM, using FAQ data from the existing examples.
All tools verified against the live Moss platform.
Fixes #76
Type of Change