Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve AI and markdown handling. #1107

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NJsonSchema" Version="11.0.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.AI" Version="6.12.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.12.0" />
<PackageReference Include="Squidex.AI" Version="6.18.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.18.0" />
<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
14 changes: 7 additions & 7 deletions backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="MailKit" Version="4.7.0" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.159">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -24,12 +24,12 @@
<PackageReference Include="NodaTime" Version="3.1.11" />
<PackageReference Include="OpenTelemetry.Api" Version="1.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets" Version="6.12.0" />
<PackageReference Include="Squidex.Caching" Version="6.12.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.12.0" />
<PackageReference Include="Squidex.Log" Version="6.12.0" />
<PackageReference Include="Squidex.Messaging" Version="6.12.0" />
<PackageReference Include="Squidex.Text" Version="6.12.0" />
<PackageReference Include="Squidex.Assets" Version="6.18.0" />
<PackageReference Include="Squidex.Caching" Version="6.18.0" />
<PackageReference Include="Squidex.Hosting.Abstractions" Version="6.18.0" />
<PackageReference Include="Squidex.Log" Version="6.18.0" />
<PackageReference Include="Squidex.Messaging" Version="6.18.0" />
<PackageReference Include="Squidex.Text" Version="6.18.0" />
<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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public static void AddSquidexTranslation(this IServiceCollection services, IConf
if (!string.IsNullOrWhiteSpace(apiKey))
{
services.AddOpenAIChat(config);
services.AddAIImagePipe();
services.AddDallE(config, options =>
{
options.DownloadImage = true;
Expand Down
22 changes: 11 additions & 11 deletions backend/src/Squidex/Squidex.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="ReportGenerator" Version="5.3.7" PrivateAssets="all" />
<PackageReference Include="Squidex.Assets.Azure" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.S3" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="6.12.0" />
<PackageReference Include="Squidex.Assets.Azure" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.GoogleCloud" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.FTP" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.ImageMagick" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.ImageSharp" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.Mongo" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.S3" Version="6.18.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="6.18.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="19.2.0" />
<PackageReference Include="Squidex.Hosting" Version="6.12.0" />
<PackageReference Include="Squidex.Messaging.All" Version="6.12.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.12.0" />
<PackageReference Include="Squidex.Hosting" Version="6.18.0" />
<PackageReference Include="Squidex.Messaging.All" Version="6.18.0" />
<PackageReference Include="Squidex.Messaging.Subscriptions" Version="6.18.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="5.1.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="YDotNet" Version="0.4.0" />
Expand Down
7 changes: 4 additions & 3 deletions backend/src/Squidex/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,15 +701,16 @@
"You are a bot to generate images.",
"Say hello to the user and explain him the user about your capabilities in a single, short sentence."
],
"tools": [ "dall-e" ]
"tools": ["dall-e"]
},

"text": {
"systemMessages": [
"You are a bot to generate text content.",
"Say hello to the user and explain him about your capabilities in a single, short sentence."
"Say hello to the user and explain him about your capabilities in a single, short sentence.",
"When you are asked to generate content such as articles, add placeholders for image, describe and use the following pattern: <IMG>{description}</IMG>. {description} is the generated image description."
],
"tools": []
"tools": ["none"]
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,13 @@ public async Task Should_generate_content()
A<ChatRequest>.That.Matches(x => x.Prompt == "prompt"),
A<ChatContext>._,
A<CancellationToken>._))
.Returns(new ChatResult { Content = "Generated", Metadata = new ChatMetadata(), Tools = [] });
.Returns(new ChatResult
{
Content = "Generated",
ToolStarts = [],
ToolEnds = [],
Metadata = new ChatMetadata(),
});

var vars = new ScriptVars
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task Should_return_clients_if_user_has_permission()

var result = await tool.ExecuteAsync(Activator.CreateInstance<ToolContext>(), default);

Assert.Contains($"{App.Name}:default", result);
Assert.Contains($"{App.Name}:default", result, StringComparison.Ordinal);

A.CallTo(() => urlGenerator.ClientsUI(AppId))
.MustHaveHappened();
Expand All @@ -72,7 +72,7 @@ public async Task Should_return_languages_if_user_has_permission()

var result = await tool.ExecuteAsync(Activator.CreateInstance<ToolContext>(), default);

Assert.Contains($"\"de\"", result);
Assert.Contains($"\"de\"", result, StringComparison.Ordinal);

A.CallTo(() => urlGenerator.LanguagesUI(AppId))
.MustHaveHappened();
Expand All @@ -99,7 +99,7 @@ public async Task Should_return_roles_if_user_has_permission()

var result = await tool.ExecuteAsync(Activator.CreateInstance<ToolContext>(), default);

Assert.Contains($"viewers", result);
Assert.Contains($"viewers", result, StringComparison.Ordinal);

A.CallTo(() => urlGenerator.RolesUI(AppId))
.MustHaveHappened();
Expand All @@ -126,7 +126,7 @@ public async Task Should_return_plan_if_user_has_permission()

var result = await tool.ExecuteAsync(Activator.CreateInstance<ToolContext>(), default);

Assert.Contains($"Business", result);
Assert.Contains($"Business", result, StringComparison.Ordinal);

A.CallTo(() => urlGenerator.PlansUI(AppId))
.MustHaveHappened();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task Should_return_schemas_if_user_has_permission()

var result = await tool.ExecuteAsync(Activator.CreateInstance<ToolContext>(), default);

Assert.Contains(Schema.Name, result);
Assert.Contains(Schema.Name, result, StringComparison.Ordinal);

A.CallTo(() => urlGenerator.SchemasUI(AppId))
.MustHaveHappened();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Reactive.Linq" Version="6.0.1" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Verify.Xunit" Version="25.0.4" />
<PackageReference Include="Verify.Xunit" Version="25.3.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
65 changes: 36 additions & 29 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@ module.exports = {
"plugins": [
"deprecation",
"eslint-plugin-import",
"@typescript-eslint",
"@typescript-eslint"
],
"rules": {
"deprecation/deprecation": "warn",
"@angular-eslint/directive-selector": [
"@angular-eslint/component-selector": [
"error",
{
"type": "attribute",
"prefix": "sqx",
"style": "camelCase"
"style": "kebab-case",
"type": "element"
}
],
"@angular-eslint/component-selector": [
"@angular-eslint/directive-selector": [
"error",
{
"type": "element",
"prefix": "sqx",
"style": "kebab-case"
"style": "camelCase",
"type": "attribute"
}
],
"@angular-eslint/use-lifecycle-interface": [
Expand All @@ -59,39 +58,39 @@ module.exports = {
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": [
"camelCase",
"PascalCase",
"UPPER_CASE",
"UPPER_CASE"
],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow",
"selector": "variable",
"trailingUnderscore": "allow"
},
{
"selector": "typeLike",
"format": [
"PascalCase"
],
"selector": "typeLike"
}
],
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"@typescript-eslint/return-await": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/quotes": [
"error",
"single"
],
"@typescript-eslint/return-await": "off",
"@typescript-eslint/semi": [
"error",
"always"
Expand All @@ -100,22 +99,30 @@ module.exports = {
"arrow-parens": "off",
"class-methods-use-this": "off",
"default-case": "off",
"deprecation/deprecation": "warn",
"function-paren-newline": "off",
"implicit-arrow-linebreak": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"import/no-useless-path-segments": "off",
"import/order": ["error", {
"pathGroupsExcludedImportTypes": ["builtin"],
"pathGroups": [{
"pattern": "@app/**",
"group": "external",
"position": "after"
}],
"alphabetize": {
"order": "asc"
"import/order": [
"error",
{
"alphabetize": {
"order": "asc"
},
"pathGroups": [
{
"group": "external",
"pattern": "@app/**",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": [
"builtin"
]
}
}],
],
"import/prefer-default-export": "off",
"linebreak-style": "off",
"max-classes-per-file": "off",
Expand All @@ -133,14 +140,14 @@ module.exports = {
"object-curly-newline": [
"error",
{
"ExportDeclaration": "never",
"ImportDeclaration": "never",
"ObjectExpression": {
"consistent": true
},
"ObjectPattern": {
"consistent": true
},
"ImportDeclaration": "never",
"ExportDeclaration": "never"
}
}
],
"operator-linebreak": "off",
Expand All @@ -151,6 +158,6 @@ module.exports = {
"ignoreCase": true,
"ignoreDeclarationSort": true
}
],
]
}
};
Loading