forked from stitionai/devika
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding LM Studio Support (stitionai#389)
* adding LM Studio * include LM Studio in simple config * Delete ui/package-lock.json That file shouldn't have been commited
- Loading branch information
1 parent
04af76c
commit 3b98ed3
Showing
4 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,30 @@ | ||
from src.logger import Logger | ||
from src.config import Config | ||
from openai import OpenAI | ||
|
||
|
||
log = Logger() | ||
|
||
class LMStudio: | ||
def __init__(self): | ||
try: | ||
self.api_endpoint = Config().get_lmstudio_api_endpoint() | ||
self.client = OpenAI(base_url=self.api_endpoint, api_key="not-needed") | ||
log.info("LM Studio available") | ||
except: | ||
self.api_endpoint = None | ||
self.client = None | ||
log.warning("LM Studio not available") | ||
log.warning("Make sure to set the LM Studio API endpoint in the config") | ||
|
||
def inference(self, model_id: str, prompt: str) -> str: | ||
chat_completion = self.client.chat.completions.create( | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": prompt.strip(), | ||
} | ||
], | ||
model=model_id, # unused | ||
) | ||
return chat_completion.choices[0].message.content |