Skip to content

Commit 6cb85f0

Browse files
Flows (#95)
* Temp. * Temp * Temp * Added icons. * Fix subscription. * Add tests for flows. * More tests * More tests * More tests * Missing files. * Temporary. * Cleanup. * Improvements. * Improve tests. * Fix tests. * Fix tests * Improved steps and tests * Fix package build. * Update version. * Improve tests and equals * Fix table name. * Change schema. * Fix tests * Cleanup. * Reduce key length. * Fix flows. * Flow improvements * Fix hash * Flow equality fixes. * Cron job manager. * Use test collections. * Update version. * Add validation methods. * Rename cron jobs. * Provide timezones. * Fix nullable. * Add worker. * Fix method name. * Fix generic constraints. * Fix. * Dump improvements. * Update events. * Fix initialization. * Update function * Update table name. * Fix position. * Fix tests * Fix length limit in mysql. * More tests * SQL Server fix. * Argh * Using Phenx * Fix tests * Fix schema. * More PhenX * Decouple bulk inserter. * Load history * Use another method to test assets.
1 parent fc2cbc5 commit 6cb85f0

File tree

329 files changed

+9928
-1350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+9928
-1350
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ uploads/
1818

1919
# Test Output
2020
_test-output/
21+
TestResults
2122

2223
# NodeJS
2324
node_modules/
@@ -26,4 +27,5 @@ docker-build.ps1
2627
appSettings.Development.json
2728
appSettings.Production.json
2829
launchSettings.json
30+
*.received.txt
2931

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageProjectUrl>https://github.com/squidex/squidex</PackageProjectUrl>
1212
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1313
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
14-
<Version>6.37.0</Version>
14+
<Version>7.23.0</Version>
1515
</PropertyGroup>
1616

1717
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

Squidex.Libs.sln

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.AI", "ai\Squidex.AI
8787
EndProject
8888
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.AI.Tests", "ai\Squidex.AI.Tests\Squidex.AI.Tests.csproj", "{AD46BEF0-33C8-4994-B242-0D9E4C50488F}"
8989
EndProject
90-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.AI.Mongo", "ai\Squidex.AI.Mongo\Squidex.AI.Mongo.csproj", "{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}"
90+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "flows", "flows", "{67DB170D-E43B-431F-AE3A-2730FC631D12}"
91+
EndProject
92+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Flows", "flows\Squidex.Flows\Squidex.Flows.csproj", "{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC}"
93+
EndProject
94+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Flows.Tests", "flows\Squidex.Flows.Tests\Squidex.Flows.Tests.csproj", "{CC9096C3-1FAD-42CD-AA50-622BE68BC78D}"
95+
EndProject
96+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Flows.Mongo", "flows\Squidex.Flows.Mongo\Squidex.Flows.Mongo.csproj", "{559B7D03-755C-4233-A055-670ABF8D4D58}"
97+
EndProject
98+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.AI.Mongo", "ai\Squidex.AI.Mongo\Squidex.AI.Mongo.csproj", "{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}"
9199
EndProject
92100
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.AI.EntityFramework", "ai\Squidex.AI.EntityFramework\Squidex.AI.EntityFramework.csproj", "{F15850C7-D623-4CBE-ABE0-07D9822B9326}"
93101
EndProject
@@ -107,6 +115,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.Events.GetEventStor
107115
EndProject
108116
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Assets.EntityFramework", "assets\Squidex.Assets.EntityFramework\Squidex.Assets.EntityFramework.csproj", "{C3D35ED4-8C81-449B-B732-3F0EE1FD6C7A}"
109117
EndProject
118+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.Flows.EntityFramework", "flows\Squidex.Flows.EntityFramework\Squidex.Flows.EntityFramework.csproj", "{A38F612A-BF14-45E5-B025-D7218074E154}"
119+
EndProject
120+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestHelpers", "utils\TestHelpers\TestHelpers.csproj", "{4E93A424-2190-491C-909F-40A5A06F36B7}"
121+
EndProject
110122
Global
111123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
112124
Debug|Any CPU = Debug|Any CPU
@@ -253,6 +265,18 @@ Global
253265
{AD46BEF0-33C8-4994-B242-0D9E4C50488F}.Debug|Any CPU.Build.0 = Debug|Any CPU
254266
{AD46BEF0-33C8-4994-B242-0D9E4C50488F}.Release|Any CPU.ActiveCfg = Release|Any CPU
255267
{AD46BEF0-33C8-4994-B242-0D9E4C50488F}.Release|Any CPU.Build.0 = Release|Any CPU
268+
{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
269+
{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
270+
{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
271+
{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC}.Release|Any CPU.Build.0 = Release|Any CPU
272+
{CC9096C3-1FAD-42CD-AA50-622BE68BC78D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
273+
{CC9096C3-1FAD-42CD-AA50-622BE68BC78D}.Debug|Any CPU.Build.0 = Debug|Any CPU
274+
{CC9096C3-1FAD-42CD-AA50-622BE68BC78D}.Release|Any CPU.ActiveCfg = Release|Any CPU
275+
{CC9096C3-1FAD-42CD-AA50-622BE68BC78D}.Release|Any CPU.Build.0 = Release|Any CPU
276+
{559B7D03-755C-4233-A055-670ABF8D4D58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
277+
{559B7D03-755C-4233-A055-670ABF8D4D58}.Debug|Any CPU.Build.0 = Debug|Any CPU
278+
{559B7D03-755C-4233-A055-670ABF8D4D58}.Release|Any CPU.ActiveCfg = Release|Any CPU
279+
{559B7D03-755C-4233-A055-670ABF8D4D58}.Release|Any CPU.Build.0 = Release|Any CPU
256280
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
257281
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
258282
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -289,6 +313,14 @@ Global
289313
{C3D35ED4-8C81-449B-B732-3F0EE1FD6C7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
290314
{C3D35ED4-8C81-449B-B732-3F0EE1FD6C7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
291315
{C3D35ED4-8C81-449B-B732-3F0EE1FD6C7A}.Release|Any CPU.Build.0 = Release|Any CPU
316+
{A38F612A-BF14-45E5-B025-D7218074E154}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
317+
{A38F612A-BF14-45E5-B025-D7218074E154}.Debug|Any CPU.Build.0 = Debug|Any CPU
318+
{A38F612A-BF14-45E5-B025-D7218074E154}.Release|Any CPU.ActiveCfg = Release|Any CPU
319+
{A38F612A-BF14-45E5-B025-D7218074E154}.Release|Any CPU.Build.0 = Release|Any CPU
320+
{4E93A424-2190-491C-909F-40A5A06F36B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
321+
{4E93A424-2190-491C-909F-40A5A06F36B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
322+
{4E93A424-2190-491C-909F-40A5A06F36B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
323+
{4E93A424-2190-491C-909F-40A5A06F36B7}.Release|Any CPU.Build.0 = Release|Any CPU
292324
EndGlobalSection
293325
GlobalSection(SolutionProperties) = preSolution
294326
HideSolutionNode = FALSE
@@ -329,6 +361,9 @@ Global
329361
{B4461E6B-81ED-4C3D-86D6-03C2B367DB15} = {C857F3ED-A6AE-47C6-A115-87ECCB36AC02}
330362
{A4EAB4B8-096D-4F4F-85E1-A1385B26680B} = {F18E275B-4805-4DCB-BE31-ACC314FB508E}
331363
{AD46BEF0-33C8-4994-B242-0D9E4C50488F} = {F18E275B-4805-4DCB-BE31-ACC314FB508E}
364+
{A11B0218-3FCB-46F4-B3B6-B56A36BA02BC} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
365+
{CC9096C3-1FAD-42CD-AA50-622BE68BC78D} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
366+
{559B7D03-755C-4233-A055-670ABF8D4D58} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
332367
{98AE3491-7D34-498B-8A8F-14BDAAF37AD3} = {F18E275B-4805-4DCB-BE31-ACC314FB508E}
333368
{F15850C7-D623-4CBE-ABE0-07D9822B9326} = {F18E275B-4805-4DCB-BE31-ACC314FB508E}
334369
{F653DF48-6ED7-45A0-B630-88E783202A64} = {28B7D0BB-1971-4802-BC40-28297D644B26}
@@ -338,6 +373,7 @@ Global
338373
{E36DAC0D-8A2D-49AA-B9C4-E74CAB0660B0} = {94285572-6875-4A9C-AFC4-987758DC9088}
339374
{98156A5E-1B4A-46EF-AA84-019868425D80} = {94285572-6875-4A9C-AFC4-987758DC9088}
340375
{C3D35ED4-8C81-449B-B732-3F0EE1FD6C7A} = {C857F3ED-A6AE-47C6-A115-87ECCB36AC02}
376+
{A38F612A-BF14-45E5-B025-D7218074E154} = {67DB170D-E43B-431F-AE3A-2730FC631D12}
341377
EndGlobalSection
342378
GlobalSection(ExtensibilityGlobals) = postSolution
343379
SolutionGuid = {060512DD-34DA-4929-A67F-2E473577FBF5}

ai/Squidex.AI.EntityFramework/EFChatStore.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public async Task RemoveAsync(string conversationId,
1919
{
2020
ArgumentException.ThrowIfNullOrWhiteSpace(conversationId);
2121

22-
await using var context = await dbContextFactory.CreateDbContextAsync(ct);
22+
await using var dbContext = await dbContextFactory.CreateDbContextAsync(ct);
2323

24-
await context.Set<EFChatEntity>().Where(x => x.Id == conversationId)
24+
await dbContext.Set<EFChatEntity>().Where(x => x.Id == conversationId)
2525
.ExecuteDeleteAsync(ct);
2626
}
2727

@@ -30,9 +30,9 @@ await context.Set<EFChatEntity>().Where(x => x.Id == conversationId)
3030
{
3131
ArgumentException.ThrowIfNullOrWhiteSpace(conversationId);
3232

33-
await using var context = await dbContextFactory.CreateDbContextAsync(ct);
33+
await using var dbContext = await dbContextFactory.CreateDbContextAsync(ct);
3434

35-
var entity = await context.Set<EFChatEntity>().Where(x => x.Id == conversationId).FirstOrDefaultAsync(ct);
35+
var entity = await dbContext.Set<EFChatEntity>().Where(x => x.Id == conversationId).FirstOrDefaultAsync(ct);
3636
if (entity == null)
3737
{
3838
return null;
@@ -53,9 +53,9 @@ public async Task StoreAsync(string conversationId, Conversation conversation, D
5353
var json = JsonSerializer.Serialize(conversation) ??
5454
throw new ChatException($"Cannot serialize conversion with ID '{conversationId}'.");
5555

56-
await using var context = await dbContextFactory.CreateDbContextAsync(ct);
56+
await using var dbContext = await dbContextFactory.CreateDbContextAsync(ct);
5757

58-
var entity = await context.Set<EFChatEntity>().Where(x => x.Id == conversationId).FirstOrDefaultAsync(ct);
58+
var entity = await dbContext.Set<EFChatEntity>().Where(x => x.Id == conversationId).FirstOrDefaultAsync(ct);
5959
if (entity != null)
6060
{
6161
entity.LastUpdated = now;
@@ -72,18 +72,18 @@ public async Task StoreAsync(string conversationId, Conversation conversation, D
7272
Value = json,
7373
};
7474

75-
await context.Set<EFChatEntity>().AddAsync(entity, ct);
75+
await dbContext.Set<EFChatEntity>().AddAsync(entity, ct);
7676
}
7777

78-
await context.SaveChangesAsync(ct);
78+
await dbContext.SaveChangesAsync(ct);
7979
}
8080

8181
public async IAsyncEnumerable<(string Id, Conversation Value)> QueryAsync(DateTime olderThan,
8282
[EnumeratorCancellation] CancellationToken ct)
8383
{
84-
await using var context = await dbContextFactory.CreateDbContextAsync(ct);
84+
await using var dbContext = await dbContextFactory.CreateDbContextAsync(ct);
8585

86-
var records = context.Set<EFChatEntity>().Where(x => x.LastUpdated < olderThan).ToAsyncEnumerable();
86+
var records = dbContext.Set<EFChatEntity>().Where(x => x.LastUpdated < olderThan).AsAsyncEnumerable();
8787

8888
await foreach (var entity in records.WithCancellation(ct))
8989
{

ai/Squidex.AI.EntityFramework/EFSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public static ModelBuilder UseChatStore(this ModelBuilder modelBuilder)
1616
modelBuilder.Entity<EFChatEntity>(b =>
1717
{
1818
b.ToTable("Chats");
19-
2019
b.HasIndex(x => x.LastUpdated);
20+
b.Property(x => x.Id).HasMaxLength(255);
2121
});
2222

2323
return modelBuilder;

ai/Squidex.AI.EntityFramework/Squidex.AI.EntityFramework.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>
19-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
20-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.11" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.16" />
20+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
2121
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

ai/Squidex.AI.Mongo/Squidex.AI.Mongo.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>
19+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
1920
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
2021
<PrivateAssets>all</PrivateAssets>
2122
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// ==========================================================================
2+
// Squidex Headless CMS
3+
// ==========================================================================
4+
// Copyright (c) Squidex UG (haftungsbeschraenkt)
5+
// All rights reserved. Licensed under the MIT license.
6+
// ==========================================================================
7+
8+
using Microsoft.Extensions.Options;
9+
using Squidex.AI.Implementation;
10+
11+
namespace Squidex.AI;
12+
13+
public class ChatAgentTests
14+
{
15+
private readonly IChatProvider chatProvider = A.Fake<IChatProvider>();
16+
private readonly IChatStore chatStore = A.Fake<IChatStore>();
17+
private readonly ChatAgent sut;
18+
19+
public ChatAgentTests()
20+
{
21+
sut = new ChatAgent(chatProvider, chatStore, [], [], Options.Create(new ChatOptions()));
22+
}
23+
24+
[Fact]
25+
public async Task Should_provider_history_without_system_messages_if_requested()
26+
{
27+
var conversationId = Guid.NewGuid().ToString();
28+
var conversation = new Conversation
29+
{
30+
History =
31+
[
32+
new ChatMessage { Content = "Message1", Type = ChatMessageType.User },
33+
new ChatMessage { Content = "Message2", Type = ChatMessageType.System },
34+
new ChatMessage { Content = "Message3", Type = ChatMessageType.Assistant },
35+
],
36+
};
37+
38+
A.CallTo(() => chatStore.GetAsync(conversationId, default))
39+
.Returns(conversation);
40+
41+
var request = new ChatRequest { LoadHistory = true, ConversationId = conversationId };
42+
var result = await sut.StreamAsync(request).ToListAsync();
43+
44+
result.Should().BeEquivalentTo(
45+
[
46+
new ChatHistoryLoaded { Message = conversation.History[0] },
47+
new ChatHistoryLoaded { Message = conversation.History[2] },
48+
],
49+
o => o.PreferringDeclaredMemberTypes());
50+
51+
A.CallTo(chatProvider)
52+
.MustNotHaveHappened();
53+
}
54+
}

ai/Squidex.AI.Tests/ChatCleanerTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
// All rights reserved. Licensed under the MIT license.
66
// ==========================================================================
77

8-
using FakeItEasy;
98
using Microsoft.Extensions.Logging;
109
using Microsoft.Extensions.Options;
1110
using Squidex.AI.Implementation;
12-
using Xunit;
1311

1412
namespace Squidex.AI;
1513

ai/Squidex.AI.Tests/ChatStoreTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
// All rights reserved. Licensed under the MIT license.
66
// ==========================================================================
77

8-
using FluentAssertions;
98
using Squidex.AI.Implementation;
10-
using Xunit;
119

1210
namespace Squidex.AI;
1311

0 commit comments

Comments
 (0)