Skip to content

Add vLLM support #524

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected override async Task OnInitializedAsync()
//
// We cannot load the API key for self-hosted providers:
//
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED && this.DataHost is not Host.OLLAMA)
if (this.DataLLMProvider is LLMProviders.SELF_HOSTED && this.DataHost is not Host.OLLAMA && this.DataHost is not Host.V_LLM)
{
await this.ReloadModels();
await base.OnInitializedAsync();
Expand Down
3 changes: 2 additions & 1 deletion app/MindWork AI Studio/Provider/LLMProvidersExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ private static IProvider CreateProvider(this LLMProviders provider, string insta
LLMProviders.GWDG => true,
LLMProviders.HUGGINGFACE => true,

LLMProviders.SELF_HOSTED => host is Host.OLLAMA,
LLMProviders.SELF_HOSTED => host is (Host.OLLAMA or Host.V_LLM),

_ => false,
};
Expand Down Expand Up @@ -322,6 +322,7 @@ public static bool CanLoadModels(this LLMProviders provider, Host host, string?

case Host.OLLAMA:
case Host.LM_STUDIO:
case Host.V_LLM:
return true;
}
}
Expand Down
5 changes: 1 addition & 4 deletions app/MindWork AI Studio/Provider/SelfHosted/ChatRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ namespace AIStudio.Provider.SelfHosted;
/// <param name="Model">Which model to use for chat completion.</param>
/// <param name="Messages">The chat messages.</param>
/// <param name="Stream">Whether to stream the chat completion.</param>
/// <param name="MaxTokens">The maximum number of tokens to generate.</param>
public readonly record struct ChatRequest(
string Model,
IList<Message> Messages,
bool Stream,

int MaxTokens
bool Stream
);
1 change: 1 addition & 0 deletions app/MindWork AI Studio/Provider/SelfHosted/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public enum Host
LM_STUDIO,
LLAMACPP,
OLLAMA,
V_LLM,
}
2 changes: 2 additions & 0 deletions app/MindWork AI Studio/Provider/SelfHosted/HostExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class HostExtensions
Host.LM_STUDIO => "LM Studio",
Host.LLAMACPP => "llama.cpp",
Host.OLLAMA => "ollama",
Host.V_LLM => "vLLM",

_ => "Unknown",
};
Expand All @@ -29,6 +30,7 @@ public static bool AreEmbeddingsSupported(this Host host)
{
case Host.LM_STUDIO:
case Host.OLLAMA:
case Host.V_LLM:
return true;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public override async IAsyncEnumerable<string> StreamChatCompletion(Provider.Mod
}).ToList()],

// Right now, we only support streaming completions:
Stream = true,
MaxTokens = -1,
Stream = true
}, JSON_SERIALIZER_OPTIONS);

async Task<HttpRequestMessage> RequestBuilder()
Expand Down Expand Up @@ -101,6 +100,7 @@ public override async IAsyncEnumerable<ImageURL> StreamImageCompletion(Provider.

case Host.LM_STUDIO:
case Host.OLLAMA:
case Host.V_LLM:
return await this.LoadModels(["embed"], [], token, apiKeyProvisional);
}

Expand All @@ -127,6 +127,7 @@ public override async IAsyncEnumerable<ImageURL> StreamImageCompletion(Provider.
{
case Host.LM_STUDIO:
case Host.OLLAMA:
case Host.V_LLM:
return await this.LoadModels([], ["embed"], token, apiKeyProvisional);
}

Expand Down