Browse Source

feat: Rename Workspace to WorkspaceDefinitionRecord

pull/1421/head
colin 2 months ago
parent
commit
11dfe9af09
  1. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain.Shared/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceDefinitionRecordConsts.cs
  2. 8
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/DynamicWorkspaceDefinitionStore.cs
  3. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/DynamicWorkspaceDefinitionStoreInMemoryCache.cs
  4. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IDynamicWorkspaceDefinitionStoreInMemoryCache.cs
  5. 4
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceDefinitionRecordRepository.cs
  6. 4
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceDefinitionSerializer.cs
  7. 16
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/StaticWorkspaceSaver.cs
  8. 30
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceDefinitionRecord.cs
  9. 8
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceDefinitionSerializer.cs
  10. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContext.cs
  11. 24
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContextModelBuilderExtensions.cs
  12. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AbpAIManagementEntityFrameworkCoreModule.cs
  13. 6
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/EfCoreWorkspaceDefinitionRecordRepository.cs
  14. 2
      aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/IAIManagementDbContext.cs

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain.Shared/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceConsts.cs → aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain.Shared/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceDefinitionRecordConsts.cs

@ -1,5 +1,5 @@
namespace LINGYUN.Abp.AIManagement.Workspaces; namespace LINGYUN.Abp.AIManagement.Workspaces;
public static class WorkspaceConsts public static class WorkspaceDefinitionRecordConsts
{ {
public static int MaxNameLength { get; set; } = 64; public static int MaxNameLength { get; set; } = 64;
public static int MaxProviderLength { get; set; } = 20; public static int MaxProviderLength { get; set; } = 20;

8
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/DynamicWorkspaceDefinitionStore.cs

@ -16,7 +16,7 @@ namespace LINGYUN.Abp.AIManagement.Workspaces;
[Dependency(ReplaceServices = true)] [Dependency(ReplaceServices = true)]
public class DynamicWorkspaceDefinitionStore : IDynamicWorkspaceDefinitionStore, ITransientDependency public class DynamicWorkspaceDefinitionStore : IDynamicWorkspaceDefinitionStore, ITransientDependency
{ {
protected IWorkspaceRepository WorkspaceRepository { get; } protected IWorkspaceDefinitionRecordRepository WorkspaceDefinitionRecordRepository { get; }
protected IWorkspaceDefinitionSerializer WorkspaceDefinitionSerializer { get; } protected IWorkspaceDefinitionSerializer WorkspaceDefinitionSerializer { get; }
protected IDynamicWorkspaceDefinitionStoreInMemoryCache StoreCache { get; } protected IDynamicWorkspaceDefinitionStoreInMemoryCache StoreCache { get; }
protected IDistributedCache DistributedCache { get; } protected IDistributedCache DistributedCache { get; }
@ -25,7 +25,7 @@ public class DynamicWorkspaceDefinitionStore : IDynamicWorkspaceDefinitionStore,
protected AbpDistributedCacheOptions CacheOptions { get; } protected AbpDistributedCacheOptions CacheOptions { get; }
public DynamicWorkspaceDefinitionStore( public DynamicWorkspaceDefinitionStore(
IWorkspaceRepository workspaceRepository, IWorkspaceDefinitionRecordRepository workspaceRepository,
IWorkspaceDefinitionSerializer workspaceDefinitionSerializer, IWorkspaceDefinitionSerializer workspaceDefinitionSerializer,
IDynamicWorkspaceDefinitionStoreInMemoryCache storeCache, IDynamicWorkspaceDefinitionStoreInMemoryCache storeCache,
IDistributedCache distributedCache, IDistributedCache distributedCache,
@ -33,7 +33,7 @@ public class DynamicWorkspaceDefinitionStore : IDynamicWorkspaceDefinitionStore,
IOptions<AIManagementOptions> aiManagementOptions, IOptions<AIManagementOptions> aiManagementOptions,
IAbpDistributedLock distributedLock) IAbpDistributedLock distributedLock)
{ {
WorkspaceRepository = workspaceRepository; WorkspaceDefinitionRecordRepository = workspaceRepository;
WorkspaceDefinitionSerializer = workspaceDefinitionSerializer; WorkspaceDefinitionSerializer = workspaceDefinitionSerializer;
StoreCache = storeCache; StoreCache = storeCache;
DistributedCache = distributedCache; DistributedCache = distributedCache;
@ -103,7 +103,7 @@ public class DynamicWorkspaceDefinitionStore : IDynamicWorkspaceDefinitionStore,
protected virtual async Task UpdateInMemoryStoreCache() protected virtual async Task UpdateInMemoryStoreCache()
{ {
var workspaces = await WorkspaceRepository.GetListAsync(); var workspaces = await WorkspaceDefinitionRecordRepository.GetListAsync();
await StoreCache.FillAsync(workspaces); await StoreCache.FillAsync(workspaces);
} }

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/DynamicWorkspaceDefinitionStoreInMemoryCache.cs

@ -30,7 +30,7 @@ public class DynamicWorkspaceDefinitionStoreInMemoryCache : IDynamicWorkspaceDef
WorkspaceDefinitions = new Dictionary<string, WorkspaceDefinition>(); WorkspaceDefinitions = new Dictionary<string, WorkspaceDefinition>();
} }
public Task FillAsync(List<Workspace> workspaces) public Task FillAsync(List<WorkspaceDefinitionRecord> workspaces)
{ {
WorkspaceDefinitions.Clear(); WorkspaceDefinitions.Clear();

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IDynamicWorkspaceDefinitionStoreInMemoryCache.cs

@ -14,7 +14,7 @@ public interface IDynamicWorkspaceDefinitionStoreInMemoryCache
DateTime? LastCheckTime { get; set; } DateTime? LastCheckTime { get; set; }
Task FillAsync(List<Workspace> permissions); Task FillAsync(List<WorkspaceDefinitionRecord> permissions);
WorkspaceDefinition? GetWorkspaceOrNull(string name); WorkspaceDefinition? GetWorkspaceOrNull(string name);

4
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceRepository.cs → aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceDefinitionRecordRepository.cs

@ -4,9 +4,9 @@ using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
namespace LINGYUN.Abp.AIManagement.Workspaces; namespace LINGYUN.Abp.AIManagement.Workspaces;
public interface IWorkspaceRepository : IBasicRepository<Workspace, Guid> public interface IWorkspaceDefinitionRecordRepository : IBasicRepository<WorkspaceDefinitionRecord, Guid>
{ {
Task<Workspace?> FindByNameAsync( Task<WorkspaceDefinitionRecord?> FindByNameAsync(
string name, string name,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
} }

4
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/IWorkspaceDefinitionSerializer.cs

@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace LINGYUN.Abp.AIManagement.Workspaces; namespace LINGYUN.Abp.AIManagement.Workspaces;
public interface IWorkspaceDefinitionSerializer public interface IWorkspaceDefinitionSerializer
{ {
Task<Workspace[]> SerializeAsync(IEnumerable<WorkspaceDefinition> definitions); Task<WorkspaceDefinitionRecord[]> SerializeAsync(IEnumerable<WorkspaceDefinition> definitions);
Task<Workspace> SerializeAsync(WorkspaceDefinition definition); Task<WorkspaceDefinitionRecord> SerializeAsync(WorkspaceDefinition definition);
} }

16
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/StaticWorkspaceSaver.cs

@ -22,7 +22,7 @@ namespace LINGYUN.Abp.AIManagement.Workspaces;
public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency
{ {
protected IStaticWorkspaceDefinitionStore StaticStore { get; } protected IStaticWorkspaceDefinitionStore StaticStore { get; }
protected IWorkspaceRepository WorkspaceRepository { get; } protected IWorkspaceDefinitionRecordRepository WorkspaceRepository { get; }
protected IWorkspaceDefinitionSerializer WorkspaceSerializer { get; } protected IWorkspaceDefinitionSerializer WorkspaceSerializer { get; }
protected IDistributedCache Cache { get; } protected IDistributedCache Cache { get; }
protected IApplicationInfoAccessor ApplicationInfoAccessor { get; } protected IApplicationInfoAccessor ApplicationInfoAccessor { get; }
@ -35,7 +35,7 @@ public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency
public StaticWorkspaceSaver( public StaticWorkspaceSaver(
IStaticWorkspaceDefinitionStore staticStore, IStaticWorkspaceDefinitionStore staticStore,
IWorkspaceRepository workspaceRepository, IWorkspaceDefinitionRecordRepository workspaceRepository,
IWorkspaceDefinitionSerializer workspaceSerializer, IWorkspaceDefinitionSerializer workspaceSerializer,
IDistributedCache cache, IDistributedCache cache,
IOptions<AbpDistributedCacheOptions> cacheOptions, IOptions<AbpDistributedCacheOptions> cacheOptions,
@ -140,10 +140,10 @@ public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency
); );
} }
private async Task<bool> UpdateChangedWorkspacesAsync(Workspace[] workspaces) private async Task<bool> UpdateChangedWorkspacesAsync(WorkspaceDefinitionRecord[] workspaces)
{ {
var newRecords = new List<Workspace>(); var newRecords = new List<WorkspaceDefinitionRecord>();
var changedRecords = new List<Workspace>(); var changedRecords = new List<WorkspaceDefinitionRecord>();
var workspaceRecordsInDatabase = (await WorkspaceRepository.GetListAsync()).ToDictionary(x => x.Name); var workspaceRecordsInDatabase = (await WorkspaceRepository.GetListAsync()).ToDictionary(x => x.Name);
@ -169,7 +169,7 @@ public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency
} }
/* Deleted */ /* Deleted */
var deletedRecords = new List<Workspace>(); var deletedRecords = new List<WorkspaceDefinitionRecord>();
if (AIOptions.DeletedWorkspaces.Any()) if (AIOptions.DeletedWorkspaces.Any())
{ {
@ -214,7 +214,7 @@ public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency
return $"{CacheOptions.KeyPrefix}_AbpInMemoryWorkspaceCacheStamp"; return $"{CacheOptions.KeyPrefix}_AbpInMemoryWorkspaceCacheStamp";
} }
private string CalculateHash(Workspace[] workspaces, IEnumerable<string> deletedWorkspaces) private string CalculateHash(WorkspaceDefinitionRecord[] workspaces, IEnumerable<string> deletedWorkspaces)
{ {
var jsonSerializerOptions = new JsonSerializerOptions var jsonSerializerOptions = new JsonSerializerOptions
{ {
@ -222,7 +222,7 @@ public class StaticWorkspaceSaver : IStaticWorkspaceSaver, ITransientDependency
{ {
Modifiers = Modifiers =
{ {
new AbpIgnorePropertiesModifiers<Workspace, Guid>().CreateModifyAction(x => x.Id), new AbpIgnorePropertiesModifiers<WorkspaceDefinitionRecord, Guid>().CreateModifyAction(x => x.Id),
} }
} }
}; };

30
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/Workspace.cs → aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceDefinitionRecord.cs

@ -4,7 +4,7 @@ using Volo.Abp.Data;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
namespace LINGYUN.Abp.AIManagement.Workspaces; namespace LINGYUN.Abp.AIManagement.Workspaces;
public class Workspace : AuditedAggregateRoot<Guid> public class WorkspaceDefinitionRecord : AuditedAggregateRoot<Guid>
{ {
public string Name { get; private set; } public string Name { get; private set; }
@ -36,13 +36,13 @@ public class Workspace : AuditedAggregateRoot<Guid>
public string? StateCheckers { get; set; } public string? StateCheckers { get; set; }
protected Workspace() protected WorkspaceDefinitionRecord()
{ {
ExtraProperties = new ExtraPropertyDictionary(); ExtraProperties = new ExtraPropertyDictionary();
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties();
} }
public Workspace( public WorkspaceDefinitionRecord(
Guid id, Guid id,
string name, string name,
string provider, string provider,
@ -60,16 +60,16 @@ public class Workspace : AuditedAggregateRoot<Guid>
string? stateCheckers = null) string? stateCheckers = null)
: base(id) : base(id)
{ {
Name = Check.NotNullOrWhiteSpace(name, nameof(name), WorkspaceConsts.MaxNameLength); Name = Check.NotNullOrWhiteSpace(name, nameof(name), WorkspaceDefinitionRecordConsts.MaxNameLength);
Provider = Check.NotNullOrWhiteSpace(provider, nameof(provider), WorkspaceConsts.MaxProviderLength); Provider = Check.NotNullOrWhiteSpace(provider, nameof(provider), WorkspaceDefinitionRecordConsts.MaxProviderLength);
ModelName = Check.NotNullOrWhiteSpace(modelName, nameof(modelName), WorkspaceConsts.MaxModelNameLength); ModelName = Check.NotNullOrWhiteSpace(modelName, nameof(modelName), WorkspaceDefinitionRecordConsts.MaxModelNameLength);
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), WorkspaceConsts.MaxDisplayNameLength); DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), WorkspaceDefinitionRecordConsts.MaxDisplayNameLength);
Description = Check.Length(description, nameof(description), WorkspaceConsts.MaxDescriptionLength); Description = Check.Length(description, nameof(description), WorkspaceDefinitionRecordConsts.MaxDescriptionLength);
ApiKey = Check.Length(apiKey, nameof(apiKey), WorkspaceConsts.MaxApiKeyLength); ApiKey = Check.Length(apiKey, nameof(apiKey), WorkspaceDefinitionRecordConsts.MaxApiKeyLength);
ApiBaseUrl = Check.Length(apiBaseUrl, nameof(apiBaseUrl), WorkspaceConsts.MaxApiBaseUrlLength); ApiBaseUrl = Check.Length(apiBaseUrl, nameof(apiBaseUrl), WorkspaceDefinitionRecordConsts.MaxApiBaseUrlLength);
SystemPrompt = Check.Length(systemPrompt, nameof(systemPrompt), WorkspaceConsts.MaxSystemPromptLength); SystemPrompt = Check.Length(systemPrompt, nameof(systemPrompt), WorkspaceDefinitionRecordConsts.MaxSystemPromptLength);
Instructions = Check.Length(instructions, nameof(instructions), WorkspaceConsts.MaxInstructionsLength); Instructions = Check.Length(instructions, nameof(instructions), WorkspaceDefinitionRecordConsts.MaxInstructionsLength);
StateCheckers = Check.Length(stateCheckers, nameof(stateCheckers), WorkspaceConsts.MaxStateCheckersLength); StateCheckers = Check.Length(stateCheckers, nameof(stateCheckers), WorkspaceDefinitionRecordConsts.MaxStateCheckersLength);
Temperature = temperature; Temperature = temperature;
MaxOutputTokens = maxOutputTokens; MaxOutputTokens = maxOutputTokens;
FrequencyPenalty = frequencyPenalty; FrequencyPenalty = frequencyPenalty;
@ -80,7 +80,7 @@ public class Workspace : AuditedAggregateRoot<Guid>
this.SetDefaultsForExtraProperties(); this.SetDefaultsForExtraProperties();
} }
public bool HasSameData(Workspace otherWorkspace) public bool HasSameData(WorkspaceDefinitionRecord otherWorkspace)
{ {
if (Name != otherWorkspace.Name) if (Name != otherWorkspace.Name)
{ {
@ -165,7 +165,7 @@ public class Workspace : AuditedAggregateRoot<Guid>
return true; return true;
} }
public void Patch(Workspace otherWorkspace) public void Patch(WorkspaceDefinitionRecord otherWorkspace)
{ {
if (Name != otherWorkspace.Name) if (Name != otherWorkspace.Name)
{ {

8
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.Domain/LINGYUN/Abp/AIManagement/Workspaces/WorkspaceDefinitionSerializer.cs

@ -25,9 +25,9 @@ public class WorkspaceDefinitionSerializer : IWorkspaceDefinitionSerializer, ITr
LocalizableStringSerializer = localizableStringSerializer; LocalizableStringSerializer = localizableStringSerializer;
} }
public async virtual Task<Workspace[]> SerializeAsync(IEnumerable<WorkspaceDefinition> definitions) public async virtual Task<WorkspaceDefinitionRecord[]> SerializeAsync(IEnumerable<WorkspaceDefinition> definitions)
{ {
var records = new List<Workspace>(); var records = new List<WorkspaceDefinitionRecord>();
foreach (var workspaceDef in definitions) foreach (var workspaceDef in definitions)
{ {
records.Add(await SerializeAsync(workspaceDef)); records.Add(await SerializeAsync(workspaceDef));
@ -36,11 +36,11 @@ public class WorkspaceDefinitionSerializer : IWorkspaceDefinitionSerializer, ITr
return records.ToArray(); return records.ToArray();
} }
public virtual Task<Workspace> SerializeAsync(WorkspaceDefinition definition) public virtual Task<WorkspaceDefinitionRecord> SerializeAsync(WorkspaceDefinition definition)
{ {
using (CultureHelper.Use(CultureInfo.InvariantCulture)) using (CultureHelper.Use(CultureInfo.InvariantCulture))
{ {
var workspace = new Workspace( var workspace = new WorkspaceDefinitionRecord(
GuidGenerator.Create(), GuidGenerator.Create(),
definition.Name, definition.Name,
definition.Provider, definition.Provider,

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContext.cs

@ -8,7 +8,7 @@ namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
[ConnectionStringName(AbpAIManagementDbProperties.ConnectionStringName)] [ConnectionStringName(AbpAIManagementDbProperties.ConnectionStringName)]
public class AIManagementDbContext : AbpDbContext<AIManagementDbContext>, IAIManagementDbContext public class AIManagementDbContext : AbpDbContext<AIManagementDbContext>, IAIManagementDbContext
{ {
public DbSet<Workspace> Workspaces { get; set; } public DbSet<WorkspaceDefinitionRecord> Workspaces { get; set; }
public AIManagementDbContext( public AIManagementDbContext(
DbContextOptions<AIManagementDbContext> options) : base(options) DbContextOptions<AIManagementDbContext> options) : base(options)
{ {

24
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AIManagementDbContextModelBuilderExtensions.cs

@ -17,22 +17,22 @@ public static class AIManagementDbContextModelBuilderExtensions
return; return;
} }
builder.Entity<Workspace>(b => builder.Entity<WorkspaceDefinitionRecord>(b =>
{ {
b.ToTable(AbpAIManagementDbProperties.DbTablePrefix + "Workspaces", AbpAIManagementDbProperties.DbSchema); b.ToTable(AbpAIManagementDbProperties.DbTablePrefix + "WorkspaceDefinitions", AbpAIManagementDbProperties.DbSchema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.Name).HasMaxLength(WorkspaceConsts.MaxNameLength).IsRequired(); b.Property(x => x.Name).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxNameLength).IsRequired();
b.Property(x => x.Provider).HasMaxLength(WorkspaceConsts.MaxProviderLength).IsRequired(); b.Property(x => x.Provider).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxProviderLength).IsRequired();
b.Property(x => x.ModelName).HasMaxLength(WorkspaceConsts.MaxModelNameLength).IsRequired(); b.Property(x => x.ModelName).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxModelNameLength).IsRequired();
b.Property(x => x.DisplayName).HasMaxLength(WorkspaceConsts.MaxDisplayNameLength).IsRequired(); b.Property(x => x.DisplayName).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxDisplayNameLength).IsRequired();
b.Property(x => x.Description).HasMaxLength(WorkspaceConsts.MaxDescriptionLength); b.Property(x => x.Description).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxDescriptionLength);
b.Property(x => x.ApiKey).HasMaxLength(WorkspaceConsts.MaxApiKeyLength); b.Property(x => x.ApiKey).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxApiKeyLength);
b.Property(x => x.ApiBaseUrl).HasMaxLength(WorkspaceConsts.MaxApiKeyLength); b.Property(x => x.ApiBaseUrl).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxApiKeyLength);
b.Property(x => x.SystemPrompt).HasMaxLength(WorkspaceConsts.MaxSystemPromptLength); b.Property(x => x.SystemPrompt).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxSystemPromptLength);
b.Property(x => x.Instructions).HasMaxLength(WorkspaceConsts.MaxInstructionsLength); b.Property(x => x.Instructions).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxInstructionsLength);
b.Property(x => x.StateCheckers).HasMaxLength(WorkspaceConsts.MaxStateCheckersLength); b.Property(x => x.StateCheckers).HasMaxLength(WorkspaceDefinitionRecordConsts.MaxStateCheckersLength);
b.HasIndex(x => new { x.Name }).IsUnique(); b.HasIndex(x => new { x.Name }).IsUnique();

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/AbpAIManagementEntityFrameworkCoreModule.cs

@ -16,7 +16,7 @@ public class AbpAIManagementEntityFrameworkCoreModule : AbpModule
{ {
options.AddDefaultRepositories<IAIManagementDbContext>(); options.AddDefaultRepositories<IAIManagementDbContext>();
options.AddRepository<Workspace, EfCoreWorkspaceRepository>(); options.AddRepository<WorkspaceDefinitionRecord, EfCoreWorkspaceDefinitionRecordRepository>();
}); });
} }
} }

6
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/EfCoreWorkspaceRepository.cs → aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/EfCoreWorkspaceDefinitionRecordRepository.cs

@ -9,15 +9,15 @@ using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore; namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
public class EfCoreWorkspaceRepository : EfCoreRepository<IAIManagementDbContext, Workspace, Guid>, IWorkspaceRepository public class EfCoreWorkspaceDefinitionRecordRepository : EfCoreRepository<IAIManagementDbContext, WorkspaceDefinitionRecord, Guid>, IWorkspaceDefinitionRecordRepository
{ {
public EfCoreWorkspaceRepository( public EfCoreWorkspaceDefinitionRecordRepository(
IDbContextProvider<IAIManagementDbContext> dbContextProvider) IDbContextProvider<IAIManagementDbContext> dbContextProvider)
: base(dbContextProvider) : base(dbContextProvider)
{ {
} }
public async virtual Task<Workspace?> FindByNameAsync(string name, CancellationToken cancellationToken = default) public async virtual Task<WorkspaceDefinitionRecord?> FindByNameAsync(string name, CancellationToken cancellationToken = default)
{ {
return await (await GetQueryableAsync()) return await (await GetQueryableAsync())
.Where(x => x.Name == name) .Where(x => x.Name == name)

2
aspnet-core/modules/ai/LINGYUN.Abp.AIManagement.EntityFrameworkCore/LINGYUN/Abp/AIManagement/EntityFrameworkCore/IAIManagementDbContext.cs

@ -8,5 +8,5 @@ namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore;
[ConnectionStringName(AbpAIManagementDbProperties.ConnectionStringName)] [ConnectionStringName(AbpAIManagementDbProperties.ConnectionStringName)]
public interface IAIManagementDbContext : IEfCoreDbContext public interface IAIManagementDbContext : IEfCoreDbContext
{ {
DbSet<Workspace> Workspaces { get; } DbSet<WorkspaceDefinitionRecord> Workspaces { get; }
} }

Loading…
Cancel
Save