Skip to content

feat: implement LM Studio runtime adapter (#17) - #170

Merged
himanshu231204 merged 2 commits into
mainfrom
feature/lmstudio-adapter
Jul 20, 2026
Merged

feat: implement LM Studio runtime adapter (#17)#170
himanshu231204 merged 2 commits into
mainfrom
feature/lmstudio-adapter

Conversation

@himanshu231204

Copy link
Copy Markdown
Member

Summary

Implement full LMStudioRuntime adapter that integrates with LM Studio's local server API. This PR closes issue #17.

Changes

  • src/modeldock/adapters/runtimes/lmstudio.py - Full implementation of LMStudioRuntime adapter
  • tests/unit/test_lmstudio_runtime.py - Comprehensive unit tests (31 tests)

Implementation Details

The adapter supports:

  • Model discovery via /v1/models endpoint
  • Interactive sessions using OpenAI-compatible API
  • Model download via native API or UI guidance
  • Configurable host and API key
  • Comprehensive error handling with typed exceptions

Key Features

  1. RuntimePort Compliance: Fully implements all RuntimePort methods
  2. OpenAI Compatibility: Uses OpenAI SDK for inference via LM Studio's compatible API
  3. Native API Support: Uses LM Studio's native API for model management
  4. Configurable: Supports custom host and API key via constructor or environment variables
  5. Graceful Error Handling: Typed exceptions with actionable hints

Testing

All tests pass:

  • 183 unit tests passed (6 skipped)
  • 31 LM Studio tests passed (100% coverage)
  • 2 integration tests passed (2 skipped)
  • 16 E2E tests passed

Static analysis:

  • ruff - All checks passed
  • mypy - No type errors
  • bandit - No security issues

Usage Example

import modeldock as md

# List models from LM Studio
md.installed()

# Load a model
client = md.load("qwen/qwen3.5-9b", backend="lmstudio")

# Or use LM Studio explicitly
mgr = md.Manager(backend="lmstudio")
client = mgr.load("qwen/qwen3.5-9b")

Checklist

  • Code follows project standards (Clean Architecture, SOLID principles)
  • Comprehensive unit tests with >80% coverage
  • All static analysis checks pass (ruff, mypy, bandit)
  • No changes to core logic or other adapters
  • Documentation updated in code comments
  • Cross-platform compatibility maintained

Implement full LMStudioRuntime adapter that integrates with LM Studio's
local server API. The adapter supports:

- Model discovery via /v1/models endpoint
- Interactive sessions using OpenAI-compatible API
- Model download via native API or UI guidance
- Configurable host and API key
- Comprehensive error handling with typed exceptions

Includes 31 unit tests covering all RuntimePort methods.

Closes #17
Run ruff format to fix CI formatting check failures across all platforms.
@himanshu231204
himanshu231204 merged commit e6da4d5 into main Jul 20, 2026
29 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @himanshu231204!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

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.

1 participant