mirror of https://github.com/abpframework/abp.git
8 changed files with 59 additions and 14 deletions
@ -0,0 +1,8 @@ |
|||||
|
using Microsoft.Extensions.AI; |
||||
|
|
||||
|
namespace Volo.Abp.AI; |
||||
|
|
||||
|
public class BuilderConfigurerList : NamedObjectList<NamedAction<ChatClientBuilder>> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -1,26 +1,18 @@ |
|||||
using System; |
using System; |
||||
using System.Collections.Concurrent; |
|
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
|
||||
namespace Volo.Abp.AI; |
namespace Volo.Abp.AI; |
||||
|
|
||||
public class ChatClientConfigurationCollection |
public class ChatClientConfigurationDictionary : Dictionary<string, ChatClientConfiguration> |
||||
{ |
{ |
||||
private readonly ConcurrentDictionary<string, ChatClientConfiguration> _chatClients = new(); |
|
||||
|
|
||||
public void Configure(string name, Action<ChatClientConfiguration> configureAction) |
public void Configure(string name, Action<ChatClientConfiguration> configureAction) |
||||
{ |
{ |
||||
if (!_chatClients.TryGetValue(name, out var configuration)) |
if (!this.TryGetValue(name, out var configuration)) |
||||
{ |
{ |
||||
configuration = new ChatClientConfiguration(name); |
configuration = new ChatClientConfiguration(name); |
||||
_chatClients[name] = configuration; |
this[name] = configuration; |
||||
} |
} |
||||
|
|
||||
configureAction(configuration); |
configureAction(configuration); |
||||
} |
} |
||||
|
} |
||||
internal IEnumerable<ChatClientConfiguration> GetAll() |
|
||||
{ |
|
||||
return _chatClients.Values; |
|
||||
} |
|
||||
} |
|
||||
|
|||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp.AI; |
||||
|
|
||||
|
public class NamedAction<T> : NamedObject //TODO: Move to Core package?
|
||||
|
{ |
||||
|
public Action<T> Action { get; set; } |
||||
|
|
||||
|
public NamedAction(string name, Action<T> action) |
||||
|
: base(name) |
||||
|
{ |
||||
|
Action = Check.NotNull(action, nameof(action)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
namespace Volo.Abp.AI; |
||||
|
|
||||
|
public class NamedObject //TODO: Move to Core package?
|
||||
|
{ |
||||
|
public string Name { get; } |
||||
|
|
||||
|
public NamedObject(string name) |
||||
|
{ |
||||
|
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.AI; |
||||
|
|
||||
|
public class NamedObjectList<T> : List<T> |
||||
|
where T : NamedObject |
||||
|
{ |
||||
|
public NamedObjectList() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue