Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ tools/NcfDesktopApp.GUI/publish-self-contained.pre-package-*
tools/NcfSimulatedSite/Senparc.Web/wwwroot/NcfPackages/
.cursor/scratchpad.md
upgrade-senparc-packages/
.venv_translate
1,942 changes: 1,942 additions & 0 deletions src/Extensions/Senparc.Web/App_Data/ApiDocXML/Senparc.Xncf.PromptRange.XML

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public async Task<AppResponseBase<AIModelDto>> GetAsync(int id)
/// <param name="request"></param>
/// <returns></returns>
[ApiBind(ApiRequestMethod = ApiRequestMethod.Post)]
public async Task<AppResponseBase<PagedResponse<AIModelDto>>> GetPagedListAsync(AIModel_GetListRequest request)
{
return await this
.GetResponseAsync<AppResponseBase<PagedResponse<AIModelDto>>, PagedResponse<AIModelDto>>(
public async Task<AppResponseBase<PagedResponse<AIModelDto>>> GetPagedListAsync(AIModel_GetListRequest request)
{
return await this
.GetResponseAsync<AppResponseBase<PagedResponse<AIModelDto>>, PagedResponse<AIModelDto>>(
async (response, logger) =>
{
var where = GetListWhere(request);
Expand All @@ -107,11 +107,33 @@ public async Task<AppResponseBase<PagedResponse<AIModelDto>>> GetPagedListAsync(
total,
modelList.Select(m => new AIModelDto(m))
);
});
}

/// <summary>
/// 获取AIModel列表
});
}

/// <summary>
/// 分页获取供其他管理页面选择的 AIModel 基本信息。
/// 不返回 ApiKey、Endpoint、OrganizationId 等配置敏感字段。
/// </summary>
[ApiBind(ApiRequestMethod = ApiRequestMethod.Post)]
public async Task<AppResponseBase<PagedResponse<AIModelSelectionResponse>>> GetSelectionListAsync(AIModel_GetListRequest request)
{
return await this
.GetResponseAsync<AppResponseBase<PagedResponse<AIModelSelectionResponse>>, PagedResponse<AIModelSelectionResponse>>(
async (response, logger) =>
{
var where = GetListWhere(request);

var modelList = await _aIModelService.GetObjectListAsync(request.Page, request.Size, where, request.Order);
var total = await _aIModelService.GetCountAsync(where);

return new PagedResponse<AIModelSelectionResponse>(
total,
modelList.Select(m => new AIModelSelectionResponse(m)));
});
}

/// <summary>
/// 获取AIModel列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Expand Down Expand Up @@ -269,4 +291,4 @@ public async Task<AppResponseBase<string>> UpdateNeuCharModels(AIModel_UpdateNeu
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,28 @@ public async Task<AppResponseBase<PagedResponse<AIVectorDto>>> GetPagedListAsync
});
}

/// <summary>
/// 分页获取供其他管理页面选择的 AIVector 基本信息。
/// 不返回连接字符串、备注等配置敏感字段。
/// </summary>
[ApiBind(ApiRequestMethod = ApiRequestMethod.Post)]
public async Task<AppResponseBase<PagedResponse<AIVectorSelectionResponse>>> GetSelectionListAsync(AIVector_GetListRequest request)
{
return await this
.GetResponseAsync<AppResponseBase<PagedResponse<AIVectorSelectionResponse>>, PagedResponse<AIVectorSelectionResponse>>(
async (response, logger) =>
{
var where = GetListWhere(request);

var vectorList = await _aIVectorService.GetObjectListAsync(request.Page, request.Size, where, request.Order);
var total = await _aIVectorService.GetCountAsync(where);

return new PagedResponse<AIVectorSelectionResponse>(
total,
vectorList.Select(m => new AIVectorSelectionResponse(m)));
});
}

/// <summary>
/// 获取AIVector列表
/// </summary>
Expand Down Expand Up @@ -202,4 +224,4 @@ public async Task<AppResponseBase<bool>> DeleteAsync(int id)
});
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*----------------------------------------------------------------
Copyright (C) 2026 Senparc

文件名:SelectionResponse.cs
文件功能描述:AIKernel 选择器安全响应模型

----------------------------------------------------------------*/

using Senparc.Xncf.AIKernel.Models;

namespace Senparc.Xncf.AIKernel.OHS.Local.PL;

