Skip to content

Commit

Permalink
AI improvements (#1095)
Browse files Browse the repository at this point in the history
* Progress

* Add missing files.

* Fix tests
  • Loading branch information
SebastianStehle authored May 27, 2024
1 parent 4dff1d5 commit 48cd104
Show file tree
Hide file tree
Showing 98 changed files with 1,159 additions and 642 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
<PackageReference Include="CoreTweet" Version="1.0.0.483" />
<PackageReference Include="Elasticsearch.Net" Version="7.17.5" />
<PackageReference Include="Google.Cloud.Diagnostics.Common" Version="5.2.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="4.3.0" />
<PackageReference Include="Google.Cloud.Logging.V2" Version="4.4.0" />
<PackageReference Include="Google.Cloud.Monitoring.V3" Version="3.9.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Azure.CognitiveServices.Vision.ComputerVision" Version="7.0.1" />
<PackageReference Include="Microsoft.Azure.SignalR.Management" Version="1.25.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.21.1" />
<PackageReference Include="Microsoft.OData.Core" Version="7.21.2" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="OpenSearch.Net" Version="1.7.1" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.8.1" />
Expand Down
2 changes: 2 additions & 0 deletions backend/i18n/source/backend_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"common.fullTextNotSupported": "Query search clause not supported.",
"common.httpContentTypeNotDefined": "File content-type is not defined.",
"common.httpFileNameNotDefined": "File name is not defined.",
"common.httpDownloadFailed": "Failed to download file.",
"common.httpDownloadRequestSize": "File exceeded maximum request size.",
"common.httpInvalidRequest": "The model is not valid.",
"common.httpInvalidRequestFormat": "Request body has an invalid format.",
"common.httpOnlyAsUser": "Not allowed for clients.",
Expand Down
1 change: 1 addition & 0 deletions backend/i18n/source/frontend_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"chat.describeFormat": "Also add the desired format (for example Markdown or HTML) to your prompt, dependending on the editor that you use.",
"chat.description": "Use the ChatBot (usually OpenAI) to generate content. Just write a prompt and describe the content you want to generate.",
"chat.prompt": "Describe the content you want to generate",
"chat.failed": "Failed to answer your request.",
"chat.title": "Chat Bot",
"chat.use": "Use",
"chatBot.questionFailed": "",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Migrations/Migrations.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ private void Generate(ScriptExecutionContext context, string prompt, Action<JsVa
return;
}
var result = await chatAgent.PromptAsync(prompt, ct: ct);
var request = new ChatRequest
{
Prompt = prompt
};
var result = await chatAgent.PromptAsync(request, ct: ct);
scheduler.Run(callback, JsValue.FromObject(context.Engine, result.Text));
scheduler.Run(callback, JsValue.FromObject(context.Engine, result.Content));
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fluid.Core" Version="2.9.0" />
<PackageReference Include="Fluid.Core" Version="2.10.0" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="Jint" Version="3.1.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Jint" Version="3.1.2" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NJsonSchema" Version="11.0.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.AI" Version="6.6.4" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.6.4" />
<PackageReference Include="Squidex.AI" Version="6.8.8" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.8.8" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ namespace Squidex.Domain.Apps.Entities.Apps.Commands;

public sealed class UploadAppImage : AppCommand
{
public AssetFile File { get; set; }
public IAssetFile File { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public abstract class UploadAssetCommand : AssetCommand
{
public HashSet<string> Tags { get; set; } = [];

public AssetFile File { get; set; }
public IAssetFile File { get; set; }

public AssetMetadata Metadata { get; } = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private async Task EnrichWithHashAndUploadAsync(UploadAssetCommand command, stri
}
}

private static string ComputeHash(AssetFile file, HasherStream hashStream)
private static string ComputeHash(IAssetFile file, HasherStream hashStream)
{
var steamHash = hashStream.GetHashStringAndReset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed class FileTagAssetMetadataSource : IAssetMetadataSource
{
private sealed class FileAbstraction : IFileAbstraction
{
private readonly AssetFile file;
private readonly IAssetFile file;

public string Name
{
Expand All @@ -36,7 +36,7 @@ public Stream WriteStream
get => throw new NotSupportedException();
}

public FileAbstraction(AssetFile file)
public FileAbstraction(IAssetFile file)
{
this.file = file;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="32.0.2" />
<PackageReference Include="CsvHelper" Version="32.0.3" />
<PackageReference Include="GraphQL" Version="7.8.0" />
<PackageReference Include="GraphQL.DataLoader" Version="7.8.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Teams;
using Squidex.Domain.Apps.Events;
using Squidex.Domain.Apps.Events.Apps;
using Squidex.Domain.Apps.Events.Teams;
using Squidex.Infrastructure.EventSourcing;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ProjectReference Include="..\Squidex.Shared\Squidex.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="IdentityModel" Version="7.0.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.5" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.5.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.6.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="SharpPwned.NET" Version="2.0.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EventStore.Client.Grpc.PersistentSubscriptions" Version="23.2.1" />
<PackageReference Include="EventStore.Client.Grpc.ProjectionManagement" Version="23.2.1" />
<PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.2.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.62.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="EventStore.Client.Grpc.PersistentSubscriptions" Version="23.3.1" />
<PackageReference Include="EventStore.Client.Grpc.ProjectionManagement" Version="23.3.1" />
<PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.3.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.63.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ProjectReference Include="..\Squidex.Infrastructure\Squidex.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
22 changes: 11 additions & 11 deletions backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MailKit" Version="4.5.0" />
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="8.0.5" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageReference Include="Microsoft.OData.Core" Version="7.21.1" />
<PackageReference Include="Microsoft.OData.Core" Version="7.21.2" />
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="OpenTelemetry.Api" Version="1.8.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="6.6.4" />
<PackageReference Include="Squidex.Caching" Version="6.6.4" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.6.4" />
<PackageReference Include="Squidex.Log" Version="6.6.4" />
<PackageReference Include="Squidex.Messaging" Version="6.6.4" />
<PackageReference Include="Squidex.Text" Version="6.6.4" />
<PackageReference Include="Squidex.Assets" Version="6.8.8" />
<PackageReference Include="Squidex.Caching" Version="6.8.8" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.8.8" />
<PackageReference Include="Squidex.Log" Version="6.8.8" />
<PackageReference Include="Squidex.Messaging" Version="6.8.8" />
<PackageReference Include="Squidex.Text" Version="6.8.8" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="8.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion backend/src/Squidex.Shared/Squidex.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
31 changes: 0 additions & 31 deletions backend/src/Squidex.Web/FileExtensions.cs

This file was deleted.

8 changes: 7 additions & 1 deletion backend/src/Squidex.Web/Services/UrlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// ==========================================================================

using Microsoft.Extensions.Options;
using Squidex.AI.Implementation.OpenAI;
using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Assets;
using Squidex.Domain.Apps.Entities.Assets;
Expand All @@ -15,7 +16,7 @@

namespace Squidex.Web.Services;

public sealed class UrlGenerator : IUrlGenerator
public sealed class UrlGenerator : IUrlGenerator, IHttpImageEndpoint
{
private readonly IAssetFileStore assetFileStore;
private readonly IGenericUrlGenerator urlGenerator;
Expand Down Expand Up @@ -171,4 +172,9 @@ public string UI()
{
return urlGenerator.BuildUrl("app", false);
}

string IHttpImageEndpoint.GetUrl(string relativePath)
{
return urlGenerator.BuildUrl($"ai-images/{relativePath}", false);
}
}
2 changes: 1 addition & 1 deletion backend/src/Squidex.Web/Squidex.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="GraphQL" Version="7.8.0" />
<PackageReference Include="GraphQL.SystemTextJson" Version="7.8.0" />
<PackageReference Include="GraphQL.Server.Transports.AspNetCore" Version="7.7.1" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.150">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.153">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit 48cd104

Please sign in to comment.