Compare commits

..

7 Commits
0.6.2 ... 0.6.3

Author SHA1 Message Date
zyxucp
8c4030ae43 update chat 默认app 2025-03-29 12:45:39 +08:00
zyxucp
c912ceeee0 del 删除做图应用 2025-03-29 12:37:20 +08:00
zyxucp
58c5edbc5e del 删除做图应用 2025-03-29 12:36:08 +08:00
zyxucp
3d86fd1125 update nuge and menu 2025-03-29 12:33:10 +08:00
zyxucp
f8c6a05380 update style 2025-03-12 23:22:30 +08:00
zyxucp
10b4706094 update 1 2025-03-12 23:12:21 +08:00
zyxucp
3f7e2d29e1 update 官网 2025-03-12 23:11:43 +08:00
12 changed files with 209 additions and 251 deletions

View File

@@ -8,8 +8,8 @@
<NoWarn>CA1050,CA1707,CA2007,VSTHRD111,CS1591,RCS1110,CA5394,SKEXP0001,SKEXP0002,SKEXP0003,SKEXP0004,SKEXP0010,SKEXP0011,,SKEXP0012,SKEXP0020,SKEXP0021,SKEXP0022,SKEXP0023,SKEXP0024,SKEXP0025,SKEXP0026,SKEXP0027,SKEXP0028,SKEXP0029,SKEXP0030,SKEXP0031,SKEXP0032,SKEXP0040,SKEXP0041,SKEXP0042,SKEXP0050,SKEXP0051,SKEXP0052,SKEXP0053,SKEXP0054,SKEXP0055,SKEXP0060,SKEXP0061,SKEXP0101,SKEXP0102,KMEXP00</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AntDesign.Charts" Version="0.5.6" />
<PackageReference Include="AntDesign.ProLayout" Version="0.20.3" />
<PackageReference Include="AntDesign.Charts" Version="0.6.0" />
<PackageReference Include="AntDesign.ProLayout" Version="1.0.1" />
<PackageReference Include="BlazorComponents.Terminal" Version="0.6.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
@@ -19,9 +19,9 @@
<PackageReference Include="AutoMapper" Version="8.1.0" />
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Markdig" Version="0.37.0" />
<PackageReference Include="Markdig" Version="0.40.0" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftVersion)" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.169" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.187" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
<PackageReference Include="RestSharp" Version="$(RestSharpVersion)" />
<PackageReference Include="NPOI" Version="2.7.1" />

View File

@@ -17,7 +17,6 @@ namespace AntSK.Domain.Domain.Interface
IAsyncEnumerable<string> SendChatByAppAsync(Apps app, ChatHistory history);
IAsyncEnumerable<StreamingKernelContent> SendKmsByAppAsync(Apps app, string questions, ChatHistory history, string filePath, List<RelevantSource> relevantSources = null);
Task<string> SendImgByAppAsync(Apps app, string questions);
Task<ChatHistory> GetChatHistory(List<Chats> MessageList, ChatHistory history);
}
}

View File

@@ -10,6 +10,5 @@ namespace AntSK.Domain.Domain.Model.Enum
{
chat = 1,
kms = 2,
img=3
}
}

View File

