Skip to content

fix: resolve setuptools packaging, Rag SDK NoneType crash, load balancer fallback logic, and add test suites - #22

Open
ankitnarang-ai wants to merge 1 commit into
npmaiecosystem:mainfrom
ankitnarang-ai:ankit-dev
Open

fix: resolve setuptools packaging, Rag SDK NoneType crash, load balancer fallback logic, and add test suites#22
ankitnarang-ai wants to merge 1 commit into
npmaiecosystem:mainfrom
ankitnarang-ai:ankit-dev

Conversation

@ankitnarang-ai

Copy link
Copy Markdown

This PR resolves several critical issues across packaging, the Python SDK, load balancer services, and test coverage.

1. 📦 Packaging & Build System (pyproject.toml)

  • Configured explicit [tool.setuptools.packages.find] to restrict package discovery strictly to npmai*.
  • Fixes Multiple top-level packages discovered in a flat-layout errors during pip install . and pip install -e ..
  • Added .gitignore to prevent committing .venv/, __pycache__, *.egg-info/, and test artifacts.

2. 🐍 Python SDK (npmai/npmai.py)

  • Fixed TypeError in Rag.send(): Fixes crash when files=None or omitted (e.g., for URL/link-based queries).
  • Resource Cleanup: Safely opens and closes file handles via a try...finally block.
  • State Isolation: Resets files_to_send per send() invocation.

3. ⚖️ Load Balancer Service (load_balancer/app.py)

  • Enhanced Fallback Model Resolution: Updated llm_router fallback lookup to resolve both standard model names (e.g. gemma2:2b) and _fall model names.
  • Standard HTTP Status Codes: Replaced non-standard HTTP status codes (444 and 402) with standard 400 Bad Request and 404 Not Found.

4. 🔗 API Framework (NPMRAG-API-Framework/NPMRAG-API-Framework.py)

  • Replaced Python string identity check anti-patterns (is not "", is "") with value equality (!= "", == "") to eliminate Python warnings.

5. 🧪 Testing & Verification

  • JavaScript SDK (npmai_js/package.json): Configured "test": "node --test tests/*.test.js" script (Passed 49/49 unit tests).
  • Python SDK (tests/test_sdk.py): Added unit test suite covering Ollama, Memory, and Rag classes (Passed 12/12 pytest tests).

Verification

  • pip install -e . built and installed successfully.
  • pytest tests/ (12 passed)
  • cd npmai_js && npm test (49 passed)

@sonuramashishnpm sonuramashishnpm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We will soon aproove it as we are finalised with our new updates we will approve your changes.

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.

2 participants