Thinking of the LangChain ver

This commit is contained in:
2025-10-25 16:40:00 +08:00
parent 19d833a522
commit bbcaa27ac5
30 changed files with 306 additions and 148 deletions

View File

@@ -0,0 +1,37 @@
using LangChain.Providers;
using LangChain.Providers.Ollama;
namespace DysonNetwork.Insight.Thinking;
public class ThinkingProvider
{
public readonly Provider Provider;
public readonly string? ModelProviderType;
public readonly string? ModelDefault;
public ThinkingProvider(IConfiguration configuration)
{
var cfg = configuration.GetSection("Thinking");
ModelProviderType = cfg.GetValue<string>("Provider")?.ToLower();
switch (ModelProviderType)
{
case "ollama":
var endpoint = cfg.GetValue<string>("Endpoint");
Provider = new OllamaProvider(endpoint ?? "http://localhost:11434/api");
break;
default:
throw new IndexOutOfRangeException("Unknown thinking provider: " + ModelProviderType);
}
ModelDefault = cfg.GetValue<string>("Model");
}
public ChatModel GetModel(string? name = null)
{
return ModelProviderType switch
{
"ollama" => new OllamaChatModel((Provider as OllamaProvider)!, (name ?? ModelDefault)!),
_ => throw new IndexOutOfRangeException("Unknown thinking provider: " + ModelProviderType),
};
}
}