@@ -229,112 +229,6 @@ namespace AntSK.Domain.Domain.Service
}
public async Task<string> SendImgByAppAsync(Apps app, string questions)
{
var imageModel = _aIModels_Repositories.GetFirst(p => p.Id == app.ImageModelID);
KernelArguments args = new() {
{ "input", questions }
};
var _kernel = _kernelService.GetKernelByApp(app);
var temperature = app.Temperature / 100; //存的是0~100需要缩小
OpenAIPromptExecutionSettings settings = new() { Temperature = temperature };
var func = _kernel.CreateFunctionFromPrompt("Translate this into English:{{$input}}", settings);
var chatResult = await _kernel.InvokeAsync(function: func, arguments: args);
if (chatResult.IsNotNull())
{
//Can Load stable-diffusion library in diffenert environment
//SDHelper.LoadLibrary()
string versionString = string.Empty;
string extensionString = string.Empty;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
extensionString = ".dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
extensionString = ".so";
}
else
{
throw new InvalidOperationException("OS Platform no support");
}
ProcessStartInfo startInfo = new ProcessStartInfo("nvcc", "--version");
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
using (Process process = Process.Start(startInfo))
{
if (process != null)
{
string result = process.StandardOutput.ReadToEnd();
Regex regex = new Regex(@"release (\d+).[\d]");
Match match = regex.Match(result);
if (match.Success)
{
switch (match.Groups[1].Value.ToString())
{
case "11":
versionString = "Cuda11";
break;
case "12":
versionString = "Cuda12";
break;
default:
versionString = "CPU";
break;
}
}
}
else
{
throw new Exception("nvcc get an error");
}
}
string libraryPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StableDiffusion", "Backend", versionString, "stable-diffusion" + extensionString);
NativeLibrary.TryLoad(libraryPath, out _);
string prompt = chatResult.GetValue<string>();
if (!SDHelper.IsInitialized)
{
Structs.ModelParams modelParams = new Structs.ModelParams
{
ModelPath = imageModel.ModelName,
RngType = Structs.RngType.CUDA_RNG,
//VaePath = vaePath,
//KeepVaeOnCpu = keepVaeOnCpu,
//set false can get a better image, otherwise can use lower vram
VaeTiling = false,
//LoraModelDir = loraModelDir,
};
bool result = SDHelper.Initialize(modelParams);
}
Structs.TextToImageParams textToImageParams = new Structs.TextToImageParams
{
Prompt = prompt,
NegativePrompt = "bad quality, wrong image, worst quality",
SampleMethod = (Structs.SampleMethod)Enum.Parse(typeof(Structs.SampleMethod), "EULER_A"),
//the base image size in SD1.5 is 512x512
Width = 512,
Height = 512,
NormalizeInput = true,
ClipSkip = -1,
CfgScale = 7,
SampleSteps = 20,
Seed = -1,
};
Bitmap[] outputImages = SDHelper.TextToImage(textToImageParams);
var base64 = ImageUtils.BitmapToBase64(outputImages[0]);
return base64;
}
else
{
return "";
}
}
public async Task<ChatHistory> GetChatHistory(List<Chats> MessageList, ChatHistory history)
{
foreach (var item in MessageList)

View File

@@ -27,7 +27,6 @@
<RadioGroup @bind-Value="context.Type" OnChange="OnAppTypeChange" TValue="string" ButtonStyle="RadioButtonStyle.Solid">
<Radio RadioButton Value="@AppType.chat.ToString()">会话应用</Radio>
<Radio RadioButton Value="@AppType.kms.ToString()">知识库</Radio>
<Radio RadioButton Value="@AppType.img.ToString()">做图应用</Radio>
</RadioGroup>
</FormItem>
<FormItem Label="描述" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
@@ -42,25 +41,24 @@
</Select>
<Button Type="@ButtonType.Link" OnClick="NavigateModelList">去创建</Button>
</FormItem>
@if (@context.Type != AppType.img.ToString())
{
<FormItem Label="向量模型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
<Select DataSource="@_embedingList"
@bind-Value="@context.EmbeddingModelID"
ValueProperty="c=>c.Id"
LabelProperty="c=>'【'+c.AIType.ToString()+'】'+c.ModelDescription">
</Select>
<Button Type="@ButtonType.Link" OnClick="NavigateModelList">去创建</Button>
</FormItem>
<FormItem Label="提示词" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
<TextArea MinRows="4" Placeholder="请输入角色信息" @bind-Value="@context.Prompt" />
</FormItem>
<FormItem Label="温度系数" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
<span>更确定</span>
<Slider TValue="double" Style="display: inline-block;width: 300px; " Min="0" Max="100" DefaultValue="70" @bind-Value="@context.Temperature" />
<span>更发散</span>
</FormItem>
}
<FormItem Label="向量模型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
<Select DataSource="@_embedingList"
@bind-Value="@context.EmbeddingModelID"
ValueProperty="c=>c.Id"
LabelProperty="c=>'【'+c.AIType.ToString()+'】'+c.ModelDescription">
</Select>
<Button Type="@ButtonType.Link" OnClick="NavigateModelList">去创建</Button>
</FormItem>
<FormItem Label="提示词" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
<TextArea MinRows="4" Placeholder="请输入角色信息" @bind-Value="@context.Prompt" />
</FormItem>
<FormItem Label="温度系数" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
<span>更确定</span>
<Slider TValue="double" Style="display: inline-block;width: 300px; " Min="0" Max="100" DefaultValue="70" @bind-Value="@context.Temperature" />
<span>更发散</span>
</FormItem>
@if (@context.Type == AppType.chat.ToString())
{
<FormItem Label="API插件列表" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">

View File

@@ -59,10 +59,6 @@
<Tag Color="@PresetColor.Green.ToString()">知识库</Tag>
}
else if (context.Type == AppType.img.ToString())
{
<Tag Color="@PresetColor.Red.ToString()">做图应用</Tag>
}
</DescriptionTemplate>
</CardMeta>
</Card>

View File

@@ -26,6 +26,10 @@ namespace AntSK.Pages.ChatPage
{
await base.OnInitializedAsync();
_list = _apps_Repositories.GetList();
if (string.IsNullOrEmpty(AppId)&&_list.Count>0)
{
AppId = _list.FirstOrDefault().Id;
}
}
private void OnRelevantSources(List<RelevantSource> relevantSources)

View File

@@ -264,48 +264,17 @@ namespace AntSK.Pages.ChatPage.Components
await SendKms(questions, history, app, filePath);
}
else if (app.Type == AppType.img.ToString())
await SaveMsg(MessageList);
if (OnRelevantSources.IsNotNull())
{
await SendImg(questions, app);
await OnRelevantSources.InvokeAsync(_relevantSources);
}
//缓存消息记录
if (app.Type != AppType.img.ToString())
{
await SaveMsg(MessageList);
if (OnRelevantSources.IsNotNull())
{
await OnRelevantSources.InvokeAsync(_relevantSources);
}
}
return true;
}
/// <summary>
/// 发送图片对话
/// </summary>
/// <param name="questions"></param>
/// <param name="app"></param>
/// <returns></returns>
private async Task SendImg(string questions,Apps app)
{
Chats info = new Chats();
info.Id = Guid.NewGuid().ToString();
info.UserName=_userName;
info.AppId=AppId;
info.CreateTime = DateTime.Now;
var base64= await _chatService.SendImgByAppAsync(app, questions);
if (string.IsNullOrEmpty(base64))
{
info.Context = "生成失败";
}
else
{
info.Context = $"<img src=\"data:image/jpeg;base64,{base64}\" alt=\"Base64 Image\" />";
}
MessageList.Add(info);
}
/// <summary>
/// 发送知识库问答
/// </summary>

