Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcb committed Dec 11, 2024
2 parents 1534103 + d27d49d commit 9f62997
Show file tree
Hide file tree
Showing 180 changed files with 940 additions and 1,075 deletions.
18 changes: 6 additions & 12 deletions Chats.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chats.BE", "src\BE\Chats.BE
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Chats.BE.Tests", "src\BE.Tests\Chats.BE.Tests.csproj", "{B785B397-23AB-4782-807B-C5D5001C1ECC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{04AEF080-BF5C-4CD7-BB7E-3D509A0FD3F6}"
ProjectSection(SolutionItems) = preProject
src\scripts\20240902-db-migration.linq = src\scripts\20240902-db-migration.linq
src\scripts\20241101-model-reference-sql.linq = src\scripts\20241101-model-reference-sql.linq
src\scripts\20241112-db-migration.linq = src\scripts\20241112-db-migration.linq
src\scripts\20241115-db-migration.sql = src\scripts\20241115-db-migration.sql
src\scripts\20241121-int-migration.sql = src\scripts\20241121-int-migration.sql
src\scripts\20241127-ref.sql = src\scripts\20241127-ref.sql
src\scripts\20241129-file.sql = src\scripts\20241129-file.sql
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "github-actions", "github-actions", "{29CC0F58-0B4E-4F4F-A084-7C461F7A4E60}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build-container.yml = .github\workflows\build-container.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "scripts", "src\scripts\scripts.csproj", "{1AE54C98-13A3-408B-B428-1FD975C02AF2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,12 +35,15 @@ Global
{B785B397-23AB-4782-807B-C5D5001C1ECC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B785B397-23AB-4782-807B-C5D5001C1ECC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B785B397-23AB-4782-807B-C5D5001C1ECC}.Release|Any CPU.Build.0 = Release|Any CPU
{1AE54C98-13A3-408B-B428-1FD975C02AF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1AE54C98-13A3-408B-B428-1FD975C02AF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AE54C98-13A3-408B-B428-1FD975C02AF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AE54C98-13A3-408B-B428-1FD975C02AF2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{04AEF080-BF5C-4CD7-BB7E-3D509A0FD3F6} = {6C78A2EB-D01E-4634-BBA7-85F12BF86232}
{29CC0F58-0B4E-4F4F-A084-7C461F7A4E60} = {6C78A2EB-D01E-4634-BBA7-85F12BF86232}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
Expand Down
8 changes: 4 additions & 4 deletions src/BE/Chats.BE.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.14.1" />
<PackageReference Include="AWSSDK.S3" Version="3.7.410.1" />
<PackageReference Include="AWSSDK.S3" Version="3.7.410.3" />
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" /> <!-- fix security issue from Azure.AI.OpenAI -->
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
Expand All @@ -26,12 +26,12 @@
<PackageReference Include="OpenAI" Version="2.1.0" />
<PackageReference Include="Sdcb.DashScope" Version="2.0.0" />
<PackageReference Include="Sdcb.WenXinQianFan" Version="1.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="System.Runtime.Caching" Version="9.0.0" />
<PackageReference Include="TencentCloudSDK.Hunyuan" Version="3.0.1137" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1137" />
<PackageReference Include="TencentCloudSDK.Hunyuan" Version="3.0.1139" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1139" />
</ItemGroup>

</Project>
7 changes: 2 additions & 5 deletions src/BE/Controllers/Chats/Chats/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Chats.BE.Services;
using Chats.BE.Services.ChatServices;
using Chats.BE.Services.ChatServices.Dtos;
using Chats.BE.Services.ChatServices.Extensions;
using Chats.BE.Services.FileServices;
using Chats.BE.Services.UrlEncryption;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -155,12 +156,8 @@ ..await GetMessageTree(existingMessages, messageId).ToAsyncEnumerable().SelectAw
throw new InvalidModelException(request.ModelId.ToString());
}

ChatCompletionOptions cco = request.UserModelConfig.ToChatCompletionOptions(currentUser.Id);
using ChatService s = conversationFactory.CreateConversationService(userModel.Model);
ChatCompletionOptions cco = new()
{
Temperature = request.UserModelConfig.Temperature,
EndUserId = currentUser.Id.ToString(),
};
await foreach (InternalChatSegment seg in icc.Run(userBalance.Balance, userModel, s.ChatStreamedFEProcessed(messageToSend, cco, cancellationToken)))
{
if (seg.TextSegment == string.Empty) continue;
Expand Down
22 changes: 4 additions & 18 deletions src/BE/Controllers/Chats/UserChats/Dtos/ChatsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Chats.BE.DB;
using Chats.BE.DB.Enums;
using Chats.BE.DB.Jsons;
using Chats.BE.Services.ChatServices;
using Chats.BE.Services.UrlEncryption;
using System.Text.Json.Serialization;

Expand All @@ -21,9 +20,6 @@ public record ChatsResponse
[JsonPropertyName("modelName")]
public required string ModelName { get; init; }

[JsonPropertyName("modelConfig")]
public required JsonModelConfig ModelConfig { get; init; }

[JsonPropertyName("userModelConfig")]
public required JsonUserModelConfig UserModelConfig { get; init; }

Expand All @@ -41,16 +37,11 @@ public static ChatsResponse FromDB(Chat chat, IUrlEncryptionService idEncryption
Title = chat.Title,
ModelId = chat.ModelId,
ModelName = chat.Model.Name,
ModelConfig = new JsonModelConfig
{
DeploymentName = chat.Model.DeploymentName,
EnableSearch = chat.Model.ModelReference.AllowSearch,
MaxLength = chat.Model.ModelReference.MaxResponseTokens,
Temperature = ChatService.DefaultTemperature,
Version = chat.Model.ModelKey.ModelProvider.Name,
Prompt = ChatService.DefaultPrompt,
UserModelConfig = new JsonUserModelConfig
{
EnableSearch = chat.EnableSearch,
Temperature = chat.Temperature,
},
UserModelConfig = new JsonUserModelConfig { EnableSearch = chat.EnableSearch, Temperature = chat.Temperature },
IsShared = chat.IsShared,
ModelProviderId = (DBModelProvider)chat.Model.ModelKey.ModelProviderId,
};
Expand Down Expand Up @@ -85,11 +76,6 @@ public ChatsResponse ToResponse(IUrlEncryptionService idEncryption)
Title = Title,
ModelId = ChatModelId,
ModelName = ModelName,
ModelConfig = new JsonModelConfig
{
Prompt = ChatService.DefaultPrompt,
Temperature = Temperature ?? ChatService.DefaultTemperature,
},
UserModelConfig = UserModelConfig,
IsShared = IsShared,
ModelProviderId = ModelProvider,
Expand Down
6 changes: 6 additions & 0 deletions src/BE/Controllers/Chats/UserChats/UserChatsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ public async Task<ActionResult<PagedResult<ChatsResponse>>> GetChats([FromQuery]
{
EnableSearch = x.EnableSearch,
Temperature = x.Temperature,
Prompt = x.Messages
.FirstOrDefault(x => x.ChatRoleId == (byte)DBChatRole.System)
!.MessageContents
.FirstOrDefault()
!.MessageContentText
!.Content
},
}),
request,
Expand Down
23 changes: 0 additions & 23 deletions src/BE/Controllers/Public/ModelInfo/DTOs/LegacyModelProviderDto.cs

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions src/BE/DB/Enums/DBModelProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public enum DBModelProvider
Sparkdesk = 8,
ZhiPuAI = 9,
DeepSeek = 10,
xAI = 11,
GithubModels = 12,
}
Loading

0 comments on commit 9f62997

Please sign in to comment.