AI-Studio/app/MindWork AI Studio/Provider/SelfHosted/HostExtensions.cs

84 lines
1.9 KiB
C#
Raw Normal View History

2024-12-03 14:24:40 +00:00
namespace AIStudio.Provider.SelfHosted;
public static class HostExtensions
{
public static string Name(this Host host) => host switch
{
Host.NONE => "None",
Host.LM_STUDIO => "LM Studio",
2026-01-09 11:45:21 +00:00
Host.LLAMA_CPP => "llama.cpp",
Host.WHISPER_CPP => "whisper.cpp",
2024-12-03 14:24:40 +00:00
Host.OLLAMA => "ollama",
Host.VLLM => "vLLM",
2024-12-03 14:24:40 +00:00
_ => "Unknown",
};
public static string BaseURL(this Host host) => host switch
{
_ => "/v1/",
};
public static string ChatURL(this Host host) => host switch
{
_ => "chat/completions",
};
2026-01-09 11:45:21 +00:00
public static string TranscriptionURL(this Host host) => host switch
{
_ => "audio/transcriptions",
};
2026-02-05 16:27:11 +00:00
public static string EmbeddingURL(this Host host) => host switch
{
_ => "embeddings",
};
2026-01-09 11:45:21 +00:00
public static bool IsChatSupported(this Host host)
2024-12-03 14:24:40 +00:00
{
switch (host)
{
2026-01-09 11:45:21 +00:00
case Host.WHISPER_CPP:
return false;
default:
case Host.OLLAMA:
case Host.VLLM:
2024-12-03 14:24:40 +00:00
case Host.LM_STUDIO:
2026-01-09 11:45:21 +00:00
case Host.LLAMA_CPP:
return true;
}
}
public static bool IsEmbeddingSupported(this Host host)
{
switch (host)
{
case Host.LM_STUDIO:
case Host.OLLAMA:
case Host.VLLM:
return true;
default:
case Host.LLAMA_CPP:
return false;
}
}
public static bool IsTranscriptionSupported(this Host host)
{
switch (host)
{
2024-12-03 14:24:40 +00:00
case Host.OLLAMA:
case Host.VLLM:
2026-01-09 11:45:21 +00:00
case Host.WHISPER_CPP:
2024-12-03 14:24:40 +00:00
return true;
default:
2026-01-09 11:45:21 +00:00
case Host.LM_STUDIO:
case Host.LLAMA_CPP:
2024-12-03 14:24:40 +00:00
return false;
}
}
}