View File

@@ -72,7 +72,7 @@
<SpaceItem>
<Card Bordered="true" Title=@("👉🏻商业授权") Hoverable="true" Style="height:260px;width:300px">
<Body>
<Text>● AntSKPro为商业版 <a href="https://antsk.cn" target="_blank">访问官网</a></Text>
<Text>● AntSKPro为商业版 <a href="https://gw.antsk.cn" target="_blank">访问官网</a></Text>
<br>
<Text>● 开源版本请参见:</Text>
<a href="https://github.com/AIDotNet/AntSK" target="_blank">AntSK开源版</a>
@@ -80,7 +80,7 @@
<Text>● 未获取商业授权,禁止商业使用</Text>
<br>
<Text>● 如需商业授权,请联系微信:</Text>
<b style="color:#7F7FFF">xuzeyu91</b>
<b style="color:#1890ff">13469996907</b>
<br>
</Body>
</Card>

View File

@@ -2,42 +2,165 @@
/* stylelint-disable no-duplicate-selectors */
/* stylelint-disable */
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
/* 全局样式优化 */
:root {
--primary-color: #1890ff;
--primary-hover: #40a9ff;
--primary-active: #096dd9;
--primary-light: rgba(24, 144, 255, 0.1);
--text-color: rgba(0, 0, 0, 0.85);
--text-color-secondary: rgba(0, 0, 0, 0.45);
--border-radius: 4px;
--box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
--transition-duration: 0.3s;
}
/* 图标组样式优化 */
.iconGroup span.anticon {
margin-left: 16px;
color: rgba(0, 0, 0, 0.45);
color: var(--text-color-secondary);
cursor: pointer;
transition: color 0.32s;
transition: all var(--transition-duration) ease;
}
.iconGroup span.anticon:hover {
color: rgba(0, 0, 0, 0.85);
color: var(--text-color);
transform: scale(1.1);
}
/* 统计卡片样式增强 */
.ant-card {
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
transition: all var(--transition-duration) ease;
}
.ant-card:hover {
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
transform: translateY(-3px);
}
/* ChartCard 组件样式优化 */
.chartCard {
position: relative;
padding: 16px;
transition: all var(--transition-duration) ease;
}
.chartCard .chartTop {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
}
.chartCard .metaWrap {
flex: 1;
}
.chartCard .meta {
display: flex;
justify-content: space-between;
color: var(--text-color-secondary);
font-size: 14px;
line-height: 22px;
}
.chartCard .action {
color: var(--primary-color);
transition: all var(--transition-duration) ease;
}
.chartCard .total {
margin-top: 4px;
color: var(--text-color);
font-weight: 600;
font-size: 24px;
line-height: 32px;
}
.chartCard .content {
position: relative;
margin-bottom: 12px;
height: auto;
width: 100%;
}
.chartCard .contentFixed {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
}
.chartCard .footer {
margin-top: 8px;
padding-top: 9px;
border-top: 1px solid rgba(0, 0, 0, 0.06);
}
/* 功能特性卡片样式优化 */
.ant-space-item .ant-card {
overflow: hidden;
border: 1px solid rgba(0, 0, 0, 0.06);
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}
.ant-space-item .ant-card:hover {
border-color: var(--primary-color);
}
.ant-space-item .ant-card .ant-card-head {
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
background: linear-gradient(90deg, var(--primary-light) 0%, rgba(255, 255, 255, 0) 100%);
}
.ant-space-item .ant-card .ant-card-head-title {
font-weight: 600;
font-size: 16px;
color: var(--text-color);
}
/* 排名列表样式优化 */
.rankingList {
margin: 25px 0 0;
padding: 0;
list-style: none;
}
.rankingList li {
display: flex;
align-items: center;
margin-top: 16px;
zoom: 1;
padding: 8px;
border-radius: var(--border-radius);
transition: background-color var(--transition-duration) ease;
}
.rankingList li:hover {
background-color: rgba(0, 0, 0, 0.02);
}
.rankingList li::before,
.rankingList li::after {
display: table;
content: ' ';
}
.rankingList li::after {
clear: both;
height: 0;
font-size: 0;
visibility: hidden;
}
.rankingList li span {
color: rgba(0, 0, 0, 0.85);
color: var(--text-color);
font-size: 14px;
line-height: 22px;
}
.rankingList li .rankingItemNumber {
display: inline-block;
width: 20px;
@@ -49,12 +172,15 @@
line-height: 20px;
text-align: center;
background-color: #fafafa;
border-radius: 20px;
border-radius: 50%;
transition: all var(--transition-duration) ease;
}
.rankingList li .rankingItemNumber.active {
color: #fff;
background-color: #314659;
background-color: var(--primary-color);
}
.rankingList li .rankingItemTitle {
flex: 1;
margin-right: 8px;
@@ -62,79 +188,41 @@
white-space: nowrap;
text-overflow: ellipsis;
}
.salesExtra {
display: inline-block;
margin-right: 24px;
}
.salesExtra a {
margin-left: 24px;
color: rgba(0, 0, 0, 0.85);
}
.salesExtra a:hover {
color: #1890ff;
}
.salesExtra a.currentDate {
color: #1890ff;
}
.salesCard .salesBar {
padding: 0 0 32px 32px;
}
.salesCard .salesRank {
padding: 0 32px 32px 72px;
}
.salesCard :global .ant-tabs-bar,
.salesCard :global .ant-tabs-nav-wrap {
padding-left: 16px;
}
.salesCard :global .ant-tabs-bar .ant-tabs-nav .ant-tabs-tab,
.salesCard :global .ant-tabs-nav-wrap .ant-tabs-nav .ant-tabs-tab {
padding-top: 16px;
padding-bottom: 14px;
line-height: 24px;
}
.salesCard :global .ant-tabs-extra-content {
padding-right: 24px;
line-height: 55px;
}
.salesCard :global .ant-card-head {
/* 标题样式优化 */
.ant-divider .ant-typography {
position: relative;
color: var(--text-color);
font-weight: 600;
text-align: center;
}
.salesCard :global .ant-card-head-title {
align-items: normal;
}
.salesCardExtra {
height: inherit;
}
.salesTypeRadio {
.ant-divider .ant-typography::after {
content: '';
position: absolute;
right: 54px;
bottom: 12px;
bottom: -8px;
left: 50%;
width: 40px;
height: 3px;
background: var(--primary-color);
transform: translateX(-50%);
border-radius: 3px;
}
.offlineCard :global .ant-tabs-ink-bar {
bottom: auto;
/* 标签样式优化 */
.ant-tag {
margin: 4px;
padding: 2px 8px;
border-radius: 12px;
font-size: 12px;
transition: all var(--transition-duration) ease;
}
.offlineCard :global .ant-tabs-bar {
border-bottom: none;
}
.offlineCard :global .ant-tabs-nav-container-scrolling {
padding-right: 40px;
padding-left: 40px;
}
.offlineCard :global .ant-tabs-tab-prev-icon::before {
position: relative;
left: 6px;
}
.offlineCard :global .ant-tabs-tab-next-icon::before {
position: relative;
right: 6px;
}
.offlineCard :global .ant-tabs-tab-active h4 {
color: #1890ff;
}
.trendText {
margin-left: 8px;
color: rgba(0, 0, 0, 0.85);
.ant-tag:hover {
transform: scale(1.05);
}
/* 响应式调整 */
@media screen and (max-width: 992px) {
.salesExtra {
display: none;
@@ -142,7 +230,11 @@
.rankingList li span:first-child {
margin-right: 8px;
}
.ant-card:hover {
transform: translateY(-2px);
}
}
@media screen and (max-width: 768px) {
.rankingTitle {
margin-top: 16px;
@@ -150,7 +242,11 @@
.salesCard .salesBar {
padding: 16px;
}
.ant-space {
justify-content: center;
}
}
@media screen and (max-width: 576px) {
.salesExtraWrap {
display: none;
@@ -158,4 +254,7 @@
.salesCard :global .ant-tabs-content {
padding-top: 30px;
}
.chartCard .total {
font-size: 20px;
}
}

View File

@@ -10,7 +10,7 @@
"urls": "http://*:5000",
"ProSettings": {
"NavTheme": "light",
"Layout": "side",
"Layout": "top",
"ContentWidth": "Fluid",
"FixedHeader": false,
"FixSiderbar": true,

View File

@@ -72,8 +72,8 @@
]
},
{
"path": "https://antsk.cn",
"name": "官方文档",
"path": "https://gw.antsk.cn",
"name": "官",
"key": "antskdoc",
"icon": "question-circle"
},