/// <summary>
/// AI model fields required by selectors. Credentials and provider details are
/// intentionally excluded.
/// </summary>
public sealed class AIModelSelectionResponse
{
public int Id { get; set; }

public string Alias { get; set; }

public bool Show { get; set; }

public AIModelSelectionResponse()
{
}

public AIModelSelectionResponse(AIModel model)
{
Id = model.Id;
Alias = model.Alias;
Show = model.Show;
}
}

/// <summary>
/// Vector database fields required by selectors. Connection strings and notes
/// are intentionally excluded.
/// </summary>
public sealed class AIVectorSelectionResponse
{
public int Id { get; set; }

public string Alias { get; set; }

public bool Show { get; set; }

public AIVectorSelectionResponse()
{
}

public AIVectorSelectionResponse(AIVector vector)
{
Id = vector.Id;
Alias = vector.Alias;
Show = vector.Show;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public async Task<AppResponseBase<FileTemplate_GetListResponse>> GetList(int pag
PageIndex = listDto.PageIndex
};
return result;
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "资料列表加载失败,请稍后重试。";
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,5 @@
@section scripts
{
@await Html.PartialAsync("_LocalizationScripts")
<script src="~/js/KnowledgeBase/Pages/KnowledgeBase/knowledgeBase.js"></script>
<script src="~/js/KnowledgeBase/Pages/KnowledgeBase/knowledgeBase.js" asp-append-version="true"></script>
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public async Task<IActionResult> OnGetKnowledgeBasesAsync(string keyword, string
response.PageIndex,
List = response.Select(_ => new {
_.Id,
_.LastUpdateTime,
_.Remark,
_.EmbeddingModelId,
_.VectorDBId,
_.ChatModelId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public async Task<AppResponseBase<string>> UploadAsync(IFormFile file)
// 知识库内嵌上传只能创建资料文件,绝不能借此写入可公开的站点资源区。
var result = await ncfFileService.UploadFileAsync(file, NcfFileResourceScope.KnowledgeBase);
return result.Id.ToString();
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "资料上传失败,请稍后重试。";
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public async Task<AppResponseBase<bool>> CreateOrUpdateAsync(KnowledgeBaseReques
await knowledgeBasesService.CreateOrUpdateAsync(dto);
bool result = true;
return result;
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "知识库保存失败,请稍后重试。";
});
}

Expand All @@ -104,6 +107,9 @@ await knowledgeBaseService.SyncInlineContentToKnowledgeBaseAsync(
logger.Append("知识库文本内容已同步。");

return true;
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "知识库内容保存失败,请稍后重试。";
});
}

Expand All @@ -125,10 +131,13 @@ public async Task<AppResponseBase<string>> EmbeddingKnowledgeBase(plRequest.Know
}
catch (Exception ex)
{
logger.Append($"向量化处理失败:{ex.Message}");
System.Console.WriteLine(ex.Message);
logger.Append("向量化处理失败");
System.Console.WriteLine("知识库向量化处理失败。");
throw;
}
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "向量化失败,请检查配置后重试。";
});
}

Expand Down Expand Up @@ -162,9 +171,12 @@ public async Task<AppResponseBase<bool>> ImportFilesToKnowledgeBase(plRequest.Im
}
catch (Exception ex)
{
logger.Append($"导入失败:{ex.Message}");
logger.Append("导入失败");
throw;
}
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "文件导入失败,请稍后重试。";
});
}

Expand All @@ -181,6 +193,9 @@ await knowledgeBaseService.SyncFilesToKnowledgeBaseAsync(
request.fileIds ?? new List<int>());
logger.Append($"知识库文件关联已同步:{request.fileIds?.Distinct().Count() ?? 0} 个文件。");
return true;
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "知识库资料关联保存失败,请稍后重试。";
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public async Task<AppResponseBase<List<KnowledgeBaseItemDto>>> GetConfigurationB
knowledgeBase.Content));
}
return result;
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "知识库资料加载失败,请稍后重试。";
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ public async Task<AppResponseBase<List<RecallTestResponse>>> RecallTest(plReques
}
catch (Exception ex)
{
logger.Append($"召回测试失败:{ex.Message}");
logger.Append("召回测试失败");
throw;
}
}, exceptionHandler: (_, response, _) =>
{
response.ErrorMessage = "召回测试失败,请检查配置后重试。";
});
}
}
Expand Down
Loading
Loading