mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-11 07:27:21 +00:00
Turned getter-like extension methods into extension properties (#1157)
This commit is contained in:
1 parent
0375318b1b
commit
f649febf88
286 files changed
+1379
-1109
No files matched your search
@@ -5,7 +5,7 @@ public static class HostExtensions
|
||||
/// <param name="host">The engine.</param>
|
||||
extension(Host host)
|
||||
{
|
||||
public string Name() => host switch
|
||||
public string Name => host switch
|
||||
{
|
||||
Host.NONE => "None",
|
||||
|
||||
@@ -19,22 +19,22 @@ public static class HostExtensions
|
||||
_ => "Unknown",
|
||||
};
|
||||
|
||||
public string BaseURL() => host switch
|
||||
public string BaseURL => host switch
|
||||
{
|
||||
_ => "/v1/",
|
||||
};
|
||||
|
||||
public string ChatURL() => host switch
|
||||
public string ChatURL => host switch
|
||||
{
|
||||
_ => "chat/completions",
|
||||
};
|
||||
|
||||
public string TranscriptionURL() => host switch
|
||||
public string TranscriptionURL => host switch
|
||||
{
|
||||
_ => "audio/transcriptions",
|
||||
};
|
||||
|
||||
public string EmbeddingURL() => host switch
|
||||
public string EmbeddingURL => host switch
|
||||
{
|
||||
_ => "embeddings",
|
||||
};
|
||||
@@ -43,12 +43,12 @@ public static class HostExtensions
|
||||
/// The largest image file, in bytes, which the engine accepts in a chat request, where we know of one.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Like the limit of a cloud provider, see LLMProvidersExtensions.GetMaxImageSizeBytes, this
|
||||
/// Like the limit of a cloud provider, see LLMProvidersExtensions.MaxImageSizeBytes, this
|
||||
/// belongs to the API of the engine, not to the model. What we actually send is asked through
|
||||
/// IImageSourceExtensions.MaxImageSizeBytesFor.
|
||||
/// </remarks>
|
||||
/// <returns>The size limit of one image file, or null when the engine states none we know of.</returns>
|
||||
public long? GetMaxImageSizeBytes() => host switch
|
||||
/// <value>The size limit of one image file, or null when the engine states none we know of.</value>
|
||||
public long? MaxImageSizeBytes => host switch
|
||||
{
|
||||
//
|
||||
// llmman answers a chat request larger than 2 MiB with 413: its route /v1/chat/completions
|
||||
@@ -61,53 +61,62 @@ public static class HostExtensions
|
||||
_ => null,
|
||||
};
|
||||
|
||||
public bool IsChatSupported()
|
||||
public bool IsChatSupported
|
||||
{
|
||||
switch (host)
|
||||
get
|
||||
{
|
||||
case Host.WHISPER_CPP:
|
||||
return false;
|
||||
|
||||
default:
|
||||
case Host.OLLAMA:
|
||||
case Host.VLLM:
|
||||
case Host.LM_STUDIO:
|
||||
case Host.LLAMA_CPP:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
switch (host)
|
||||
{
|
||||
case Host.WHISPER_CPP:
|
||||
return false;
|
||||
|
||||
default:
|
||||
case Host.OLLAMA:
|
||||
case Host.VLLM:
|
||||
case Host.LM_STUDIO:
|
||||
case Host.LLAMA_CPP:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEmbeddingSupported()
|
||||
public bool IsEmbeddingSupported
|
||||
{
|
||||
switch (host)
|
||||
get
|
||||
{
|
||||
case Host.LM_STUDIO:
|
||||
case Host.OLLAMA:
|
||||
case Host.VLLM:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
|
||||
default:
|
||||
case Host.LLAMA_CPP:
|
||||
return false;
|
||||
switch (host)
|
||||
{
|
||||
case Host.LM_STUDIO:
|
||||
case Host.OLLAMA:
|
||||
case Host.VLLM:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
|
||||
default:
|
||||
case Host.LLAMA_CPP:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsTranscriptionSupported()
|
||||
public bool IsTranscriptionSupported
|
||||
{
|
||||
switch (host)
|
||||
get
|
||||
{
|
||||
case Host.OLLAMA:
|
||||
case Host.VLLM:
|
||||
case Host.WHISPER_CPP:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
switch (host)
|
||||
{
|
||||
case Host.OLLAMA:
|
||||
case Host.VLLM:
|
||||
case Host.WHISPER_CPP:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
|
||||
default:
|
||||
case Host.LM_STUDIO:
|
||||
case Host.LLAMA_CPP:
|
||||
return false;
|
||||
default:
|
||||
case Host.LM_STUDIO:
|
||||
case Host.LLAMA_CPP:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,22 +131,25 @@ public static class HostExtensions
|
||||
/// provider offers that model under a fixed name instead. llama.cpp is, even though builds
|
||||
/// older than the route answer it with 404; the provider handles those builds itself.
|
||||
/// </remarks>
|
||||
/// <returns>True when the models can be loaded from the engine; otherwise, false.</returns>
|
||||
public bool IsModelListSupported()
|
||||
/// <value>True when the models can be loaded from the engine; otherwise, false.</value>
|
||||
public bool IsModelListSupported
|
||||
{
|
||||
switch (host)
|
||||
get
|
||||
{
|
||||
case Host.LLAMA_CPP:
|
||||
case Host.OLLAMA:
|
||||
case Host.LM_STUDIO:
|
||||
case Host.VLLM:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
switch (host)
|
||||
{
|
||||
case Host.LLAMA_CPP:
|
||||
case Host.OLLAMA:
|
||||
case Host.LM_STUDIO:
|
||||
case Host.VLLM:
|
||||
case Host.LLMMAN:
|
||||
return true;
|
||||
|
||||
default:
|
||||
case Host.NONE:
|
||||
case Host.WHISPER_CPP:
|
||||
return false;
|
||||
default:
|
||||
case Host.NONE:
|
||||
case Host.WHISPER_CPP:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user