Код: Выделить всё
public ChatOllama(string? model = null, string? systemPrompt = null, Uri? endpoint = null, TimeSpan? timeout = null)
{
SystemPrompt = systemPrompt ?? SystemPrompt;
string ollamaModel = string.IsNullOrEmpty(model) ? DefaultModel : model.ToLower().Trim();
Uri ollamaEndpoint = endpoint ?? DefaultUri;
TimeSpan ollamaTimeout = timeout ?? DefaultHttpTimeout;
this.ollamaEndpoint = new HttpClient
{
Timeout = ollamaTimeout,
BaseAddress = ollamaEndpoint,
};
var builder = Kernel.CreateBuilder();
builder.Services.AddOllamaChatCompletion(
ollamaModel,
httpClient: this.ollamaEndpoint
);
var kernel = builder.Build();
m_chatService = kernel.GetRequiredService();
History.AddSystemMessage(SystemPrompt);
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... in-c-sharp
Мобильная версия