Skip to content

Added LMStudio support

Choose a tag to compare

@EmilianoMusso EmilianoMusso released this 08 Mar 17:03
· 2 commits to master since this release
233cdf6
Added LMStudio support (#12)

* **Commit Message:**

Added LLM server classes

- Added an abstract class `LLMServerBase` with an abstract method `GetChatCompletionAsync` in `LlmServerBase.cs`.
- Implemented the `LMStudioServer` class with the `GetChatCompletionAsync` method to interact with the LM Studio server in `LmStudioServer.cs`.
- Implemented the `OllamaServer` class with the `GetChatCompletionAsync` method to interact with the Ollama server in `OllamaServer.cs`.
- Added a reference to `System.Net.Http` in the `EntwineLLM.csproj` project.
- Added a type converter (`LlmServerConverter`) for selecting the LLM server in general options (`EntwineLLMOptions.cs`).
- Modified properties `LlmUrl` and `LlmRequestTimeOut` to use values from the selected LLM server in `EntwineLLMOptions.cs`.
- Replaced direct usage of `HttpClient` with a call to the `GetChatCompletionAsync` method of the LLM server classes in `RefactoringHelper.cs`.

* Refactoring and Feature Addition for LLM

- Added `Microsoft.VisualStudio.Threading` import to `EntwineLLMOptions.cs`.
- Removed unnecessary imports from `EntwineLLMOptions.cs`.
- Introduced a static field `currentServer` and property `CurrentServer` in `GeneralOptions` for managing a single instance of `LLMServerBase`.
- Updated the `LlmServer` property to use `currentServer` and update it when set.
- Created `LlmModelConverter` class in `ModelsOptions` for converting LLM models using `ThreadHelper.JoinableTaskFactory`.
- Added `TypeConverter` attribute to several properties of `ModelsOptions`.
- Implemented `GetModelListAsync` method in `LlmServerBase`, `LMStudioServer`, and `OllamaServer` to retrieve model lists from HTTP endpoints.

* Refactored code and updated Ollama models API URL

- Created a new file `LlmServerConverter.cs` containing the `LlmServerConverter` class, which was previously in `EntwineLLMOptions.cs`.
- Updated the API URL in `OllamaServer.cs` from `api/list_models` to `api/tags`.

* General refactoring

* Added image to readme

---------

Co-authored-by: Luc BOLOGNA <bologna.luc@gmail.com>