-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Add lm studio as model provider #1134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b49e567
add lm studio provider
garyzhang99 46e9169
fix copilot comment
garyzhang99 baa1b21
fix comments
garyzhang99 a894826
polish according to copilot comment
garyzhang99 7fbeed8
merge current main
garyzhang99 b4fa074
fix copliot comments
garyzhang99 a6699e3
polish doc
garyzhang99 484a9e0
fix npm format
garyzhang99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # -*- coding: utf-8 -*- | ||
| """An LM Studio provider implementation. | ||
|
|
||
| LM Studio exposes an OpenAI-compatible local server (default | ||
| http://localhost:1234/v1). This provider auto-discovers loaded models | ||
| on each get_info() call, similar to OllamaProvider.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| from typing import List | ||
|
|
||
| from copaw.providers.openai_provider import OpenAIProvider | ||
| from copaw.providers.provider import ModelInfo, ProviderInfo | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
garyzhang99 marked this conversation as resolved.
|
||
|
|
||
|
|
||
| class LMStudioProvider(OpenAIProvider): | ||
| """Provider for LM Studio's OpenAI-compatible local server.""" | ||
|
|
||
| async def get_info(self, mock_secret: bool = True) -> ProviderInfo: | ||
| models: List[ModelInfo] = [] | ||
| try: | ||
| models = await self.fetch_models(timeout=1) | ||
| self.models = models | ||
| except Exception: | ||
| pass | ||
|
garyzhang99 marked this conversation as resolved.
Outdated
|
||
| return ProviderInfo( | ||
| id=self.id, | ||
| name=self.name, | ||
| base_url=self.base_url, | ||
| api_key=self.api_key_prefix + "*" * 6 | ||
|
garyzhang99 marked this conversation as resolved.
Outdated
|
||
| if mock_secret and self.api_key | ||
| else self.api_key, | ||
| chat_model=self.chat_model, | ||
| models=models, | ||
| extra_models=self.extra_models, | ||
| api_key_prefix=self.api_key_prefix, | ||
| is_local=self.is_local, | ||
| is_custom=self.is_custom, | ||
| freeze_url=self.freeze_url, | ||
| require_api_key=self.require_api_key, | ||
|
garyzhang99 marked this conversation as resolved.
Outdated
|
||
| ) | ||
|
garyzhang99 marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.