mirror of
https://github.com/AIDotNet/AntSK.git
synced 2026-02-18 06:20:11 +08:00
Compare commits
156 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d93e962ae9 | ||
|
|
1da5d5bce1 | ||
|
|
b853ab4851 | ||
|
|
00b37d9600 | ||
|
|
c467a3c427 | ||
|
|
06cdbb14d0 | ||
|
|
115e12257b | ||
|
|
533a47566b | ||
|
|
51ec2db3c3 | ||
|
|
3aa76e0662 | ||
|
|
755d2c2d4f | ||
|
|
bd27048237 | ||
|
|
01063f2d49 | ||
|
|
5a4f038da1 | ||
|
|
dd6e1a6d54 | ||
|
|
52e20396ad | ||
|
|
a8f48929e7 | ||
|
|
ae89fb5ec7 | ||
|
|
48a8670f01 | ||
|
|
2c8efd2eef | ||
|
|
a4acb80151 | ||
|
|
a8f143995d | ||
|
|
e46b02d70b | ||
|
|
31ea75ecba | ||
|
|
e2142deb4a | ||
|
|
a6b11bb33d | ||
|
|
773073b847 | ||
|
|
2bd38b96e7 | ||
|
|
f7bcbcfc95 | ||
|
|
6f5429695c | ||
|
|
547a3b5919 | ||
|
|
358909892c | ||
|
|
6c1bc4be04 | ||
|
|
431c754f42 | ||
|
|
f46faa7679 | ||
|
|
195053cbd7 | ||
|
|
b41d79c247 | ||
|
|
5acab7a46f | ||
|
|
5b83c844a1 | ||
|
|
2325c58092 | ||
|
|
04d16148b5 | ||
|
|
f0f14889c7 | ||
|
|
dedafdd108 | ||
|
|
fad2b4e733 | ||
|
|
032de7a447 | ||
|
|
cb0df4d4af | ||
|
|
c810f85cea | ||
|
|
6700b75684 | ||
|
|
ab15dd6e99 | ||
|
|
13a4419705 | ||
|
|
cf03465e23 | ||
|
|
a441730508 | ||
|
|
6e30886bd2 | ||
|
|
bc2af42724 | ||
|
|
919fc5dea7 | ||
|
|
9ab287fabd | ||
|
|
cf02efc2da | ||
|
|
1c34ad5987 | ||
|
|
4e8039703e | ||
|
|
c2b97c7f82 | ||
|
|
1a621f5cbc | ||
|
|
836f898ffe | ||
|
|
0a9a737709 | ||
|
|
0df8c74ec2 | ||
|
|
5e3ff74eaa | ||
|
|
7c49ff0a6c | ||
|
|
63f5267bca | ||
|
|
e0c35aac06 | ||
|
|
27d52d3331 | ||
|
|
e7b2c6e193 | ||
|
|
7600397b79 | ||
|
|
874b8e5d7f | ||
|
|
3ac18086a1 | ||
|
|
16049c7413 | ||
|
|
7bb7a41bb3 | ||
|
|
6c37ed66b2 | ||
|
|
bc86f96159 | ||
|
|
8eb09fb783 | ||
|
|
eff5f69f0f | ||
|
|
e3f966d4f2 | ||
|
|
015f51b99c | ||
|
|
cd66b61014 | ||
|
|
f0bef7d2fa | ||
|
|
de051b047d | ||
|
|
ed6f5dada2 | ||
|
|
d2e3fde829 | ||
|
|
195551e9c1 | ||
|
|
855103c2a4 | ||
|
|
6150d543d3 | ||
|
|
d968d78982 | ||
|
|
0ec5d1f1cf | ||
|
|
31f44c1758 | ||
|
|
e5f63d605d | ||
|
|
7db62e3dc6 | ||
|
|
4408fa4345 | ||
|
|
c5e952b98e | ||
|
|
bedfeaf53d | ||
|
|
d605fd6685 | ||
|
|
e5e3f7cd8f | ||
|
|
657949694c | ||
|
|
10b6035f84 | ||
|
|
3f9fe27456 | ||
|
|
da3a0681e5 | ||
|
|
57b7948d86 | ||
|
|
40b8bd0439 | ||
|
|
6ed9cc9b70 | ||
|
|
e51bf35217 | ||
|
|
28f88438e7 | ||
|
|
85f4a330d5 | ||
|
|
21d7c719f1 | ||
|
|
4ef398bd57 | ||
|
|
dc70270362 | ||
|
|
97b7211cce | ||
|
|
3e762e13af | ||
|
|
e084317a46 | ||
|
|
531b4473e8 | ||
|
|
aefd0d2775 | ||
|
|
960468edf0 | ||
|
|
07ad1f58b5 | ||
|
|
095428be50 | ||
|
|
87fc8911fa | ||
|
|
58272e1ce8 | ||
|
|
700bbcb63f | ||
|
|
dde1d68876 | ||
|
|
71553a6153 | ||
|
|
d4f8de3e21 | ||
|
|
6cf5dea10d | ||
|
|
05379dfee6 | ||
|
|
5a6d49ff64 | ||
|
|
64ab940a26 | ||
|
|
55982ea36d | ||
|
|
21efcf2479 | ||
|
|
0dc7bfcadb | ||
|
|
22d99091e1 | ||
|
|
7558d3ffdc | ||
|
|
85ae41c44c | ||
|
|
91193850dd | ||
|
|
7cc04e3364 | ||
|
|
3da28090c6 | ||
|
|
1595ef2c0a | ||
|
|
83e3d81de7 | ||
|
|
18437ddda4 | ||
|
|
fd503171a1 | ||
|
|
7022139780 | ||
|
|
1e508e45af | ||
|
|
03d9ec2cad | ||
|
|
86fb48bab7 | ||
|
|
a4bc1e4a55 | ||
|
|
8681e15da5 | ||
|
|
ebc82f8b1b | ||
|
|
3bcd7bd7e1 | ||
|
|
b64d8669b1 | ||
|
|
0489044098 | ||
|
|
17e2062b72 | ||
|
|
4e4f5a698d | ||
|
|
b879d04bcd |
@@ -1,8 +1,4 @@
|
||||
# 1. Define the Python image to use for getting pip
|
||||
FROM pytorch/pytorch AS python-base
|
||||
|
||||
# 2. Define the .NET SDK image to build your application
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["src/AntSK/AntSK.csproj", "AntSK/"]
|
||||
RUN dotnet restore "AntSK/AntSK.csproj"
|
||||
@@ -11,19 +7,11 @@ WORKDIR "/src/AntSK"
|
||||
RUN dotnet build "AntSK.csproj" -c Release -o /app/build
|
||||
RUN dotnet publish "AntSK.csproj" -c Release -o /app/publish
|
||||
|
||||
# 3. Define the final image that will contain both .NET runtime and Python
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
|
||||
|
||||
# Copy the Python/pip installation from the official Python image
|
||||
COPY --from=python-base /usr/local /usr/local
|
||||
COPY --from=python-base /opt/conda/ /opt/conda/
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk-base:v1.0.0 AS final
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/publish .
|
||||
# Make sure the app and Python directories are in PATH
|
||||
ENV PATH="/app:/opt/conda/bin:/usr/local/bin:${PATH}"
|
||||
|
||||
ENV PATH="/app:/opt/conda/bin:/usr/local/bin:${PATH}"
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo 'Asia/Shanghai' >/etc/timezone
|
||||
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
RUN apt update && apt install -y libpugixml-dev libtbb-dev
|
||||
ENTRYPOINT ["dotnet", "AntSK.dll"]
|
||||
|
||||
216
LICENSE
216
LICENSE
@@ -1,201 +1,79 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
## AntSK 用户协议
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
欢迎使用 AntSK 。请仔细阅读以下协议条款,继续使用本软件即表示您同意本协议内容。
|
||||
|
||||
1. Definitions.
|
||||
**许可协议**
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
本软件采用 Apache License 2.0 许可。除 Apache License 2.0 规定的条款外,您在使用 AntSK 时还应遵守以下附加条款:
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
**一. 商用许可**
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
1. **免费商用**:用户在不修改代码的情况下,可以免费用于商业目的。
|
||||
2. **商业授权**:如果您满足以下任意条件之一,需取得商业授权:
|
||||
1. 对本软件进行二次修改、开发(包括但不限于修改应用名称、logo、代码以及功能)。
|
||||
2. 为企业客户提供多租户服务,且该服务支持 10 人或以上的使用。
|
||||
3. 预装或集成到硬件设备或产品中进行捆绑销售。
|
||||
4. 政府或教育机构的大规模采购项目,特别是涉及安全、数据隐私等敏感需求时。
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
**二. 贡献者协议**
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
作为 AntSK 的贡献者,您应当同意以下条款:
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
1. **许可调整**:生产者有权根据需要对开源协议进行调整,使其更加严格或宽松。
|
||||
2. **商业用途**:您贡献的代码可能会被用于商业用途,包括但不限于云业务运营。
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
**三. 其他条款**
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
1. 本协议条款的解释权归 AntSK 开发者所有。
|
||||
2. 本协议可能根据实际情况进行更新,更新时将通过本软件通知用户。
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
如有任何问题或需申请商业授权,请联系 AntSK 开发团队。
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
除上述特定条件外,其他所有权利和限制均遵循 Apache License 2.0。有关 Apache License 2.0 的详细信息,请访问 http://www.apache.org/licenses/LICENSE-2.0。
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
---
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
根据 Apache 许可证 2.0 版(“许可证”)进行许可;除非符合许可证,否则您不得使用此文件。您可以在以下网址获取许可证副本:
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
除非适用法律要求或书面同意,软件根据许可证分发的内容以“原样”分发,不附带任何明示或暗示的保证或条件。请参阅特定语言管理权限的许可证和许可证下的限制。
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
## AntSK User Agreement
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
Welcome to AntSK, a AI knowledge base. Please read the following agreement carefully. By continuing to use this software, you agree to the terms outlined below.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
**License Agreement**
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
This software is licensed under the **Apache License 2.0**. In addition to the terms of the Apache License 2.0, the following additional terms apply to the use of AntSK:
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
**I. Commercial Use License**
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
1. **Free Commercial Use**: Users can use the software for commercial purposes without modifying the code.
|
||||
2. **Commercial License Required**: A commercial license is required if any of the following conditions are met:
|
||||
1. You modify, develop, or alter the software, including but not limited to changes to the application name, logo, code, or functionality.
|
||||
2. You provide multi-tenant services to enterprise customers with 10 or more users.
|
||||
3. You pre-install or integrate the software into hardware devices or products and bundle it for sale.
|
||||
4. You are engaging in large-scale procurement for government or educational institutions, especially involving security, data privacy, or other sensitive requirements.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
**II. Contributor Agreement**
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
As a contributor to AntSK, you agree to the following:
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
1. **License Adjustment**: The producer reserves the right to adjust the open-source license as needed, making it stricter or more lenient.
|
||||
2. **Commercial Use**: Any code you contribute may be used for commercial purposes, including but not limited to cloud business operations.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
**III. Other Terms**
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
1. The interpretation of these terms is subject to the discretion of AntSK developers.
|
||||
2. These terms may be updated, and users will be notified through the software when changes occur.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
For any questions or to request a commercial license, please contact the AntSK development team.
|
||||
|
||||
Copyright [2024] [许泽宇]
|
||||
Apart from the specific conditions mentioned above, all other rights and restrictions follow the Apache License 2.0. Detailed information about the Apache License 2.0 can be found at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
---
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
||||
|
||||
66
README.md
66
README.md
@@ -20,7 +20,7 @@
|
||||
|
||||
- **Online Search**: AntSK, real-time access to the latest information, ensuring users receive the most timely and relevant data.
|
||||
|
||||
- **Model Management**: Adapts and manages integration of different models from different manufacturers, including gguf types supported by **llama.cpp** and models offline running supported by **llamafactory**.
|
||||
- **Model Management**: Adapts and manages integration of different models from different manufacturers, models offline running supported by **llamafactory** and **ollama**.
|
||||
|
||||
- **Domestic Innovation**: AntSK supports domestic models and databases and can run under domestic innovation conditions.
|
||||
|
||||
@@ -41,7 +41,9 @@ AntSK is suitable for various business scenarios, such as:
|
||||
### Online Demo
|
||||
[document](http://antsk.cn/)
|
||||
|
||||
[demo](https://antsk.ai-dotnet.com/)
|
||||
[demo](https://demo.antsk.cn/)
|
||||
and
|
||||
[demo1](https://antsk.ai-dotnet.com/)
|
||||
|
||||
```
|
||||
Default account: test
|
||||
@@ -84,7 +86,8 @@ version: '3.8'
|
||||
services:
|
||||
antsk:
|
||||
container_name: antsk
|
||||
image: registry.cn-hangzhou.aliyuncs.com/AIDotNet/antsk:v0.1.5ports:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/AIDotNet/antsk:v0.6.0
|
||||
ports:
|
||||
- 5000:5000
|
||||
networks:
|
||||
- antsk
|
||||
@@ -98,11 +101,18 @@ services:
|
||||
- D://model:/app/model
|
||||
networks:
|
||||
antsk:
|
||||
external: true
|
||||
```
|
||||
Taking this as an example, it means mounting the local D://model folder of Windows into the container /app/model. If so, the model address in your appsettings.json should be configured as
|
||||
```
|
||||
model/xxx.gguf
|
||||
```
|
||||
|
||||
[LiteDockerCompose](https://github.com/AIDotNet/AntSK/blob/main/docker-compose.simple.yml)
|
||||
|
||||
The compact version is deployed with sqlite-disk by one click
|
||||
|
||||
[FullDockerCompose](https://github.com/AIDotNet/AntSK/blob/main/docker-compose.yml)
|
||||
|
||||
The full version uses pg+aspire
|
||||
|
||||
|
||||
## 3️⃣Some meanings of configuration file
|
||||
```
|
||||
@@ -119,11 +129,6 @@ model/xxx.gguf
|
||||
"FileDir": {
|
||||
"DirectoryPath": "D:\\git\\AntBlazor\\model"
|
||||
},
|
||||
"LLamaSharp": {
|
||||
"RunType": "GPU",
|
||||
"ContextSize": 2048,
|
||||
"GpuLayerCount": 20
|
||||
},
|
||||
"Login": {
|
||||
"User": "admin",
|
||||
"Password": "xuzeyu"
|
||||
@@ -147,11 +152,8 @@ DBConnection.ConnectionStrings
|
||||
//The ConnectionString of Qdrant and AzureAISearch uses Endpoint | APIKey
|
||||
KernelMemory.VectorDb
|
||||
|
||||
//Local model execution options: GPU and CPU. When using the online API, any option can be used.
|
||||
LLamaSharp.RunType
|
||||
|
||||
//Local model path, used for quick selection of models under llama, as well as saving downloaded models.
|
||||
LLamaSharp.FileDirectory
|
||||
FileDir.DirectoryPath
|
||||
|
||||
//Default admin account password
|
||||
Login
|
||||
@@ -188,13 +190,6 @@ I'm using CodeFirst mode for the database, so as long as the database connection
|
||||
8. Many people ask about the difference between LLamaSharp and llamafactory. In fact, LLamaSharp is a .NET implementation of llama.cpp, but only supports local gguf models, while llamafactory supports a wider variety of models and uses Python implementation. The main difference lies here. Additionally, llamafactory has the ability to fine-tune models, which is an area we will focus on integrating in the future.
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
[PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)
|
||||
|
||||
If you would like to contribute, feel free to create a [Pull Request](https://github.com/AIDotNet/AntSK/pulls), or give us [Bug Report](https://github.com/AIDotNet/AntSK/issues/new).
|
||||
|
||||
|
||||
## 💕 Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute.
|
||||
@@ -204,15 +199,36 @@ This project exists thanks to all the people who contribute.
|
||||
</a>
|
||||
|
||||
## 🚨 Use Protocol
|
||||
This warehouse follows the [Apache-2.0 License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file) open source protocol.
|
||||
The Apache open source license allows the use of AntSK in commercial environments, provided that the license terms are followed. One of the main terms is to retain the copyright and license statements.
|
||||
|
||||
This warehouse follows the [AntSK License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file) open source protocol.
|
||||
|
||||
This project follows the Apache 2.0 agreement, in addition to the following additional terms
|
||||
|
||||
1. **Free Commercial Use**: Users can use the software for commercial purposes without modifying the code.
|
||||
2. **Commercial License Required**: A commercial license is required if any of the following conditions are met:
|
||||
1. You modify, develop, or alter the software, including but not limited to changes to the application name, logo, code, or functionality.
|
||||
2. You provide multi-tenant services to enterprise customers with 10 or more users.
|
||||
3. You pre-install or integrate the software into hardware devices or products and bundle it for sale.
|
||||
4. You are engaging in large-scale procurement for government or educational institutions, especially involving security, data privacy, or other sensitive requirements.
|
||||
|
||||
3. If you need authorization, you can contact WeChat: **xuzeyu91**
|
||||
|
||||
If you plan to use AntSK in commercial projects, you need to ensure that you follow the following steps:
|
||||
1. Copyright statement containing Apache license. [Apache-2.0 License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file).
|
||||
|
||||
1. Copyright statement containing AntSK license. [AntSK License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file).
|
||||
|
||||
2. If you modify the software source code, you need to clearly indicate these modifications in the source code.
|
||||
|
||||
3. Meet the above requirements
|
||||
|
||||
## 💕 Special thanks
|
||||
Helping enterprise AI application development, we recommend [AntBlazor](https://antblazor.com)
|
||||
|
||||
## ☎️Contact Me
|
||||
If you have any questions or suggestions, please contact me through my official WeChat account. We also have a discussion group where you can send a message to join, and then I will add you to the group.
|
||||
|
||||
Additionally, you can also contact me via email: antskpro@qq.com
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
70
README.zh.md
70
README.zh.md
@@ -22,7 +22,7 @@
|
||||
|
||||
- **联网搜索**:AntSK,实时获取最新信息,确保用户接受到的资料总是最及时、最相关的。
|
||||
|
||||
- **模型管理**:适配和管理集成不同厂商的不同模型。并且支持**llama.cpp**所支持的gguf类型,以及**llamafactory**所支持的模型离线运行
|
||||
- **模型管理**:适配和管理集成不同厂商的不同模型。并且支持**llama.cpp**所支持的gguf类型,以及**llamafactory** 和 **ollama** 所支持的模型离线运行
|
||||
|
||||
- **国产信创**:AntSK支持国产模型,和国产数据库,可以在信创条件下运行
|
||||
|
||||
@@ -43,10 +43,11 @@ AntSK 适用于多种业务场景,例如:
|
||||
## ✏️功能示例
|
||||
### 在线演示
|
||||
|
||||
[文档地址](http://antsk.cn/)
|
||||
[体验地址1](https://demo.antsk.cn/)
|
||||
|
||||
[体验地址](https://antsk.ai-dotnet.com/)
|
||||
和
|
||||
|
||||
[体验地址2](https://antsk.ai-dotnet.com/)
|
||||
```
|
||||
默认账号:test
|
||||
|
||||
@@ -72,6 +73,12 @@ AntSK 适用于多种业务场景,例如:
|
||||
|
||||
需要配置如下的配置文件
|
||||
|
||||
## 为了方便体验,我已经把打包好的程序放进了网盘,你只需要安装.net8环境即可运行。
|
||||
[.net8环境 ](https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0)
|
||||
|
||||
[我用夸克网盘分享了「AntSK」](https://pan.quark.cn/s/9462c849cbad)
|
||||
|
||||
|
||||
## 1️⃣使用docker-compose
|
||||
|
||||
提供了pg版本 **appsettings.json** 和 简化版本(**Sqlite+disk**) **docker-compose.simple.yml**
|
||||
@@ -93,7 +100,7 @@ version: '3.8'
|
||||
services:
|
||||
antsk:
|
||||
container_name: antsk
|
||||
image: registry.cn-hangzhou.aliyuncs.com/AIDotNet/antsk:v0.3.1
|
||||
image: registry.cn-hangzhou.aliyuncs.com/AIDotNet/antsk:v0.6.0
|
||||
ports:
|
||||
- 5000:5000
|
||||
networks:
|
||||
@@ -111,9 +118,15 @@ networks:
|
||||
antsk:
|
||||
```
|
||||
以这个为示例,意思是把windows本地D://model的文件夹挂载进 容器内/app/model 如果是这样你的appsettings.json中的模型地址应该配置为
|
||||
```
|
||||
model/xxx.gguf
|
||||
```
|
||||
|
||||
[LiteDockerCompose](https://github.com/AIDotNet/AntSK/blob/main/docker-compose.simple.yml)
|
||||
|
||||
精简版使用sqlite+disk向量模式,简化部署配置
|
||||
|
||||
[FullDockerCompose](https://github.com/AIDotNet/AntSK/blob/main/docker-compose.yml)
|
||||
|
||||
完整版使用pg+aspire 功能更完整,配置文件需要参考如下配置含义进行配置
|
||||
|
||||
|
||||
## 3️⃣配置文件的一些含义
|
||||
```
|
||||
@@ -130,11 +143,6 @@ model/xxx.gguf
|
||||
"FileDir": {
|
||||
"DirectoryPath": "D:\\git\\AntBlazor\\model"
|
||||
},
|
||||
"LLamaSharp": {
|
||||
"RunType": "GPU",
|
||||
"ContextSize": 2048,
|
||||
"GpuLayerCount": 20
|
||||
},
|
||||
"Login": {
|
||||
"User": "admin",
|
||||
"Password": "xuzeyu"
|
||||
@@ -157,11 +165,8 @@ DBConnection.ConnectionStrings
|
||||
//Qdrant 和AzureAISearch 的 ConnectionString 使用 Endpoint|APIKey
|
||||
KernelMemory.VectorDb
|
||||
|
||||
//本地模型使用的运行方式 GUP CPU ,如果用在线API 这个随意使用一个即可
|
||||
LLamaSharp.RunType
|
||||
|
||||
//本地模型路径,用于在选择llama时可以快速选择目录下的模型,以及保存下载的模型
|
||||
LLamaSharp.FileDirectory
|
||||
FileDir.DirectoryPath
|
||||
|
||||
//默认管理员账号密码
|
||||
Login
|
||||
@@ -195,13 +200,6 @@ DB我使用的是CodeFirst模式,只要配置好数据库链接,表结构是
|
||||
7、点击保存,然后就可以开始聊天了
|
||||
8、很多人会问 LLamaSharp与llamafactory有什么区别?其实这两者LLamaSharp是llama.cpp的 dotnet实现,但是只支持本地gguf模型, 而llamafactory 支持的模型种类更多,但使用的是python的实现,其主要差异在这里,另外llamafactory具有模型微调的能力,这也是我们下一步需要重点集成的部分。
|
||||
```
|
||||
|
||||
## 🤝 贡献
|
||||
|
||||
[](https://github.com/AIDotNet/AntSK/pulls)
|
||||
|
||||
如果你想贡献,可以创建一个[拉取请求](https://github.com/AIDotNet/AntSK/pulls), 或给我们[错误报告](https://github.com/AIDotNet/AntSK/issues/new).
|
||||
|
||||
|
||||
## 💕 贡献者
|
||||
|
||||
@@ -213,18 +211,36 @@ DB我使用的是CodeFirst模式,只要配置好数据库链接,表结构是
|
||||
|
||||
## 🚨 使用协议
|
||||
|
||||
本仓库遵循 [Apache-2.0 License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file) 开源协议。
|
||||
Apache开源许可证允许在商业环境中使用AntSK,前提是需要遵守许可证的条款。主要条款之一是要保留版权声明和许可证声明。
|
||||
本仓库遵循 [AntSK License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file) 开源协议。
|
||||
|
||||
除以下附加条款外,该项目遵循Apache 2.0协议
|
||||
|
||||
1. **免费商用**:用户在不修改代码的情况下,可以免费用于商业目的。
|
||||
2. **商业授权**:如果您满足以下任意条件之一,需取得商业授权:
|
||||
1. 对本软件进行二次修改、开发(包括但不限于修改应用名称、logo、代码以及功能)。
|
||||
2. 为企业客户提供多租户服务,且该服务支持 10 人或以上的使用。
|
||||
3. 预装或集成到硬件设备或产品中进行捆绑销售。
|
||||
4. 政府或教育机构的大规模采购项目,特别是涉及安全、数据隐私等敏感需求时。
|
||||
|
||||
3. 如果您需要授权,可以联系微信:xuzeyu91
|
||||
|
||||
如果您打算在商业项目中使用AntSK,您需要确保遵守以下步骤:
|
||||
|
||||
1、包含Apache许可证的版权声明。 [Apache-2.0 License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file) 。
|
||||
1. 包含AntSK许可证的版权声明。 [AntSK License](https://github.com/AIDotNet/AntSK?tab=Apache-2.0-1-ov-file) 。
|
||||
|
||||
2、如果您修改了软件源代码,您需要在源代码中明确标明这些修改。
|
||||
2. 如果您修改了软件源代码,您需要在源代码中明确标明这些修改。
|
||||
|
||||
3. 满足以上要求
|
||||
|
||||
## 💕 特别感谢
|
||||
助力企业级AI应用开发,推荐使用 [AntBlazor](https://antblazor.com)
|
||||
|
||||
|
||||
## ☎️联系我
|
||||
如有任何问题或建议,请通过以下方式关注我的公众号《许泽宇的技术分享》,发消息与我联系,我们也有AIDotnet交流群,可以发送进群等消息,然后我会拉你进交流群
|
||||
|
||||
另外您也可以通过邮箱与我联系:antskpro@qq.com
|
||||
|
||||

|
||||
|
||||
## 🌟 Star History
|
||||
|
||||
@@ -3,9 +3,9 @@ version: '3.8'
|
||||
services:
|
||||
antsk:
|
||||
container_name: antsk
|
||||
image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:v0.4.1
|
||||
image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:v0.6.2
|
||||
# 如果需要pytorch环境需要使用下面这个镜像,镜像比较大
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:p0.4.1
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:p0.6.2
|
||||
ports:
|
||||
- 5000:5000
|
||||
networks:
|
||||
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
- 18889:18889
|
||||
restart: unless-stopped
|
||||
antskpg:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/pg:v0.5.0
|
||||
image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/pg:v0.5.0
|
||||
container_name: antskpg
|
||||
restart: always
|
||||
ports: # 生产环境建议不要暴露
|
||||
@@ -32,9 +32,9 @@ services:
|
||||
- ./pg/data:/var/lib/postgresql/data
|
||||
antsk:
|
||||
container_name: antsk
|
||||
image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:v0.4.1
|
||||
image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:v0.6.2
|
||||
# 如果需要pytorch环境需要使用下面这个镜像,镜像比较大
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:p0.4.1
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/xuzeyu91/antsk:p0.6.2
|
||||
ports:
|
||||
- 5000:5000
|
||||
networks:
|
||||
|
||||
@@ -8,50 +8,44 @@
|
||||
<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.1" />
|
||||
<PackageReference Include="AntDesign.ProLayout" Version="0.19.0" />
|
||||
<PackageReference Include="AntDesign.Charts" Version="0.5.6" />
|
||||
<PackageReference Include="AntDesign.ProLayout" Version="0.20.3" />
|
||||
<PackageReference Include="BlazorComponents.Terminal" Version="0.6.0" />
|
||||
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
|
||||
|
||||
<PackageReference Include="pythonnet" Version="3.0.3" />
|
||||
<PackageReference Include="pythonnet" Version="3.0.4" />
|
||||
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
|
||||
|
||||
<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="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.158" />
|
||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
|
||||
<PackageReference Include="RestSharp" Version="111.2.0" />
|
||||
<PackageReference Include="NPOI" Version="2.7.0" />
|
||||
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="1.14.1" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.14.1" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="1.14.1-alpha" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftVersion)" />
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.169" />
|
||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
|
||||
<PackageReference Include="RestSharp" Version="$(RestSharpVersion)" />
|
||||
<PackageReference Include="NPOI" Version="2.7.1" />
|
||||
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="$(SKVersion)" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="$(SKVersion)" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Core" Version="$(SKVersion)-alpha" />
|
||||
<PackageReference Include="Microsoft.KernelMemory.Core" Version="$(KMVersion)" />
|
||||
<PackageReference Include="Microsoft.KernelMemory.MemoryDb.Postgres" Version="$(KMVersion)" />
|
||||
<PackageReference Include="Microsoft.KernelMemory.MemoryDb.Qdrant" Version="$(KMVersion)" />
|
||||
<PackageReference Include="Microsoft.KernelMemory.MemoryDb.Redis" Version="$(KMVersion)" />
|
||||
<PackageReference Include="Microsoft.KernelMemory.MemoryDb.AzureAISearch" Version="$(KMVersion)" />
|
||||
|
||||
<PackageReference Include="LLamaSharp" Version="$(LLamaSharpVersion)" />
|
||||
<PackageReference Include="LLamaSharp.Backend.Cpu" Version="$(LLamaSharpVersion)" />
|
||||
<PackageReference Include="LLamaSharp.Backend.Cuda12" Version="$(LLamaSharpVersion)" />
|
||||
<PackageReference Include="LLamaSharp.kernel-memory" Version="$(LLamaSharpVersion)" />
|
||||
<PackageReference Include="LLamaSharp.semantic-kernel" Version="$(LLamaSharpVersion)" />
|
||||
|
||||
<PackageReference Include="Serilog" Version="4.0.0" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.1-dev-00972" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.1-dev-10391" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="3.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="4.1.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AntSK.LLamaFactory\AntSK.LLamaFactory.csproj" />
|
||||
<ProjectReference Include="..\AntSk.LLM\AntSK.LLM.csproj" />
|
||||
<ProjectReference Include="..\AntSK.LLM\AntSK.LLM.csproj" />
|
||||
<ProjectReference Include="..\AntSK.OCR\AntSK.OCR.csproj" />
|
||||
<ProjectReference Include="..\MiddleWare\AntSK.BackgroundTask\AntSK.BackgroundTask.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -188,11 +188,6 @@
|
||||
<member name="M:AntSK.Domain.Domain.Other.KMExcelHandler.InvokeAsync(Microsoft.KernelMemory.Pipeline.DataPipeline,System.Threading.CancellationToken)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="F:AntSK.Domain.Domain.Other.LLamaConfig.dicLLamaWeights">
|
||||
<summary>
|
||||
避免模型重复加载,本地缓存
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Domain.Other.QAHandler.StepName">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
@@ -257,6 +252,53 @@
|
||||
<param name="history"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Result.Code">
|
||||
<summary>
|
||||
错误码,0是正常返回,异常返回错误码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Result.Data">
|
||||
<summary>
|
||||
返回数据
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Result.Message">
|
||||
<summary>
|
||||
返回信息详情
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.ResponseResult.Success">
|
||||
<summary>
|
||||
执行成功
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.ResponseResult.Success(System.Object,System.String,System.String)">
|
||||
<summary>
|
||||
执行成功
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<param name="code"></param>
|
||||
<param name="message"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.ResponseResult.Error(System.Object,System.String,System.String)">
|
||||
<summary>
|
||||
执行失败
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<param name="code"></param>
|
||||
<param name="message"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.ResponseResult.Error(System.String,System.String)">
|
||||
<summary>
|
||||
执行失败
|
||||
</summary>
|
||||
<param name="code"></param>
|
||||
<param name="message"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Options.DBConnectionOption.DbType">
|
||||
<summary>
|
||||
sqlite连接字符串
|
||||
@@ -424,7 +466,7 @@
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Repositories.Chats.CreateTime">
|
||||
<summary>
|
||||
创建事件
|
||||
创建时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:AntSK.Domain.Repositories.Chats.FileName">
|
||||
@@ -924,6 +966,20 @@
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.Utils.ConvertUtils.Unescape(System.String)">
|
||||
<summary>
|
||||
\uxxxx转中文,保留换行符号
|
||||
</summary>
|
||||
<param name="unicodeString"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.Utils.ConvertUtils.IsStream(System.String)">
|
||||
<summary>
|
||||
是否为流式请求
|
||||
</summary>
|
||||
<param name="value"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:AntSK.Domain.Utils.RepoFiles.SamplePluginsPath">
|
||||
<summary>
|
||||
Scan the local folders from the repo, looking for "samples/plugins" folder.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace AntSK.Domain.Common
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class AntSkFunctionAttribute : Attribute
|
||||
public class AntSKFunctionAttribute : Attribute
|
||||
{
|
||||
// 自定义的ActionAttribute
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using LLamaSharp.KernelMemory;
|
||||
using Microsoft.KernelMemory.AI;
|
||||
using Microsoft.KernelMemory.AI;
|
||||
using Microsoft.KernelMemory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
using LLama.Common;
|
||||
using LLama;
|
||||
using LLamaSharp.KernelMemory;
|
||||
using Microsoft.KernelMemory.AI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.KernelMemory.AI;
|
||||
using AntSK.Domain.Domain.Other.Bge;
|
||||
|
||||
namespace AntSK.Domain.Common.Embedding
|
||||
@@ -52,5 +44,10 @@ namespace AntSK.Domain.Common.Embedding
|
||||
{
|
||||
return BgeEmbeddingConfig.TokenCount(text);
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> GetTokens(string text)
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Amazon.Runtime.Internal.Util;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -12,7 +12,9 @@ namespace AntSK.Domain.Domain.Interface
|
||||
{
|
||||
public event LogMessageHandler LogMessageReceived;
|
||||
Task PipInstall();
|
||||
Task StartLLamaFactory(string modelName, string templateName);
|
||||
|
||||
Task PipInstallName(string name);
|
||||
Task StartLLamaFactory(string modelName);
|
||||
|
||||
void KillProcess();
|
||||
|
||||
|
||||
15
src/AntSK.Domain/Domain/Interface/IOllamaService.cs
Normal file
15
src/AntSK.Domain/Domain/Interface/IOllamaService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static AntSK.Domain.Domain.Service.OllamaService;
|
||||
|
||||
namespace AntSK.Domain.Domain.Interface
|
||||
{
|
||||
public interface IOllamaService
|
||||
{
|
||||
public event LogMessageHandler LogMessageReceived;
|
||||
Task OllamaPull(string modelName);
|
||||
}
|
||||
}
|
||||
@@ -18,4 +18,11 @@
|
||||
public List<string> input { get; set; }
|
||||
}
|
||||
|
||||
public class RerankModel
|
||||
{
|
||||
public string modelId { get; set; }
|
||||
public string query { get; set; }
|
||||
|
||||
public string document { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,6 @@ namespace AntSK.Domain.Domain.Model.Enum
|
||||
[Display(Name = "Azure Open AI")]
|
||||
AzureOpenAI = 2,
|
||||
|
||||
[Display(Name = "LLama本地模型")]
|
||||
LLamaSharp = 3,
|
||||
|
||||
[Display(Name = "星火大模型")]
|
||||
SparkDesk = 4,
|
||||
|
||||
@@ -28,8 +25,11 @@ namespace AntSK.Domain.Domain.Model.Enum
|
||||
BgeEmbedding = 7,
|
||||
[Display(Name = "Bge Rerank")]
|
||||
BgeRerank = 8,
|
||||
[Display(Name = "StableDiffusion")]
|
||||
StableDiffusion = 9,
|
||||
|
||||
[Display(Name = "Ollama")]
|
||||
Ollama = 10,
|
||||
[Display(Name = "OllamaEmbedding")]
|
||||
OllamaEmbedding = 11,
|
||||
[Display(Name = "模拟输出")]
|
||||
Mock = 100,
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace AntSK.Domain.Domain.Model.Enum
|
||||
{
|
||||
Chat = 1,
|
||||
Embedding = 2,
|
||||
Image=3,
|
||||
Rerank=4
|
||||
}
|
||||
}
|
||||
|
||||
85
src/AntSK.Domain/Domain/Model/ResponseResult.cs
Normal file
85
src/AntSK.Domain/Domain/Model/ResponseResult.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
namespace AntSK.Domain
|
||||
{
|
||||
public class Result
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误码,0是正常返回,异常返回错误码
|
||||
/// </summary>
|
||||
public string Code { get; set; } = "0";
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public object Data { get; set; }
|
||||
/// <summary>
|
||||
/// 返回信息详情
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class ResponseResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行成功
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Result Success()
|
||||
{
|
||||
return new Result
|
||||
{
|
||||
Data = "",
|
||||
Code = "0",
|
||||
Message = "ok"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行成功
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public static Result Success(this object data, string code = "0", string message = "ok")
|
||||
{
|
||||
return new Result
|
||||
{
|
||||
Data = data,
|
||||
Code = code,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 执行失败
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public static Result Error(this object data, string code, string message)
|
||||
{
|
||||
return new Result
|
||||
{
|
||||
Data = data,
|
||||
Code = code,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// 执行失败
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public static Result Error(string code, string message)
|
||||
{
|
||||
return new Result
|
||||
{
|
||||
Data = "",
|
||||
Code = code,
|
||||
Message = message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Amazon.Runtime.Internal.Util;
|
||||
using AntSK.BackgroundTask;
|
||||
using AntSK.BackgroundTask;
|
||||
using AntSK.Domain.Domain.Interface;
|
||||
using AntSK.Domain.Domain.Model;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static Python.Runtime.Py;
|
||||
using AntSK.Domain.Utils;
|
||||
|
||||
namespace AntSK.Domain.Domain.Other.Bge
|
||||
{
|
||||
@@ -26,11 +27,7 @@ namespace AntSK.Domain.Domain.Other.Bge
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Runtime.PythonDLL))
|
||||
{
|
||||
Runtime.PythonDLL = pythondllPath;
|
||||
}
|
||||
PythonEngine.Initialize();
|
||||
PyRunTime.InitRunTime(pythondllPath);
|
||||
try
|
||||
{
|
||||
using (GIL())// 初始化Python环境的Global Interpreter Lock)
|
||||
@@ -39,8 +36,16 @@ namespace AntSK.Domain.Domain.Other.Bge
|
||||
dynamic flagEmbedding = Py.Import("FlagEmbedding");
|
||||
|
||||
dynamic model_dir = modelscope.snapshot_download(modelName, revision: "master");
|
||||
dynamic flagReranker = flagEmbedding.FlagReranker(model_dir, use_fp16: true);
|
||||
model = flagReranker;
|
||||
if (modelName == "BAAI/bge-reranker-v2-minicpm-layerwise")
|
||||
{
|
||||
dynamic flagReranker = flagEmbedding.LayerWiseFlagLLMReranker(model_dir, use_fp16: true);
|
||||
model = flagReranker;
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamic flagReranker = flagEmbedding.FlagReranker(model_dir, use_fp16: true);
|
||||
model = flagReranker;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
@@ -69,7 +74,11 @@ namespace AntSK.Domain.Domain.Other.Bge
|
||||
pyList.Append(item.ToPython()); // 将C# string转换为Python对象并添加到PyList中
|
||||
}
|
||||
PyObject result = model.compute_score(pyList, normalize: true);
|
||||
return result.As<double>();
|
||||
|
||||
var res = result.ToString();
|
||||
var res1 = res.Replace("[", "").Replace("]", "").ConvertToDouble();
|
||||
|
||||
return res1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.KernelMemory.AI.OpenAI;
|
||||
using Microsoft.KernelMemory.AI.OpenAI.GPT3;
|
||||
using Python.Runtime;
|
||||
using Serilog;
|
||||
using System;
|
||||
@@ -28,13 +27,7 @@ namespace AntSK.Domain.Domain.Other.Bge
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
//Runtime.PythonDLL = @"D:\Programs\Python\Python311\python311.dll";
|
||||
if (string.IsNullOrEmpty(Runtime.PythonDLL))
|
||||
{
|
||||
Runtime.PythonDLL = pythondllPath;
|
||||
}
|
||||
PythonEngine.Initialize();
|
||||
PythonEngine.BeginAllowThreads();
|
||||
PyRunTime.InitRunTime(pythondllPath);
|
||||
try
|
||||
{
|
||||
using (GIL())// 初始化Python环境的Global Interpreter Lock)
|
||||
|
||||
28
src/AntSK.Domain/Domain/Other/Bge/PyRunTime.cs
Normal file
28
src/AntSK.Domain/Domain/Other/Bge/PyRunTime.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Python.Runtime;
|
||||
|
||||
namespace AntSK.Domain.Domain.Other.Bge
|
||||
{
|
||||
public static class PyRunTime
|
||||
{
|
||||
static object lockobj = new object();
|
||||
|
||||
static bool isInit = false;
|
||||
|
||||
public static void InitRunTime(string pythonPath)
|
||||
{
|
||||
lock (lockobj)
|
||||
{
|
||||
if (!isInit)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Runtime.PythonDLL))
|
||||
{
|
||||
Runtime.PythonDLL = pythonPath;
|
||||
}
|
||||
PythonEngine.Initialize();
|
||||
PythonEngine.BeginAllowThreads();
|
||||
isInit = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using AntSK.Domain.Options;
|
||||
using LLama;
|
||||
using LLama.Common;
|
||||
using LLamaSharp.KernelMemory;
|
||||
|
||||
namespace AntSK.Domain.Domain.Other
|
||||
{
|
||||
public static class LLamaConfig
|
||||
{
|
||||
static object lockobj = new object();
|
||||
/// <summary>
|
||||
/// 避免模型重复加载,本地缓存
|
||||
/// </summary>
|
||||
static Dictionary<string, (LLamaWeights, ModelParams)> dicLLamaWeights = new Dictionary<string, (LLamaWeights, ModelParams)>();
|
||||
public static (LLamaWeights, ModelParams) GetLLamaConfig(string modelPath, LLamaSharpConfig config = null)
|
||||
{
|
||||
lock (lockobj)
|
||||
{
|
||||
if (dicLLamaWeights.ContainsKey(modelPath))
|
||||
{
|
||||
return dicLLamaWeights.GetValueOrDefault(modelPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
InferenceParams infParams = new() { AntiPrompts = ["\n\n"] };
|
||||
LLamaSharpConfig lsConfig = new(modelPath) { DefaultInferenceParams = infParams };
|
||||
if (config != null)
|
||||
{
|
||||
lsConfig = config;
|
||||
}
|
||||
var parameters = new ModelParams(lsConfig.ModelPath)
|
||||
{
|
||||
ContextSize = LLamaSharpOption.ContextSize ?? 2048,
|
||||
Seed = lsConfig?.Seed ?? 0,
|
||||
GpuLayerCount = LLamaSharpOption.GpuLayerCount ?? 20,
|
||||
Embeddings = true
|
||||
};
|
||||
var weights = LLamaWeights.LoadFromFile(parameters);
|
||||
dicLLamaWeights.Add(modelPath, (weights, parameters));
|
||||
return (weights, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,10 +90,12 @@ namespace AntSK.Domain.Domain.Service
|
||||
public async IAsyncEnumerable<StreamingKernelContent> SendKmsByAppAsync(Apps app, string questions, ChatHistory history, string filePath, List<RelevantSource> relevantSources = null)
|
||||
{
|
||||
relevantSources?.Clear();
|
||||
var relevantSourceList = await _kMService.GetRelevantSourceList(app, questions);
|
||||
List<RelevantSource> relevantSourceList = new List<RelevantSource>();
|
||||
|
||||
var _kernel = _kernelService.GetKernelByApp(app);
|
||||
if (!string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
//上传文件问答
|
||||
var memory = _kMService.GetMemoryByApp(app);
|
||||
|
||||
// 匹配GUID的正则表达式
|
||||
@@ -105,7 +107,7 @@ namespace AntSK.Domain.Domain.Service
|
||||
{
|
||||
var fileId = match.Value;
|
||||
|
||||
var status=await memory.IsDocumentReadyAsync(fileId, index: KmsConstantcs.KmsIndex);
|
||||
var status = await memory.IsDocumentReadyAsync(fileId, index: KmsConstantcs.KmsIndex);
|
||||
if (!status)
|
||||
{
|
||||
var result = await memory.ImportDocumentAsync(new Document(fileId).AddFile(filePath)
|
||||
@@ -129,6 +131,11 @@ namespace AntSK.Domain.Domain.Service
|
||||
app.Prompt = KmsConstantcs.KmsPrompt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//从知识库问答
|
||||
relevantSourceList = await _kMService.GetRelevantSourceList(app, questions);
|
||||
}
|
||||
|
||||
|
||||
var dataMsg = new StringBuilder();
|
||||
|
||||
@@ -10,8 +10,6 @@ using AntSK.Domain.Repositories;
|
||||
using AntSK.Domain.Utils;
|
||||
using AntSK.OCR;
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using LLama;
|
||||
using LLamaSharp.KernelMemory;
|
||||
using Markdig;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
@@ -171,12 +169,6 @@ namespace AntSK.Domain.Domain.Service
|
||||
APIType = AzureOpenAIConfig.APITypes.EmbeddingGeneration,
|
||||
});
|
||||
break;
|
||||
|
||||
case Model.Enum.AIType.LLamaSharp:
|
||||
var (weights, parameters) = LLamaConfig.GetLLamaConfig(embedModel.ModelName);
|
||||
var embedder = new LLamaEmbedder(weights, parameters);
|
||||
memory.WithLLamaSharpTextEmbeddingGeneration(new LLamaSharpTextEmbeddingGenerator(embedder));
|
||||
break;
|
||||
case Model.Enum.AIType.BgeEmbedding:
|
||||
string pyDll = embedModel.EndPoint;
|
||||
string bgeEmbeddingModelName = embedModel.ModelName;
|
||||
@@ -185,6 +177,13 @@ namespace AntSK.Domain.Domain.Service
|
||||
case Model.Enum.AIType.DashScope:
|
||||
memory.WithDashScopeDefaults(embedModel.ModelKey);
|
||||
break;
|
||||
case Model.Enum.AIType.OllamaEmbedding:
|
||||
memory.WithOpenAITextEmbeddingGeneration(new OpenAIConfig()
|
||||
{
|
||||
APIKey = "NotNull",
|
||||
EmbeddingModel = embedModel.ModelName
|
||||
}, null, false, embeddingHttpClient);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,15 +210,15 @@ namespace AntSK.Domain.Domain.Service
|
||||
APIType = AzureOpenAIConfig.APITypes.TextCompletion,
|
||||
});
|
||||
break;
|
||||
|
||||
case Model.Enum.AIType.LLamaSharp:
|
||||
var (weights, parameters) = LLamaConfig.GetLLamaConfig(chatModel.ModelName);
|
||||
var context = weights.CreateContext(parameters);
|
||||
var executor = new StatelessExecutor(weights, parameters);
|
||||
memory.WithLLamaSharpTextGeneration(new LlamaSharpTextGenerator(weights, context, executor));
|
||||
break;
|
||||
case Model.Enum.AIType.LLamaFactory:
|
||||
|
||||
memory.WithOpenAITextGeneration(new OpenAIConfig()
|
||||
{
|
||||
APIKey = "NotNull",
|
||||
TextModel = chatModel.ModelName
|
||||
}, null, chatHttpClient);
|
||||
break;
|
||||
case Model.Enum.AIType.Ollama:
|
||||
memory.WithOpenAITextGeneration(new OpenAIConfig()
|
||||
{
|
||||
APIKey = "NotNull",
|
||||
|
||||
@@ -4,25 +4,15 @@ using AntSK.Domain.Domain.Interface;
|
||||
using AntSK.Domain.Domain.Other;
|
||||
using AntSK.Domain.Repositories;
|
||||
using AntSK.Domain.Utils;
|
||||
using LLama;
|
||||
using LLamaSharp.SemanticKernel.TextCompletion;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.SemanticKernel;
|
||||
using Microsoft.SemanticKernel.Plugins.Core;
|
||||
using Microsoft.SemanticKernel.TextGeneration;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using ServiceLifetime = AntSK.Domain.Common.DependencyInjection.ServiceLifetime;
|
||||
using AntSK.LLM.Mock;
|
||||
using AntSK.Domain.Domain.Model.Enum;
|
||||
using AntSK.LLM.LLamaFactory;
|
||||
using System.Reflection;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
using Microsoft.KernelMemory;
|
||||
using OpenCvSharp.ML;
|
||||
using LLamaSharp.SemanticKernel.ChatCompletion;
|
||||
using Microsoft.SemanticKernel.ChatCompletion;
|
||||
using Amazon.Runtime.Internal.Util;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AntSK.Domain.Domain.Service
|
||||
@@ -108,13 +98,6 @@ namespace AntSK.Domain.Domain.Service
|
||||
);
|
||||
break;
|
||||
|
||||
case Model.Enum.AIType.LLamaSharp:
|
||||
var (weights, parameters) = LLamaConfig.GetLLamaConfig(chatModel.ModelName);
|
||||
var ex = new StatelessExecutor(weights, parameters);
|
||||
builder.Services.AddKeyedSingleton<ITextGenerationService>("local-llama", new LLamaSharpTextCompletion(ex));
|
||||
builder.Services.AddKeyedSingleton<IChatCompletionService>("local-llama-chat", new LLamaSharpChatCompletion(ex));
|
||||
break;
|
||||
|
||||
case Model.Enum.AIType.SparkDesk:
|
||||
|
||||
var settings = chatModel.ModelKey.Split("|");
|
||||
@@ -154,7 +137,14 @@ namespace AntSK.Domain.Domain.Service
|
||||
case Model.Enum.AIType.LLamaFactory:
|
||||
builder.AddOpenAIChatCompletion(
|
||||
modelId: chatModel.ModelName,
|
||||
apiKey: "123",
|
||||
apiKey: "NotNull",
|
||||
httpClient: chatHttpClient
|
||||
);
|
||||
break;
|
||||
case AIType.Ollama:
|
||||
builder.AddOpenAIChatCompletion(
|
||||
modelId: chatModel.ModelName,
|
||||
apiKey: "NotNull",
|
||||
httpClient: chatHttpClient
|
||||
);
|
||||
break;
|
||||
@@ -169,7 +159,7 @@ namespace AntSK.Domain.Domain.Service
|
||||
public void ImportFunctionsByApp(Apps app, Kernel _kernel)
|
||||
{
|
||||
//插件不能重复注册,否则会异常
|
||||
if (_kernel.Plugins.Any(p => p.Name == "AntSkFunctions"))
|
||||
if (_kernel.Plugins.Any(p => p.Name == "AntSKFunctions"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -180,7 +170,7 @@ namespace AntSK.Domain.Domain.Service
|
||||
//本地函数插件
|
||||
ImportNativeFunction(app, functions);
|
||||
|
||||
_kernel.ImportPluginFromFunctions("AntSkFunctions", functions);
|
||||
_kernel.ImportPluginFromFunctions("AntSKFunctions", functions);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using Amazon.Runtime.Internal.Util;
|
||||
using AntSK.Domain.Common.DependencyInjection;
|
||||
using AntSK.Domain.Common.DependencyInjection;
|
||||
using AntSK.Domain.Domain.Interface;
|
||||
using AntSK.Domain.Domain.Model.Dto;
|
||||
using AntSK.Domain.Options;
|
||||
using AntSK.Domain.Utils;
|
||||
using AntSK.LLamaFactory.Model;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -23,8 +24,6 @@ namespace AntSK.Domain.Domain.Service
|
||||
{
|
||||
private Process process;
|
||||
|
||||
public static bool isProcessComplete = false;
|
||||
|
||||
private readonly object _syncLock = new object();
|
||||
private List<LLamaModel> modelList = new List<LLamaModel>();
|
||||
|
||||
@@ -42,7 +41,6 @@ namespace AntSK.Domain.Domain.Service
|
||||
var cmdTask = Task.Factory.StartNew(() =>
|
||||
{
|
||||
|
||||
var isProcessComplete = false;
|
||||
|
||||
process = new Process
|
||||
{
|
||||
@@ -74,13 +72,53 @@ namespace AntSK.Domain.Domain.Service
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
await cmdTask;
|
||||
}
|
||||
|
||||
public async Task StartLLamaFactory(string modelName, string templateName)
|
||||
public async Task PipInstallName(string name)
|
||||
{
|
||||
|
||||
var cmdTask = Task.Factory.StartNew(() =>
|
||||
{
|
||||
|
||||
var isProcessComplete = false;
|
||||
process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "pip",
|
||||
Arguments = $"install {name} -i https://pypi.tuna.tsinghua.edu.cn/simple",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory,
|
||||
}
|
||||
};
|
||||
process.OutputDataReceived += (sender, eventArgs) =>
|
||||
{
|
||||
Log.Information($"{eventArgs.Data}");
|
||||
OnLogMessageReceived(eventArgs.Data);
|
||||
};
|
||||
process.ErrorDataReceived += (sender, eventArgs) =>
|
||||
{
|
||||
Log.Information($"{eventArgs.Data}");
|
||||
OnLogMessageReceived(eventArgs.Data);
|
||||
};
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
process.WaitForExit();
|
||||
OnLogMessageReceived("--------------------完成--------------------");
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
await cmdTask;
|
||||
}
|
||||
public async Task StartLLamaFactory(string modelName)
|
||||
{
|
||||
var cmdTask = Task.Factory.StartNew(() =>
|
||||
{
|
||||
string templateName = "default";
|
||||
var modelList = GetLLamaFactoryModels();
|
||||
var model = modelList.Where(p => p.ModelScope == modelName).FirstOrDefault();
|
||||
if (model.IsNotNull() && !string.IsNullOrEmpty(model.Template))
|
||||
{
|
||||
templateName = model.Template;
|
||||
}
|
||||
|
||||
process = new Process
|
||||
{
|
||||
@@ -162,7 +200,7 @@ namespace AntSK.Domain.Domain.Service
|
||||
{
|
||||
foreach (var m in model.Models)
|
||||
{
|
||||
modelList.Add(new LLamaModel() { Name=m.Key, ModelScope=m.Value.MODELSCOPE });
|
||||
modelList.Add(new LLamaModel() { Name = m.Key, ModelScope = m.Value.MODELSCOPE, Template = model.Template });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
src/AntSK.Domain/Domain/Service/OllamaService.cs
Normal file
74
src/AntSK.Domain/Domain/Service/OllamaService.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using AntSK.Domain.Common.DependencyInjection;
|
||||
using AntSK.Domain.Domain.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using AntSK.Domain.Utils;
|
||||
|
||||
namespace AntSK.Domain.Domain.Service
|
||||
{
|
||||
[ServiceDescription(typeof(IOllamaService), ServiceLifetime.Singleton)]
|
||||
public class OllamaService : IOllamaService
|
||||
{
|
||||
private Process process;
|
||||
public delegate Task LogMessageHandler(string message);
|
||||
public event LogMessageHandler LogMessageReceived;
|
||||
protected virtual async Task OnLogMessageReceived(string message)
|
||||
{
|
||||
LogMessageReceived?.Invoke(message);
|
||||
}
|
||||
|
||||
public async Task OllamaPull(string modelName)
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
var cmdTask = Task.Factory.StartNew(() =>
|
||||
{
|
||||
|
||||
var isProcessComplete = false;
|
||||
|
||||
process = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = "ollama",
|
||||
Arguments = "pull " + modelName,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
}
|
||||
};
|
||||
process.OutputDataReceived += (sender, eventArgs) =>
|
||||
{
|
||||
Log.Information($"{eventArgs.Data.ConvertToString()}");
|
||||
if (!eventArgs.Data.ConvertToString().Contains("The handle is invalid"))
|
||||
{
|
||||
OnLogMessageReceived(eventArgs.Data.ConvertToString());
|
||||
}
|
||||
};
|
||||
process.ErrorDataReceived += (sender, eventArgs) =>
|
||||
{
|
||||
Log.Error($"{eventArgs.Data.ConvertToString()}");
|
||||
if (!eventArgs.Data.ConvertToString().Contains("The handle is invalid"))
|
||||
{
|
||||
OnLogMessageReceived(eventArgs.Data.ConvertToString());
|
||||
}
|
||||
};
|
||||
process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
process.StartInfo.StandardErrorEncoding = Encoding.UTF8;
|
||||
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
process.WaitForExit();
|
||||
|
||||
OnLogMessageReceived("--------------------完成--------------------");
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
await cmdTask;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace AntSK.Domain.Options
|
||||
{
|
||||
public class LLamaSharpOption
|
||||
{
|
||||
public static string RunType { get; set; }
|
||||
public static uint? ContextSize { get; set; }
|
||||
public static int? GpuLayerCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace AntSK.Domain.Repositories
|
||||
/// 图标
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Icon { get; set; }
|
||||
public string Icon { get; set; } = "windows";
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
@@ -42,6 +42,7 @@ namespace AntSK.Domain.Repositories
|
||||
/// <summary>
|
||||
/// Embedding 模型Id
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string? EmbeddingModelID { get; set; }
|
||||
|
||||
public string? RerankModelID { get; set; }
|
||||
@@ -75,6 +76,7 @@ namespace AntSK.Domain.Repositories
|
||||
/// <summary>
|
||||
/// 知识库ID列表
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(1000)")]
|
||||
public string? KmsIdList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -85,8 +87,8 @@ namespace AntSK.Domain.Repositories
|
||||
/// <summary>
|
||||
/// 相似度
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "70")]
|
||||
public double Relevance { get; set; } = 70f;
|
||||
[SugarColumn(DefaultValue = "60")]
|
||||
public double Relevance { get; set; } = 60f;
|
||||
|
||||
/// <summary>
|
||||
/// 提问最大token数
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace AntSK.Domain.Repositories
|
||||
/// </summary>
|
||||
public bool IsSend { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 创建事件
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace AntSK.Domain.Repositories
|
||||
/// 图标
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Icon { get; set; }
|
||||
public string Icon { get; set; } = "question-circle";
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using System.Security.Cryptography;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
namespace AntSK.Domain.Utils
|
||||
@@ -263,6 +266,50 @@ namespace AntSK.Domain.Utils
|
||||
return s.Equals(value, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// \uxxxx转中文,保留换行符号
|
||||
/// </summary>
|
||||
/// <param name="unicodeString"></param>
|
||||
/// <returns></returns>
|
||||
public static string Unescape(this string value)
|
||||
{
|
||||
if (value.IsNull())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Formatting formatting = Formatting.None;
|
||||
|
||||
object jsonObj = JsonConvert.DeserializeObject(value);
|
||||
string unescapeValue = JsonConvert.SerializeObject(jsonObj, formatting);
|
||||
return unescapeValue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否为流式请求
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsStream(this string value)
|
||||
{
|
||||
// 正则表达式忽略空格的情况
|
||||
string pattern = @"\s*""stream""\s*:\s*true\s*";
|
||||
|
||||
// 使用正则表达式匹配
|
||||
bool contains = Regex.IsMatch(value, pattern);
|
||||
return contains;
|
||||
}
|
||||
|
||||
public static string AntSKCalculateSHA256(this BinaryData binaryData)
|
||||
{
|
||||
byte[] byteArray = SHA256.HashData(binaryData.ToMemory().Span);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
using Serilog;
|
||||
using Serilog;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace AntSK.Domain.Utils
|
||||
@@ -17,12 +17,19 @@ namespace AntSK.Domain.Utils
|
||||
UriBuilder uriBuilder;
|
||||
Regex regex = new Regex(@"(https?)://([^/:]+)(:\d+)?/(.*)");
|
||||
Match match = regex.Match(_endPoint);
|
||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" && request.Content != null)
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
var mediaType = request.Content.Headers.ContentType.MediaType;
|
||||
string requestBody = (await request.Content.ReadAsStringAsync()).Unescape();
|
||||
var uncaseBody = new StringContent(requestBody, Encoding.UTF8, mediaType);
|
||||
request.Content = uncaseBody;
|
||||
|
||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").ConvertToString() == "Development")
|
||||
{
|
||||
string requestBody = await request.Content.ReadAsStringAsync();
|
||||
//生产环境根据环境变量可去关闭日志
|
||||
//便于调试查看请求prompt
|
||||
Log.Information(requestBody);
|
||||
Log.Information("{Message}", $"【模型服务接口调用-{guid},host:{_endPoint}】:{Environment.NewLine}{requestBody}");
|
||||
}
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
string xieyi = match.Groups[1].Value;
|
||||
@@ -72,7 +79,11 @@ namespace AntSK.Domain.Utils
|
||||
|
||||
// 接着,调用基类的 SendAsync 方法将你的修改后的请求发出去
|
||||
HttpResponseMessage response = await base.SendAsync(request, cancellationToken);
|
||||
|
||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").ConvertToString() == "Development")
|
||||
{
|
||||
string responseContent = requestBody.IsStream() ? response.Content.ReadAsStringAsync().Result : response.Content.ReadAsStringAsync().Result.Unescape();
|
||||
Log.Information("{Message}", $"【模型服务接口返回-{guid},host:{_endPoint}】:{Environment.NewLine}{responseContent}");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -84,7 +95,7 @@ namespace AntSK.Domain.Utils
|
||||
{
|
||||
var handler = new OpenAIHttpClientHandler(endPoint.ConvertToString());
|
||||
var httpClient = new HttpClient(handler);
|
||||
httpClient.Timeout = TimeSpan.FromMinutes(5);
|
||||
httpClient.Timeout = TimeSpan.FromMinutes(10);
|
||||
return httpClient;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,22 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="1.14.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="RestSharp" Version="111.2.0" />
|
||||
<PackageReference Include="Cnblogs.KernelMemory.AI.DashScope" Version="0.1.0" />
|
||||
<PackageReference Include="Microsoft.SemanticKernel" Version="$(SKVersion)" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftVersion)" />
|
||||
<PackageReference Include="RestSharp" Version="$(RestSharpVersion)" />
|
||||
<PackageReference Include="Cnblogs.KernelMemory.AI.DashScope" Version="0.3.0" />
|
||||
<PackageReference Include="Cnblogs.SemanticKernel.Connectors.DashScope" Version="0.3.2" />
|
||||
<PackageReference Include="Sdcb.SparkDesk" Version="3.0.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="OllamaEmbeddingModelList.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="OllamaModelList.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="StableDiffusion\Backend\CPU\stable-diffusion.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
@@ -42,7 +48,7 @@
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="StableDiffusionModelList.txt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
12
src/AntSK.LLM/OllamaEmbeddingModelList.txt
Normal file
12
src/AntSK.LLM/OllamaEmbeddingModelList.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
nomic-embed-text:v1.5
|
||||
mxbai-embed-large:335m
|
||||
all-minilm:22m
|
||||
all-minilm:33m
|
||||
snowflake-arctic-embed:22m
|
||||
snowflake-arctic-embed:33m
|
||||
snowflake-arctic-embed:110m
|
||||
snowflake-arctic-embed:137m
|
||||
snowflake-arctic-embed:335m
|
||||
bge-m3
|
||||
bge-large:335m
|
||||
paraphrase-multilingual:278m
|
||||
111
src/AntSK.LLM/OllamaModelList.txt
Normal file
111
src/AntSK.LLM/OllamaModelList.txt
Normal file
@@ -0,0 +1,111 @@
|
||||
gemma2
|
||||
gemma2:27b
|
||||
gemma:2b
|
||||
gemma:7b
|
||||
llama3
|
||||
llama3:70b
|
||||
yi:6b
|
||||
yi:9B
|
||||
yi:34B
|
||||
qwen2:0.5b
|
||||
qwen2:1.5b
|
||||
qwen2:7b
|
||||
qwen2:72b
|
||||
qwen:0.5b
|
||||
qwen:1.8b
|
||||
qwen:4b
|
||||
qwen:7b
|
||||
qwen:14b
|
||||
qwen:32b
|
||||
qwen:72b
|
||||
qwen:110b
|
||||
deepseek-coder:1.3b
|
||||
deepseek-coder:6.7b
|
||||
deepseek-coder:33b
|
||||
deepseek-coder-v2:16b
|
||||
deepseek-coder-v2:236b
|
||||
deepseek-r1:1.5b
|
||||
deepseek-r1:7b
|
||||
deepseek-r1:8b
|
||||
deepseek-r1:14b
|
||||
deepseek-r1:32b
|
||||
deepseek-r1:70b
|
||||
phi:2.7b
|
||||
phi3:mini
|
||||
phi3:medium
|
||||
phi3:medium-128k
|
||||
aya:8b
|
||||
aya:35b
|
||||
mistral:7b
|
||||
mixtral:8x22b
|
||||
mixtral:8x7b
|
||||
codegemma:2b
|
||||
codegemma:7b
|
||||
command-r:35b
|
||||
llava
|
||||
gemma:2b
|
||||
gemma:7b
|
||||
llama2:7b
|
||||
llama2:13b
|
||||
llama2:70b
|
||||
llama2-chinese:7b
|
||||
llama2-chinese:13b
|
||||
llama3.1:8b
|
||||
llama3.1:70b
|
||||
llama3.1:405b
|
||||
codellama:7b
|
||||
codellama:13b
|
||||
codellama:34b
|
||||
codellama:70b
|
||||
dolphin-mistral:7b
|
||||
dolphin-mixtral:8x22b
|
||||
dolphin-mixtral:8x7b
|
||||
llama2-uncensored:7b
|
||||
llama2-uncensored:70b
|
||||
tinyllama:1.1b
|
||||
openchat:7b
|
||||
orca-mini:3b
|
||||
orca-mini:7b
|
||||
orca-mini:13b
|
||||
orca-mini:70b
|
||||
mistral-openorca:7b
|
||||
dolphin-llama3:8b
|
||||
dolphin-llama3:70b
|
||||
starcoder:1b
|
||||
starcoder:3b
|
||||
starcoder:7b
|
||||
starcoder:15b
|
||||
starcoder2:3b
|
||||
starcoder2:7b
|
||||
starcoder2:15b
|
||||
zephyr:7b
|
||||
zephyr:141b
|
||||
nous-hermes2:10.7b
|
||||
nous-hermes2:34b
|
||||
vicuna:7b
|
||||
vicuna:13b
|
||||
vicuna:33b
|
||||
wizard-vicuna-uncensored:7b
|
||||
wizard-vicuna-uncensored:13b
|
||||
wizard-vicuna-uncensored:30b
|
||||
wizardlm2:7b
|
||||
codestral:22b
|
||||
tinydolphin:1.1b
|
||||
openhermes:v2.5
|
||||
neural-chat:7b
|
||||
codeqwen:7b
|
||||
phind-codellama:34b
|
||||
nous-hermes:7b
|
||||
nous-hermes:13b
|
||||
nous-hermes:13b
|
||||
starling-lm:7b
|
||||
llama3-gradient:8b
|
||||
llama3-gradient:70b
|
||||
yarn-llama2:7b
|
||||
yarn-llama2:13b
|
||||
llava-llama3:8b
|
||||
llama-pro:instruct
|
||||
everythinglm:13b
|
||||
llava-phi3:3.8b
|
||||
mistrallite:7b
|
||||
notus:7b
|
||||
@@ -50,7 +50,7 @@ namespace AntSK.LLM.SparkDesk
|
||||
parameters.Temperature = (float)chatExecutionSettings.Temperature;
|
||||
parameters.MaxTokens = chatExecutionSettings.MaxTokens ?? parameters.MaxTokens;
|
||||
|
||||
IList<KernelFunctionMetadata> functions = kernel?.Plugins.GetFunctionsMetadata().Where(x => x.PluginName == "AntSkFunctions").ToList() ?? [];
|
||||
IList<KernelFunctionMetadata> functions = kernel?.Plugins.GetFunctionsMetadata().Where(x => x.PluginName == "AntSKFunctions").ToList() ?? [];
|
||||
var functionDefs = functions.Select(func => new FunctionDef(func.Name, func.Description, func.Parameters.Select(p => new FunctionParametersDef(p.Name, p.ParameterType?.IsClass == true ? "object" : "string", p.Description, p.IsRequired)).ToList())).ToList();
|
||||
|
||||
List<ChatMessage> messages = GetSparkMessage(chatHistory);
|
||||
@@ -133,7 +133,7 @@ namespace AntSK.LLM.SparkDesk
|
||||
parameters.Temperature = (float)chatExecutionSettings.Temperature;
|
||||
parameters.MaxTokens = chatExecutionSettings.MaxTokens ?? parameters.MaxTokens;
|
||||
|
||||
IList<KernelFunctionMetadata> functions = kernel?.Plugins.GetFunctionsMetadata().Where(x => x.PluginName == "AntSkFunctions").ToList() ?? [];
|
||||
IList<KernelFunctionMetadata> functions = kernel?.Plugins.GetFunctionsMetadata().Where(x => x.PluginName == "AntSKFunctions").ToList() ?? [];
|
||||
var functionDefs = functions.Select(func => new FunctionDef(func.Name, func.Description, func.Parameters.Select(p => new FunctionParametersDef(p.Name, p.ParameterType?.IsClass == true ? "object" : "string", p.Description, p.IsRequired)).ToList())).ToList();
|
||||
List<ChatMessage> messages = GetSparkMessage(chatHistory);
|
||||
await foreach (StreamedChatResponse msg in _client.ChatAsStreamAsync(_options.ModelVersion, messages.ToArray(), parameters, functionDefs.Count > 0 ? [.. functionDefs] : null, cancellationToken: cancellationToken))
|
||||
@@ -67,7 +67,7 @@ namespace AntSK.LLM.SparkDesk
|
||||
parameters.Temperature = (float)chatExecutionSettings.Temperature;
|
||||
parameters.MaxTokens = chatExecutionSettings.MaxTokens ?? parameters.MaxTokens;
|
||||
|
||||
IList<KernelFunctionMetadata> functions = kernel?.Plugins.GetFunctionsMetadata().Where(x => x.PluginName == "AntSkFunctions").ToList() ?? [];
|
||||
IList<KernelFunctionMetadata> functions = kernel?.Plugins.GetFunctionsMetadata().Where(x => x.PluginName == "AntSKFunctions").ToList() ?? [];
|
||||
var functionDefs = functions.Select(func => new FunctionDef(func.Name, func.Description, func.Parameters.Select(p => new FunctionParametersDef(p.Name, p.ParameterType?.IsClass == true ? "object" : "string", p.Description, p.IsRequired)).ToList())).ToList();
|
||||
|
||||
//var messages = GetHistories(prompt);
|
||||
@@ -23,5 +23,7 @@ namespace AntSK.LLamaFactory.Model
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ModelScope { get; set; }
|
||||
|
||||
public string Template { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ fire
|
||||
modelscope
|
||||
langchain-community
|
||||
sentence_transformers
|
||||
FlagEmbedding
|
||||
flagembedding
|
||||
packaging
|
||||
pyyaml
|
||||
trl>=0.8.6
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
<PackageReference Include="Microsoft.KernelMemory.Core" Version="$(KMVersion)" />
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.9.0.20240103" />
|
||||
<PackageReference Include="Sdcb.OpenCvSharp4.mini.runtime.debian.12-x64" Version="4.8.0.20231125" />
|
||||
<PackageReference Include="Sdcb.OpenVINO" Version="0.6.5" />
|
||||
<PackageReference Include="Sdcb.OpenVINO" Version="0.6.6" />
|
||||
<PackageReference Include="Sdcb.OpenVINO.PaddleOCR.Models.Online" Version="0.6.2" />
|
||||
<PackageReference Include="Sdcb.OpenVINO.PaddleOCR" Version="0.6.3" />
|
||||
<PackageReference Include="Sdcb.OpenVINO.runtime.ubuntu.22.04-x64" Version="2024.0.0" />
|
||||
<PackageReference Include="Sdcb.OpenVINO.runtime.win-x64" Version="2024.1.0" />
|
||||
<PackageReference Include="Sdcb.OpenVINO.runtime.ubuntu.22.04-x64" Version="2024.2.0" />
|
||||
<PackageReference Include="Sdcb.OpenVINO.runtime.win-x64" Version="2024.2.0" />
|
||||
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -19,7 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MiddleWare", "MiddleWare",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntSK.BackgroundTask", "MiddleWare\AntSK.BackgroundTask\AntSK.BackgroundTask.csproj", "{DF87E829-99C5-44A7-9718-B3E67DC801F6}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntSK.LLM", "AntSk.LLM\AntSK.LLM.csproj", "{19529BFA-152F-4A8C-8254-F2D4896AB739}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntSK.LLM", "AntSK.LLM\AntSK.LLM.csproj", "{19529BFA-152F-4A8C-8254-F2D4896AB739}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntSK.Test", "AntSK.Test\AntSK.Test.csproj", "{6AD71410-127F-4C83-95A8-F699C39B44FF}"
|
||||
EndProject
|
||||
|
||||
13
src/AntSK/.config/dotnet-tools.json
Normal file
13
src/AntSK/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "9.0.1",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
<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</NoWarn>
|
||||
<ApplicationIcon>AntSKlogo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="llamafactory\**" />
|
||||
<Content Remove="llamafactory\**" />
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
cursor:pointer;
|
||||
border:none;
|
||||
background-image: url('http://img.shields.io/github/stars/aidotnet/antsk?style=social');
|
||||
width:88px;
|
||||
width:90px;
|
||||
height:20px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,5 @@
|
||||
using AntSK.Domain.Domain.Model.Dto.OpenAPI;
|
||||
using AntSK.Domain;
|
||||
using AntSK.Domain.Domain.Model.Dto.OpenAPI;
|
||||
using AntSK.Domain.Utils;
|
||||
using AntSK.Services.OpenApi;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -22,5 +23,22 @@ namespace AntSK.Controllers
|
||||
string sk = HttpContext.Request.Headers["Authorization"].ConvertToString();
|
||||
await _openApiService.Chat(model, sk, HttpContext);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/v1/rerank")]
|
||||
public async Task<IActionResult> Rerank(RerankModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sk = HttpContext.Request.Headers["Authorization"].ConvertToString();
|
||||
var result = await _openApiService.Rerank(model, sk, HttpContext);
|
||||
return Ok(result.Success());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(ResponseResult.Error("1001",ex.Message));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
</ErrorBoundary>
|
||||
</ChildContent>
|
||||
<FooterRender>
|
||||
<FooterView Copyright="2024 许泽宇的技术分享" Links="Links"></FooterView>
|
||||
<FooterView Copyright="2024 AntSK版权所有" Links="Links"></FooterView>
|
||||
</FooterRender>
|
||||
</AntDesign.ProLayout.BasicLayout>
|
||||
<SettingDrawer />
|
||||
@@ -93,9 +93,9 @@
|
||||
{
|
||||
new LinkItem
|
||||
{
|
||||
Key = "许泽宇的技术分享",
|
||||
Title = "许泽宇的技术分享",
|
||||
Href = "./assets/gzh.jpg",
|
||||
Key = "antsk.cn",
|
||||
Title = "antsk.cn",
|
||||
Href = "https://antsk.cn",
|
||||
BlankTarget = true,
|
||||
},
|
||||
new LinkItem
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
@Body
|
||||
</div>
|
||||
<FooterView Copyright="许泽宇的技术分享" Links="Links"></FooterView>
|
||||
<FooterView Copyright="2024 AntSK版权所有" Links="Links"></FooterView>
|
||||
</div>
|
||||
|
||||
@code
|
||||
@@ -27,9 +27,9 @@
|
||||
{
|
||||
new LinkItem
|
||||
{
|
||||
Key = "许泽宇的技术分享",
|
||||
Title = "许泽宇的技术分享",
|
||||
Href = "./assets/gzh.jpg",
|
||||
Key = "antsk.cn",
|
||||
Title = "antsk.cn",
|
||||
Href = "https://antsk.cn",
|
||||
BlankTarget = true,
|
||||
},
|
||||
new LinkItem
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
font-size: 14px;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.container__b__0 {
|
||||
background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center 110px;
|
||||
background-size: 100%;
|
||||
}
|
||||
.container__b__0 {
|
||||
background-image: url('./assets/TVYTbAXWheQpRcWDaDMu.svg');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center 110px;
|
||||
background-size: 100%;
|
||||
}
|
||||
.container__b__0 .content {
|
||||
padding: 32px 0 24px;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
<FormItem Label="应用名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入应用名称" @bind-Value="@context.Name" />
|
||||
</FormItem>
|
||||
<FormItem Label="图标" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
@* <Input Placeholder="请输入图标" @bind-Value="@context.Icon" />
|
||||
<a href="https://antblazor.com/zh-CN/components/icon" target="_blank">图标库</a> *@
|
||||
@* <FormItem Label="图标" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入图标" @bind-Value="@context.Icon" />
|
||||
<a href="https://antblazor.com/zh-CN/components/icon" target="_blank">图标库</a>
|
||||
<IconPicker @bind-Value="@context.Icon"></IconPicker>
|
||||
</FormItem>
|
||||
</FormItem> *@
|
||||
<FormItem Label="类型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<RadioGroup @bind-Value="context.Type" OnChange="OnAppTypeChange" TValue="string">
|
||||
<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>
|
||||
@@ -61,18 +61,6 @@
|
||||
<span>更发散</span>
|
||||
</FormItem>
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
<FormItem Label="图片模型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Select DataSource="@_imageList"
|
||||
@bind-Value="@context.ImageModelID"
|
||||
ValueProperty="c=>c.Id"
|
||||
LabelProperty="c=>'【'+c.AIType.ToString()+'】'+c.ModelDescription">
|
||||
</Select>
|
||||
<Button Type="@ButtonType.Link" OnClick="NavigateModelList">去创建</Button>
|
||||
</FormItem>
|
||||
}
|
||||
@if (@context.Type == AppType.chat.ToString())
|
||||
{
|
||||
<FormItem Label="API插件列表" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
|
||||
@@ -48,7 +48,6 @@ namespace AntSK.Pages.AppPage
|
||||
private List<AIModels> _chatList;
|
||||
private List<AIModels> _embedingList;
|
||||
private List<AIModels> _rerankList;
|
||||
private List<AIModels> _imageList;
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
@@ -58,7 +57,7 @@ namespace AntSK.Pages.AppPage
|
||||
_chatList = models.Where(p => p.AIModelType == AIModelType.Chat).ToList();
|
||||
_embedingList = models.Where(p => p.AIModelType == AIModelType.Embedding).ToList();
|
||||
_rerankList = models.Where(p => p.AIModelType == AIModelType.Rerank).ToList();
|
||||
_imageList = models.Where(p => p.AIModelType == AIModelType.Image).ToList();
|
||||
|
||||
|
||||
_functionService.SearchMarkedMethods();
|
||||
foreach (var func in _functionService.Functions)
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
{
|
||||
<Card Hoverable Bordered Class="card" Actions="@(new[] {
|
||||
info(()=> Info(context.Id)) ,
|
||||
use(()=> Use(context.Id)),
|
||||
open(()=> Open(context.Id)),
|
||||
delete(async ()=>await Delete(context.Id)) ,
|
||||
|
||||
@@ -75,6 +76,7 @@
|
||||
@code
|
||||
{
|
||||
RenderFragment info(Action clickAction) =>@<a key="info" @onclick="@clickAction">查看</a>;
|
||||
RenderFragment use(Action clickAction) =>@<a key="use" @onclick="@clickAction">使用</a>;
|
||||
RenderFragment open(Action clickAction) =>@<a key="info" @onclick="@clickAction">外部使用</a>;
|
||||
RenderFragment delete(Action clickAction) => @<a key="delete" @onclick="@clickAction">删除</a> ;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace AntSK.Pages.AppPage
|
||||
}
|
||||
else
|
||||
{
|
||||
data = await _apps_Repositories.GetListAsync(p => p.Name.Contains(searchKey));
|
||||
data = await _apps_Repositories.GetListAsync(p => p.Name.Contains(searchKey)|| p.SecretKey==searchKey);
|
||||
}
|
||||
|
||||
list.AddRange(data);
|
||||
@@ -57,6 +57,10 @@ namespace AntSK.Pages.AppPage
|
||||
NavigationManager.NavigateTo($"/app/open/{id}");
|
||||
}
|
||||
|
||||
private void Use(string id)
|
||||
{
|
||||
NavigationManager.NavigateTo($"/chat/{id}");
|
||||
}
|
||||
|
||||
private async Task Delete(string id)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<Icon Style="float:right;margin-top:10px;" Type="copy" Theme="outline" OnClick="async () =>await OnCopyAsync(item)" />
|
||||
</GridCol>
|
||||
<GridCol Span="1">
|
||||
<Image Width="25px" Height="25px" Style="margin-top:10px;" Src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" />
|
||||
<Image Width="25px" Height="25px" Style="margin-top:10px;" Src="./assets/KDpgvguMpGfqaHPjicRK.svg" />
|
||||
</GridCol>
|
||||
</GridRow>
|
||||
}
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
<GridRow>
|
||||
<GridCol Span="1">
|
||||
<Image Width="25px" Height="25px" Style="margin-top:10px;" Src="https://gw.alipayobjects.com/zos/antfincdn/aPkFc8Sj7n/method-draw-image.svg" />
|
||||
<Image Width="25px" Height="25px" Style="margin-top:10px;" Src="./assets/method-draw-image.svg" />
|
||||
</GridCol>
|
||||
<GridCol Span="23">
|
||||
<div class="chat-bubble received">
|
||||
@@ -126,6 +126,11 @@
|
||||
.ant-card-body {
|
||||
height: 90% !important;
|
||||
}
|
||||
|
||||
.think {
|
||||
color: gray;
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
|
||||
@code {
|
||||
|
||||
@@ -19,6 +19,7 @@ using Microsoft.SemanticKernel.ChatCompletion;
|
||||
using Microsoft.SemanticKernel.Connectors.OpenAI;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AntSK.Pages.ChatPage.Components
|
||||
{
|
||||
@@ -82,6 +83,7 @@ namespace AntSK.Pages.ChatPage.Components
|
||||
var userSession = userSessionStorageResult.Success ? userSessionStorageResult.Value : null;
|
||||
_userName = userSession?.UserName;
|
||||
await GetMsgList();
|
||||
await MarkDown();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取聊天记录列表
|
||||
@@ -323,15 +325,16 @@ namespace AntSK.Pages.ChatPage.Components
|
||||
};
|
||||
MessageList.Add(info);
|
||||
var chatResult = _chatService.SendKmsByAppAsync(app, questions, history, filePath, _relevantSources);
|
||||
StringBuilder rawContent = new StringBuilder();
|
||||
await foreach (var content in chatResult)
|
||||
{
|
||||
|
||||
info.Context += content.ConvertToString();
|
||||
await Task.Delay(50);
|
||||
rawContent.Append(content.ConvertToString());
|
||||
info.Context = Markdown.ToHtml(rawContent.ToString().Replace("<think>", "<div class=\"think\">").Replace("</think>", "</div>"));
|
||||
await Task.Delay(30);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
//全部处理完后再处理一次Markdown
|
||||
await MarkDown(info);
|
||||
//全部处理完后再处理一次Markdown 处理代码高亮
|
||||
await MarkDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -344,10 +347,12 @@ namespace AntSK.Pages.ChatPage.Components
|
||||
{
|
||||
Chats info = null;
|
||||
var chatResult = _chatService.SendChatByAppAsync(app, history);
|
||||
StringBuilder rawContent = new StringBuilder();
|
||||
await foreach (var content in chatResult)
|
||||
{
|
||||
if (info == null)
|
||||
{
|
||||
rawContent.Append(content.ConvertToString());
|
||||
info = new Chats();
|
||||
info.Id = Guid.NewGuid().ToString();
|
||||
info.UserName = _userName;
|
||||
@@ -359,13 +364,14 @@ namespace AntSK.Pages.ChatPage.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
info.Context += content.ConvertToString();
|
||||
await Task.Delay(50);
|
||||
rawContent.Append(content.ConvertToString());
|
||||
}
|
||||
info.Context = Markdown.ToHtml(rawContent.ToString().Replace("<think>", "<div class=\"think\">").Replace("</think>", "</div>"));
|
||||
await Task.Delay(30);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
//全部处理完后再处理一次Markdown
|
||||
await MarkDown(info);
|
||||
//全部处理完后再处理一次Markdown 处理代码高亮
|
||||
await MarkDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -373,14 +379,8 @@ namespace AntSK.Pages.ChatPage.Components
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
/// <returns></returns>
|
||||
private async Task MarkDown(Chats info)
|
||||
private async Task MarkDown()
|
||||
{
|
||||
if (info.IsNotNull())
|
||||
{
|
||||
// info!.HtmlAnswers = markdown.Transform(info.HtmlAnswers);
|
||||
info!.Context = Markdown.ToHtml(info.Context);
|
||||
|
||||
}
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await _JSRuntime.InvokeVoidAsync("Prism.highlightAll");
|
||||
await _JSRuntime.ScrollToBottomAsync("scrollDiv");
|
||||
|
||||
@@ -68,104 +68,142 @@
|
||||
</AntDesign.Col>
|
||||
</Row>
|
||||
<Divider><Title Level="3">功能特性</Title></Divider>
|
||||
<Space Size=@(("10", "10" )) Wrap Align="start" Style="padding:10px">
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🍬语义内核") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>1、采用遥遥领先的自然语言处理技术</Text>
|
||||
<br>
|
||||
<Text>2、准确理解、处理和响应复杂的语义查询</Text>
|
||||
<br>
|
||||
<Text>3、为用户提供精确的信息检索和推荐服务</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🏁知识库") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>1、通过文档(Word、PDF、Excel、Txt、Markdown、Json、PPT)等形式导入知识库</Text>
|
||||
<br>
|
||||
<Text>2、可以进行知识库文档搜索问答</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🌈GPTs 生成") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>1、支持创建个性化的GPTs</Text>
|
||||
<br>
|
||||
<Text>2、构建您自己的GPTs</Text>
|
||||
<br>
|
||||
<Text>3、可以尽情发挥你的想象力</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🎁插件生态") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>1、开放式API插件系统,允许第三方开发者或服务商轻松将其接口集成到AntSK,不断增强应用功能</Text>
|
||||
<br>
|
||||
<Text>2、开放式函数插件系统,标准格式的函数代码以及dll后集成到AntSK,不断增强应用功能</Text>
|
||||
<br>
|
||||
<Text>3、支持二次开发Function</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("📱模型集成与管理") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>1、适配和管理集成不同厂商的不同模型</Text>
|
||||
<br>
|
||||
<Text>
|
||||
2、并且支持llama.cpp所支持的gguf类型的模型离线运行
|
||||
</Text>
|
||||
<br>
|
||||
<Space Size=@(("10", "10" )) Wrap Align="start" Style="padding:10px">
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("👉🏻商业授权") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● AntSKPro为商业版 <a href="https://antsk.cn" target="_blank">访问官网</a></Text>
|
||||
<br>
|
||||
<Text>● 开源版本请参见:</Text>
|
||||
<a href="https://github.com/AIDotNet/AntSK" target="_blank">AntSK开源版</a>
|
||||
<br>
|
||||
<Text>● 未获取商业授权,禁止商业使用</Text>
|
||||
<br>
|
||||
<Text>● 如需商业授权,请联系微信:</Text>
|
||||
<b style="color:#7F7FFF">xuzeyu91</b>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🌟AntSKPro 一体机") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>
|
||||
3、支持llamafactory所支持的模型,包括baichuan、gemma、yuan、yi等
|
||||
● 海量会话+向量+重排离线模型
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
4、未来将实现模型的训练、微调、部署一站式服务
|
||||
</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🔗国产信创") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>1、支持国产本地化模型</Text>
|
||||
<br>
|
||||
<Text>
|
||||
2、支持国产信创数据库
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
3、支持信创环境运行
|
||||
</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("❤项目最新进展") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Image Height="170" Src="./assets/gzh.jpg" />
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🥤项目赞助") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Image Width="110" Src="./assets/zfb.png" />
|
||||
<Image Width="110" Src="./assets/wx.png" />
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
<Text>● 装机直发、开箱即用</Text>
|
||||
<a href="https://antsk.cn/archives/wei-ming-ming-wen-zhang" target="_blank">更多详情</a>
|
||||
<br>
|
||||
<Text>
|
||||
● 保姆式指导
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 整机硬件质保三年
|
||||
</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🍬语义内核") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 采用领先的自然语言处理技术</Text>
|
||||
<br>
|
||||
<Text>● 精准理解、处理和响应复杂的语义查询</Text>
|
||||
<br>
|
||||
<Text>● 为用户提供精准的信息检索和推荐服务</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🏁知识库") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 支持导入各种格式的文档(如Word, PDF, Excel, Txt, Json, PPT, Png等)至知识库和知识图谱</Text>
|
||||
<br>
|
||||
<Text>● 可进行知识库和知识图谱文档的搜索问答</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🌈GPTs 生成") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 支持创建个性化的GPTs</Text>
|
||||
<br>
|
||||
<Text>● 构建您自己的GPTs</Text>
|
||||
<br>
|
||||
<Text>● 尽情发挥您的想象力</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🎁插件生态") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 开放API插件系统,允许第三方开发者或服务商轻松集成接口至AntSK,持续增强应用功能</Text>
|
||||
<br>
|
||||
<Text>● 开放函数插件系统,标准格式的函数代码及dll文件可集成至AntSK,持续增强应用能力</Text>
|
||||
<br>
|
||||
<Text>● 支持二次开发Function</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("📱模型集成与管理") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 适配与管理来自不同厂商的多种模型</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 支持ollama支持的gguf模型类型离线运行
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 支持llamafactory所支持的模型,包括baichuan、gemma、yuan、yi等
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 未来将实现模型的训练、微调、部署一站式服务
|
||||
</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("🔗国产信创") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 支持国产本地化模型</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 支持国产信创数据库
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 支持信创环境运行
|
||||
</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
<SpaceItem>
|
||||
<Card Bordered="true" Title=@("✨技术支持") Hoverable="true" Style="height:260px;width:300px">
|
||||
<Body>
|
||||
<Text>● 商业版享有专业的技术支持(1对1)</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 提供技术指导、方案设计、技术对接等服务
|
||||
</Text>
|
||||
<br>
|
||||
<Text>
|
||||
● 提供培训服务
|
||||
</Text>
|
||||
<br>
|
||||
</Body>
|
||||
</Card>
|
||||
</SpaceItem>
|
||||
</Space>
|
||||
</GridContent>
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
<FormItem Label="知识库名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入知识库名称" @bind-Value="@context.Name" />
|
||||
</FormItem>
|
||||
<FormItem Label="图标" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
@* <Input Placeholder="请输入图标" @bind-Value="@context.Icon" />
|
||||
<a href="https://antblazor.com/zh-CN/components/icon" target="_blank">图标库</a> *@
|
||||
@* <FormItem Label="图标" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入图标" @bind-Value="@context.Icon" />
|
||||
<a href="https://antblazor.com/zh-CN/components/icon" target="_blank">图标库</a>
|
||||
<IconPicker @bind-Value="@context.Icon"></IconPicker>
|
||||
</FormItem>
|
||||
</FormItem>*@
|
||||
<FormItem Label="描述" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入描述" @bind-Value="@context.Describe" />
|
||||
</FormItem>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<TextArea Placeholder="一个一行,以冒号分割。例如:Content-Type:application/json" @bind-Value="@context.Header" MinRows="3" />
|
||||
</FormItem>
|
||||
<FormItem Label="Method类型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<EnumRadioGroup ButtonStyle="@RadioButtonStyle.Outline" @bind-Value="context.Method"></EnumRadioGroup>
|
||||
<EnumRadioGroup ButtonStyle="@RadioButtonStyle.Solid" @bind-Value="context.Method"></EnumRadioGroup>
|
||||
</FormItem>
|
||||
|
||||
@if (context.Method == HttpMethodType.Get)
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
@using BlazorComponents.Terminal
|
||||
@page "/modelmanager/model/add"
|
||||
@page "/modelmanager/model/add/{ModelId}"
|
||||
@page "/modelmanager/model/addbypath/{ModelPath}"
|
||||
@using AntSK.Services.Auth
|
||||
@inherits AuthComponentBase
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@@ -18,104 +17,100 @@
|
||||
<Card>
|
||||
<Form Model="@_aiModel"
|
||||
Style="margin-top: 8px;"
|
||||
OnFinish="HandleSubmit">
|
||||
OnFinish="HandleSubmit"
|
||||
Autocomplete="off">
|
||||
<FormItem Label="模型描述" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入模型描述" @bind-Value="@context.ModelDescription" />
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="AI类型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<EnumRadioGroup @bind-Value="context.AIType" ButtonStyle="RadioButtonStyle.Solid" OnChange="AITypeChange" TEnum="AIType"> </EnumRadioGroup>
|
||||
</FormItem>
|
||||
<FormItem Label="模型类型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<RadioGroup @bind-Value="context.AIModelType">
|
||||
@if (context.AIType == AIType.StableDiffusion)
|
||||
<RadioGroup @bind-Value="context.AIModelType" ButtonStyle="RadioButtonStyle.Solid" OnChange="AIModelTypeChange" TValue="AIModelType">
|
||||
<Radio RadioButton Value="@(AIModelType.Chat)">会话模型</Radio>
|
||||
<Radio RadioButton Value="@(AIModelType.Embedding)">向量模型</Radio>
|
||||
<Radio RadioButton Value="@(AIModelType.Rerank)">Rerank重排模型</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="AI类型" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<RadioGroup @bind-Value="context.AIType" ButtonStyle="RadioButtonStyle.Solid" OnChange="AITypeChange" TValue="AIType">
|
||||
@if (context.AIModelType == AIModelType.Chat)
|
||||
{
|
||||
<Radio RadioButton Value="@(AIModelType.Image)">图片模型</Radio>
|
||||
<Radio RadioButton Value="@(AIType.OpenAI)">OpenAI</Radio>
|
||||
<Radio RadioButton Value="@(AIType.AzureOpenAI)">AzureOpenAI</Radio>
|
||||
<Radio RadioButton Value="@(AIType.SparkDesk)">星火大模型</Radio>
|
||||
<Radio RadioButton Value="@(AIType.DashScope)">灵积大模型</Radio>
|
||||
<Radio RadioButton Value="@(AIType.Ollama)">Ollama本地模型</Radio>
|
||||
<Radio RadioButton Value="@(AIType.LLamaFactory)">LLamaFactory本地模型</Radio>
|
||||
<Radio RadioButton Value="@(AIType.Mock)">模拟输出</Radio>
|
||||
}
|
||||
else
|
||||
else if (context.AIModelType == AIModelType.Embedding)
|
||||
{
|
||||
@if (context.AIType != AIType.BgeEmbedding && context.AIType != AIType.BgeRerank)
|
||||
{
|
||||
<Radio RadioButton Value="@(AIModelType.Chat)">会话模型</Radio>
|
||||
}
|
||||
@if (context.AIType != AIType.LLamaFactory && context.AIType != AIType.Mock && context.AIType != AIType.SparkDesk && context.AIType != AIType.BgeRerank)
|
||||
{
|
||||
<Radio RadioButton Value="@(AIModelType.Embedding)">向量模型</Radio>
|
||||
}
|
||||
@if (context.AIType == AIType.BgeRerank)
|
||||
{
|
||||
<Radio RadioButton Value="@(AIModelType.Rerank)">Rerank重排模型</Radio>
|
||||
}
|
||||
<Radio RadioButton Value="@(AIType.BgeEmbedding)">BgeEmbedding</Radio>
|
||||
<Radio RadioButton Value="@(AIType.OpenAI)">OpenAI</Radio>
|
||||
<Radio RadioButton Value="@(AIType.AzureOpenAI)">AzureOpenAI</Radio>
|
||||
<Radio RadioButton Value="@(AIType.OllamaEmbedding)">Ollama本地模型</Radio>
|
||||
}
|
||||
else if (context.AIModelType == AIModelType.Rerank)
|
||||
{
|
||||
<Radio RadioButton Value="@(AIType.BgeRerank)">BgeRerank</Radio>
|
||||
}
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
|
||||
@if (context.AIModelType == AIModelType.Embedding)
|
||||
{
|
||||
<FormItem Label="注意事项" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<span style="color:red"><b>请不要使用不同维度的向量模型,否则会导致无法向量存储</b></span>
|
||||
</FormItem>
|
||||
}
|
||||
|
||||
@if (context.AIType == AIType.AzureOpenAI)
|
||||
{
|
||||
<FormItem Label="请求地址" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入请求地址" @bind-Value="@context.EndPoint" />
|
||||
<Input Placeholder="请输入请求地址" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="部署名(模型名)" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入部署名" @bind-Value="@context.ModelName" />
|
||||
<Input Placeholder="请输入部署名" @bind-Value="@context.ModelName" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="模型秘钥" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputPassword @bind-Value="@context.ModelKey" Placeholder="请输入模型秘钥" />
|
||||
<InputPassword @bind-Value="@context.ModelKey" Placeholder="请输入模型秘钥" AutoComplete="false" />
|
||||
</FormItem>
|
||||
}
|
||||
@if (context.AIType == AIType.OpenAI)
|
||||
{
|
||||
<FormItem Label="代理API" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<a href="https://api.antsk.cn/" target="_blank">去创建</a>
|
||||
</FormItem>
|
||||
<FormItem Label="请求地址" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入请求地址 示例格式 http://ip:port/" @bind-Value="@context.EndPoint" />
|
||||
<Input Placeholder="请输入请求地址 示例格式 http://ip:port/" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="模型名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入模型名称" @bind-Value="@context.ModelName" />
|
||||
<Input Placeholder="请输入模型名称" @bind-Value="@context.ModelName" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="模型秘钥" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputPassword @bind-Value="@context.ModelKey" Placeholder="请输入模型秘钥" />
|
||||
<InputPassword @bind-Value="@context.ModelKey" Placeholder="请输入模型秘钥" AutoComplete="false" />
|
||||
</FormItem>
|
||||
}
|
||||
@if (context.AIType == AIType.SparkDesk)
|
||||
{
|
||||
<FormItem Label="模型版本" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<SimpleSelect DefaultValue="V3_5" @bind-Value="@context.ModelName">
|
||||
<SimpleSelect DefaultValue="Lite" @bind-Value="@context.ModelName">
|
||||
<SelectOptions>
|
||||
<SimpleSelectOption Value="V3_5" Label="V3_5"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V3" Label="V3"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V2" Label="V2" Disabled></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V1_5" Label="V1_5"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V3_5" Label="Max"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V3" Label="Pro"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V2" Label="V2"></SimpleSelectOption>
|
||||
<SimpleSelectOption Value="V1_5" Label="Lite"></SimpleSelectOption>
|
||||
</SelectOptions>
|
||||
</SimpleSelect>
|
||||
</FormItem>
|
||||
<FormItem Label="请输入模型APPID|APISecret|APIKey" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputPassword Placeholder="APPID|APISecret|APIKey" @bind-Value="@context.ModelKey" />
|
||||
<InputPassword Placeholder="APPID|APISecret|APIKey" @bind-Value="@context.ModelKey" AutoComplete="false" />
|
||||
</FormItem>
|
||||
|
||||
|
||||
}
|
||||
@if (context.AIType == AIType.DashScope)
|
||||
{
|
||||
<FormItem Label="API KEY" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入API KEY" @bind-Value="@context.ModelKey" />
|
||||
<Input Placeholder="请输入API KEY" @bind-Value="@context.ModelKey" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="模型名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="请输入模型名称" @bind-Value="@context.ModelName" />
|
||||
</FormItem>
|
||||
}
|
||||
@if (context.AIType == AIType.LLamaSharp || context.AIType == AIType.StableDiffusion)
|
||||
{
|
||||
<FormItem Label="模型路径" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputGroup>
|
||||
<AutoComplete Options="_modelFiles" Placeholder="请输入模型路径" @bind-Value="@context.ModelName" />
|
||||
<Button OnClick="()=>_downloadModalVisible=true">从Haggingface下载</Button>
|
||||
</InputGroup>
|
||||
<Input Placeholder="请输入模型名称" @bind-Value="@context.ModelName" AutoComplete="false" />
|
||||
</FormItem>
|
||||
}
|
||||
@if (context.AIType == AIType.LLamaFactory)
|
||||
@@ -136,10 +131,14 @@
|
||||
</InputGroup>
|
||||
</FormItem>
|
||||
<FormItem Label="请求地址" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="http://localhost:8080/" @bind-Value="@context.EndPoint" />
|
||||
<Input Placeholder="http://localhost:8080/" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="环境安装" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Button Type="primary" OnClick="PipInstall">环境安装</Button>
|
||||
<FormItem Label="基础环境安装" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Button Type="primary" OnClick="PipInstall">开始安装</Button>
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="缺失依赖包安装" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Button Type="primary" OnClick="PipInstallShow">pip install</Button>
|
||||
</FormItem>
|
||||
<FormItem Label="llama factory服务" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputGroup>
|
||||
@@ -154,7 +153,70 @@
|
||||
</InputGroup>
|
||||
</FormItem>
|
||||
}
|
||||
|
||||
@if (context.AIType == AIType.Ollama)
|
||||
{
|
||||
<FormItem Label="模型名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputGroup>
|
||||
<Select TItem="string"
|
||||
TItemValue="string"
|
||||
DataSource="@ollamaModelList"
|
||||
@bind-Value="@context.ModelName"
|
||||
ValueProperty="c=>c"
|
||||
LabelProperty="c=>c"
|
||||
Placeholder="选择模型"
|
||||
DefaultActiveFirstOption="false"
|
||||
EnableSearch
|
||||
OnSearch="OnOllamaSearch">
|
||||
</Select>
|
||||
</InputGroup>
|
||||
<a href="https://ollama.com/library" target="_blank">获取更多模型</a>
|
||||
<br/>
|
||||
<span>可以在OllamaModelList.txt中进行修改</span>
|
||||
</FormItem>
|
||||
<FormItem Label="请求地址" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="http://localhost:11434/" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="环境安装" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<a href="https://ollama.com/download" target="_blank">下载Ollama</a>
|
||||
</FormItem>
|
||||
<FormItem Label="Ollama服务" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputGroup>
|
||||
<Button Type="primary" OnClick="StartOllamaService">下载模型</Button>
|
||||
</InputGroup>
|
||||
</FormItem>
|
||||
}
|
||||
@if (context.AIType == AIType.OllamaEmbedding)
|
||||
{
|
||||
<FormItem Label="模型名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputGroup>
|
||||
<Select TItem="string"
|
||||
TItemValue="string"
|
||||
DataSource="@ollamaEmbeddingModelList"
|
||||
@bind-Value="@context.ModelName"
|
||||
ValueProperty="c=>c"
|
||||
LabelProperty="c=>c"
|
||||
Placeholder="选择模型"
|
||||
DefaultActiveFirstOption="false"
|
||||
EnableSearch
|
||||
OnSearch="OnOllamaEmbeddingSearch">
|
||||
</Select>
|
||||
</InputGroup>
|
||||
<a href="https://ollama.com/library" target="_blank">获取更多模型</a>
|
||||
<br />
|
||||
<span>可以在OllamaEmbeddingModelList.txt中进行修改</span>
|
||||
</FormItem>
|
||||
<FormItem Label="请求地址" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Input Placeholder="http://localhost:11434/" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</FormItem>
|
||||
<FormItem Label="环境安装" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<a href="https://ollama.com/download" target="_blank">下载Ollama</a>
|
||||
</FormItem>
|
||||
<FormItem Label="Ollama服务" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<InputGroup>
|
||||
<Button Type="primary" OnClick="StartOllamaService">下载模型</Button>
|
||||
</InputGroup>
|
||||
</FormItem>
|
||||
}
|
||||
@if (context.AIType == AIType.BgeEmbedding)
|
||||
{
|
||||
<FormItem Label="模型名称" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
@@ -162,12 +224,11 @@
|
||||
@bind-Value="@context.ModelName"
|
||||
ValueProperty="c=>c"
|
||||
LabelProperty="c=>c">
|
||||
</Select>
|
||||
</Select>
|
||||
</FormItem>
|
||||
|
||||
<FormItem Label="Python路径" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Popover ContentTemplate="@_content" Title="提示" Style="width:100%">
|
||||
<Input Placeholder="D:\Programs\Python\Python311\python311.dll" @bind-Value="@context.EndPoint" />
|
||||
<Input Placeholder="D:\Programs\Python\Python311\python311.dll" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</Popover>
|
||||
</FormItem>
|
||||
|
||||
@@ -191,7 +252,7 @@
|
||||
</FormItem>
|
||||
<FormItem Label="Python路径" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
<Popover ContentTemplate="@_content" Title="提示" Style="width:100%">
|
||||
<Input Placeholder="D:\Programs\Python\Python311\python311.dll" @bind-Value="@context.EndPoint" />
|
||||
<Input Placeholder="D:\Programs\Python\Python311\python311.dll" @bind-Value="@context.EndPoint" AutoComplete="false" />
|
||||
</Popover>
|
||||
</FormItem>
|
||||
<FormItem Label="环境安装" LabelCol="LayoutModel._formItemLayout.LabelCol" WrapperCol="LayoutModel._formItemLayout.WrapperCol">
|
||||
@@ -225,7 +286,7 @@
|
||||
<Input Disabled="_downloadStarted" Placeholder="请输入下载地址" @bind-Value="_downloadUrl" Style="width:80%"></Input>
|
||||
@if (!_downloadStarted)
|
||||
{
|
||||
<Button OnClick="StartDownload">开始</Button>
|
||||
<Button OnClick="StartDownload" Style="margin-left:10px;" Type="@ButtonType.Primary">开始</Button>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -237,8 +298,19 @@
|
||||
</Flex>
|
||||
</Modal>
|
||||
|
||||
<Modal @ref="_modal" Visible="_pipModalVisible" Footer="null" Closable Title="pip install" OnCancel="OnCancelPipInstall" DestroyOnClose>
|
||||
<Flex Gap="10" Vertical>
|
||||
<InputGroup>
|
||||
<Input Placeholder="请输入包名(例如 pip install torch 则只需要输入 torch)" @bind-Value="_pipName" Style="border-radius: 8px"></Input>
|
||||
</InputGroup>
|
||||
<InputGroup>
|
||||
<Button OnClick="PipInstallName" Type="@ButtonType.Primary">pip install</Button>
|
||||
</InputGroup>
|
||||
</Flex>
|
||||
</Modal>
|
||||
|
||||
<Modal Visible="_logModalVisible" Footer="null" Closable Title="日志输出" OnCancel="OnCancelLog" DestroyOnClose Width="1000">
|
||||
<BlazorTerminal @ref="blazorTerminal" Style="height:600px;"></BlazorTerminal>
|
||||
<BlazorTerminal @ref="blazorTerminal" Style="height:600px;overflow-y: auto;"></BlazorTerminal>
|
||||
</Modal>
|
||||
|
||||
|
||||
|
||||
@@ -4,17 +4,16 @@ using AntSK.Domain.Domain.Interface;
|
||||
using AntSK.Domain.Domain.Model.Constant;
|
||||
using AntSK.Domain.Domain.Model.Enum;
|
||||
using AntSK.Domain.Domain.Other.Bge;
|
||||
using AntSK.Domain.Domain.Service;
|
||||
using AntSK.Domain.Options;
|
||||
using AntSK.Domain.Repositories;
|
||||
using AntSK.Domain.Utils;
|
||||
using AntSK.LLamaFactory.Model;
|
||||
using BlazorComponents.Terminal;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Downloader;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NRedisStack.Search;
|
||||
using Serilog;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AntSK.Pages.Setting.AIModel
|
||||
{
|
||||
@@ -22,13 +21,12 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
{
|
||||
[Parameter]
|
||||
public string ModelId { get; set; }
|
||||
[Parameter]
|
||||
public string ModelPath { get; set; }
|
||||
[Inject] protected IAIModels_Repositories _aimodels_Repositories { get; set; }
|
||||
[Inject] protected MessageService? Message { get; set; }
|
||||
[Inject] public HttpClient HttpClient { get; set; }
|
||||
|
||||
[Inject] protected ILLamaFactoryService _ILLamaFactoryService { get; set; }
|
||||
[Inject] protected IOllamaService _ollamaService { get; set; }
|
||||
[Inject] protected IDics_Repositories _IDics_Repositories { get; set; }
|
||||
|
||||
[Inject] IConfirmService _confirmService { get; set; }
|
||||
@@ -44,6 +42,9 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
private bool _downloadStarted;
|
||||
private IDownload _download;
|
||||
|
||||
private bool _pipModalVisible;
|
||||
private string _pipName;
|
||||
|
||||
private Modal _modal;
|
||||
private string[] _modelFiles;
|
||||
|
||||
@@ -52,16 +53,19 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
private List<MenuDataItem> menuList = new List<MenuDataItem>();
|
||||
|
||||
//llamafactory
|
||||
private List<LLamaModel> modelList=new List<LLamaModel>();
|
||||
private List<LLamaModel> modelList = new List<LLamaModel>();
|
||||
private bool llamaFactoryIsStart = false;
|
||||
private Dics llamaFactoryDic= new Dics();
|
||||
private Dics llamaFactoryDic = new Dics();
|
||||
//ollama
|
||||
private List<string> ollamaModelList = new List<string>();
|
||||
private List<string> ollamaEmbeddingModelList = new List<string>();
|
||||
//日志输出
|
||||
private BlazorTerminal blazorTerminal = new BlazorTerminal();
|
||||
private BlazorTerminal blazorTerminal = new BlazorTerminal();
|
||||
private TerminalParagraph para;
|
||||
private bool _logModalVisible;
|
||||
|
||||
private List<string> bgeEmbeddingList = new List<string>() { "AI-ModelScope/bge-small-zh-v1.5", "AI-ModelScope/bge-base-zh-v1.5", "AI-ModelScope/bge-large-zh-v1.5" };
|
||||
private List<string> bgeRerankList = new List<string>() { "Xorbits/bge-reranker-base", "Xorbits/bge-reranker-large", "AI-ModelScope/bge-reranker-v2-m3", "AI-ModelScope/bge-reranker-v2-gemma"};
|
||||
private List<string> bgeRerankList = new List<string>() { "Xorbits/bge-reranker-base", "Xorbits/bge-reranker-large", "AI-ModelScope/bge-reranker-v2-m3", "AI-ModelScope/bge-reranker-v2-gemma", "BAAI/bge-reranker-v2-minicpm-layerwise" };
|
||||
private bool BgeEmbeddingIsStart = false;
|
||||
private string BgeEmbeddingBtnText = "初始化";
|
||||
|
||||
@@ -80,47 +84,27 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
}
|
||||
|
||||
modelList = _ILLamaFactoryService.GetLLamaFactoryModels();
|
||||
ollamaModelList = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "OllamaModelList.txt")).ToList();
|
||||
ollamaEmbeddingModelList = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "OllamaEmbeddingModelList.txt")).ToList();
|
||||
|
||||
llamaFactoryDic = await _IDics_Repositories.GetFirstAsync(p => p.Type == LLamaFactoryConstantcs.LLamaFactorDic && p.Key == LLamaFactoryConstantcs.IsStartKey);
|
||||
if (llamaFactoryDic != null)
|
||||
{
|
||||
llamaFactoryIsStart = llamaFactoryDic.Value == "false" ? false : true;
|
||||
}
|
||||
|
||||
|
||||
//目前只支持gguf的 所以筛选一下
|
||||
_modelFiles = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), FileDirOption.DirectoryPath)).Where(p=> p.Contains(".gguf")||p.Contains(".ckpt")|| p.Contains(".safetensors")).ToArray();
|
||||
if (!string.IsNullOrEmpty(ModelPath))
|
||||
{
|
||||
string extension = Path.GetExtension(ModelPath);
|
||||
switch (extension)
|
||||
{
|
||||
case ".gguf":
|
||||
_aiModel.AIType = AIType.LLamaSharp;
|
||||
break;
|
||||
case ".safetensors":
|
||||
case ".ckpt":
|
||||
_aiModel.AIType = AIType.StableDiffusion;
|
||||
break;
|
||||
|
||||
}
|
||||
//下载页跳入
|
||||
|
||||
_downloadModalVisible = true;
|
||||
|
||||
_downloadUrl = $"https://hf-mirror.com{ModelPath.Replace("---","/")}";
|
||||
}
|
||||
}
|
||||
catch
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
_ = Message.Error("LLamaSharp.FileDirectory目录配置不正确!", 2);
|
||||
Log.Error(ex.Message + ex.StackTrace);
|
||||
_ = Message.Error($"{ex.Message + ex.StackTrace}", 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleSubmit()
|
||||
{
|
||||
if (_aimodels_Repositories.IsAny(p => p.Id!=_aiModel.Id.ConvertToString()&& p.AIModelType == _aiModel.AIModelType && p.EndPoint == _aiModel.EndPoint.ConvertToString() && p.ModelKey == _aiModel.ModelKey && p.ModelName == _aiModel.ModelName))
|
||||
if (_aiModel.ModelDescription.IsNull())
|
||||
{
|
||||
_ = Message.Error("模型已存在!", 2);
|
||||
_ = Message.Error("模型描述必须填写", 2);
|
||||
return;
|
||||
}
|
||||
if (_aiModel.AIType.IsNull())
|
||||
@@ -133,6 +117,12 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
_ = Message.Error("模型类型必须选择", 2);
|
||||
return;
|
||||
}
|
||||
if (_aimodels_Repositories.IsAny(p => p.Id != _aiModel.Id.ConvertToString() && p.AIModelType == _aiModel.AIModelType && p.EndPoint == _aiModel.EndPoint.ConvertToString() && p.ModelKey == _aiModel.ModelKey && p.ModelName == _aiModel.ModelName))
|
||||
{
|
||||
_ = Message.Error("模型已存在!", 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ModelId))
|
||||
{
|
||||
//新增
|
||||
@@ -185,7 +175,7 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
|
||||
private void DownloadProgressChanged(object? sender, DownloadProgressChangedEventArgs e)
|
||||
{
|
||||
_downloadProgress = Math.Round( e.ProgressPercentage,2);
|
||||
_downloadProgress = Math.Round(e.ProgressPercentage, 2);
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
@@ -217,7 +207,7 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
|
||||
private void StopDownload()
|
||||
{
|
||||
_downloadStarted=false;
|
||||
_downloadStarted = false;
|
||||
_download?.Stop();
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
@@ -225,8 +215,8 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
private void OnSearch(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
modelList = _ILLamaFactoryService.GetLLamaFactoryModels();
|
||||
{
|
||||
modelList = _ILLamaFactoryService.GetLLamaFactoryModels();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -234,7 +224,7 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 启动服务
|
||||
/// </summary>
|
||||
@@ -251,7 +241,7 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
_IDics_Repositories.Update(llamaFactoryDic);
|
||||
_ILLamaFactoryService.LogMessageReceived -= CmdLogHandler;
|
||||
_ILLamaFactoryService.LogMessageReceived += CmdLogHandler;
|
||||
_ILLamaFactoryService.StartLLamaFactory(_aiModel.ModelName, "default");
|
||||
_ILLamaFactoryService.StartLLamaFactory(_aiModel.ModelName);
|
||||
}
|
||||
|
||||
private void StopLFService()
|
||||
@@ -275,6 +265,79 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
}
|
||||
}
|
||||
|
||||
private async Task PipInstallShow()
|
||||
{
|
||||
_pipModalVisible = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
private void OnOllamaSearch(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
ollamaModelList = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "OllamaModelList.txt")).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ollamaModelList = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "OllamaModelList.txt")).ToList().Where(p => p.ToLower().Contains(value.ToLower())).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Embedding 搜索
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
private void OnOllamaEmbeddingSearch(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
ollamaEmbeddingModelList = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "OllamaEmbeddingModelList.txt")).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
ollamaEmbeddingModelList = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "OllamaEmbeddingModelList.txt")).ToList().Where(p => p.ToLower().Contains(value.ToLower())).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Ollama
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task StartOllamaService()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_aiModel.ModelName))
|
||||
{
|
||||
_ = Message.Error("请先选择模型!", 2);
|
||||
return;
|
||||
}
|
||||
_logModalVisible = true;
|
||||
|
||||
_ollamaService.LogMessageReceived -= CmdLogHandler;
|
||||
_ollamaService.LogMessageReceived += CmdLogHandler;
|
||||
_ollamaService.OllamaPull(_aiModel.ModelName);
|
||||
}
|
||||
|
||||
private void OnCancelPipInstall()
|
||||
{
|
||||
_pipModalVisible = false;
|
||||
}
|
||||
|
||||
private async Task PipInstallName()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_pipName))
|
||||
{
|
||||
_pipModalVisible = false;
|
||||
_logModalVisible = true;
|
||||
_ILLamaFactoryService.LogMessageReceived -= CmdLogHandler;
|
||||
_ILLamaFactoryService.LogMessageReceived += CmdLogHandler;
|
||||
_ILLamaFactoryService.PipInstallName(_pipName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async Task BgeEmbedding()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_aiModel.ModelName))
|
||||
@@ -303,7 +366,7 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
_ = Message.Error(ex.Message, 2);
|
||||
BgeEmbeddingIsStart = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private async Task BgeRerank()
|
||||
@@ -343,42 +406,67 @@ namespace AntSK.Pages.Setting.AIModel
|
||||
await InvokeAsync(() =>
|
||||
{
|
||||
para = blazorTerminal.RespondText("");
|
||||
para.AddTextLine(message);
|
||||
para.AddTextLine(message);
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 停止服务
|
||||
/// </summary>
|
||||
|
||||
private void OnCancelLog() {
|
||||
|
||||
private void OnCancelLog()
|
||||
{
|
||||
_logModalVisible = false;
|
||||
}
|
||||
|
||||
private void AITypeChange(AIType aiType)
|
||||
private void AITypeChange(AIType aiType)
|
||||
{
|
||||
//切换时清空
|
||||
_aiModel.EndPoint = "";
|
||||
_aiModel.ModelKey = "";
|
||||
_aiModel.ModelName = "";
|
||||
switch (aiType)
|
||||
{
|
||||
case AIType.OpenAI:
|
||||
_aiModel.EndPoint = "https://api.antsk.cn/";
|
||||
break;
|
||||
case AIType.LLamaFactory:
|
||||
_aiModel.EndPoint = "http://localhost:8000/";
|
||||
_aiModel.AIModelType=AIModelType.Chat;
|
||||
_aiModel.AIModelType = AIModelType.Chat;
|
||||
break;
|
||||
case AIType.StableDiffusion:
|
||||
_aiModel.AIModelType = AIModelType.Image;
|
||||
case AIType.Ollama:
|
||||
_aiModel.EndPoint = "http://localhost:11434/";
|
||||
_aiModel.AIModelType = AIModelType.Chat;
|
||||
break;
|
||||
case AIType.OllamaEmbedding:
|
||||
_aiModel.EndPoint = "http://localhost:11434/";
|
||||
_aiModel.AIModelType = AIModelType.Embedding;
|
||||
break;
|
||||
case AIType.Mock:
|
||||
_aiModel.AIModelType = AIModelType.Chat;
|
||||
break ;
|
||||
break;
|
||||
case AIType.BgeEmbedding:
|
||||
_aiModel.AIModelType = AIModelType.Embedding;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
_aiModel.EndPoint = "/opt/conda/pkgs/python-3.10.13-h955ad1f_0/lib/libpython3.10.so";
|
||||
}
|
||||
break;
|
||||
case AIType.BgeRerank:
|
||||
_aiModel.AIModelType = AIModelType.Rerank;
|
||||
|
||||
break;
|
||||
default:
|
||||
_aiModel.AIModelType = AIModelType.Chat;
|
||||
}
|
||||
}
|
||||
|
||||
private void AIModelTypeChange(AIModelType aIModelType)
|
||||
{
|
||||
switch (aIModelType)
|
||||
{
|
||||
case AIModelType.Chat:
|
||||
_aiModel.AIType = AIType.OpenAI;
|
||||
break;
|
||||
case AIModelType.Embedding:
|
||||
_aiModel.AIType = AIType.BgeEmbedding;
|
||||
break;
|
||||
case AIModelType.Rerank:
|
||||
_aiModel.AIType = AIType.BgeRerank;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
@namespace AntSK.Pages.Setting.AIModel
|
||||
@page "/modelmanager/modeldown"
|
||||
@using AntSK.Services.Auth
|
||||
@inherits AuthComponentBase
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using AntSK.Domain.Domain.Model.hfmirror
|
||||
@attribute [Authorize(Roles = "AntSKAdmin")]
|
||||
|
||||
<div>
|
||||
<PageContainer Title="模型列表">
|
||||
<Content>
|
||||
<RadioGroup @bind-Value="@_modelType" OnChange="OnModelTypeChange" TValue="string">
|
||||
<Radio Value="@("gguf")" DefaultChecked=true>LLama本地模型(gguf)</Radio>
|
||||
<Radio Value="@("safetensors")">StableDiffusion(safetensors)</Radio>
|
||||
<Radio Value="@("ckpt")">StableDiffusion2(ckpt)</Radio>
|
||||
</RadioGroup>
|
||||
<div style="text-align: center;">
|
||||
|
||||
<Search Placeholder="输入回车"
|
||||
EnterButton="@("搜索")"
|
||||
Size="large"
|
||||
Style="max-width: 522px; width: 100%;"
|
||||
OnSearch="Search" />
|
||||
|
||||
</div>
|
||||
</Content>
|
||||
<ChildContent>
|
||||
<div class="filterCardList">
|
||||
<Spin Tip="加载中..." Spinning="@(loaddding)">
|
||||
<AntList TItem="HfModels"
|
||||
Grid="LayoutModel._listGridType"
|
||||
DataSource="_modelList">
|
||||
<ListItem NoFlex>
|
||||
<Card Hoverable
|
||||
BodyStyle="padding-bottom: 20px;"
|
||||
Actions="new[] {
|
||||
down(()=> Down(context.Id))
|
||||
}">
|
||||
<CardMeta>
|
||||
<TitleTemplate>
|
||||
@context.Id
|
||||
</TitleTemplate>
|
||||
<AvatarTemplate>
|
||||
<Avatar Size="small" Src="@context.AuthorData.AvatarUrl" />
|
||||
</AvatarTemplate>
|
||||
</CardMeta>
|
||||
<div class="cardItemContent">
|
||||
<div class="cardInfo">
|
||||
<div>
|
||||
<p>Downloads</p>
|
||||
<p>@context.Downloads.ToString("0,0")</p>
|
||||
</div>
|
||||
<div>
|
||||
<p>Likes</p>
|
||||
<p>@context.Likes.ToString("0,0")</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</ListItem>
|
||||
</AntList>
|
||||
</Spin>
|
||||
</div>
|
||||
</ChildContent>
|
||||
</PageContainer>
|
||||
</div>
|
||||
@code
|
||||
{
|
||||
RenderFragment down(Action clickAction) =>@<a key="down" @onclick="@clickAction">下载</a>;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
using AntSK.Domain.Domain.Model.hfmirror;
|
||||
using AntSK.Domain.Utils;
|
||||
using AntSK.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
|
||||
namespace AntSK.Pages.Setting.AIModel
|
||||
{
|
||||
public partial class ModelDown
|
||||
{
|
||||
private readonly ListFormModel _model = new ListFormModel();
|
||||
private readonly IList<string> _selectCategories = new List<string>();
|
||||
|
||||
private List<HfModels> _modelList = new List<HfModels>();
|
||||
private string _modelType="gguf";
|
||||
private bool loaddding = false;
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
InitData("");
|
||||
}
|
||||
|
||||
private async Task InitData(string searchKey)
|
||||
{
|
||||
loaddding = true;
|
||||
if (_modelType.Contains("safetensors"))
|
||||
{
|
||||
_modelList.Clear();
|
||||
var param = searchKey.ConvertToString().Split(" ");
|
||||
string[] lines = File.ReadAllLines(Path.Combine(AppContext.BaseDirectory, "StableDiffusionModelList.txt"));
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string urlBase = $"https://hf-mirror.com/models-json?sort=trending&search={line}";
|
||||
if (param.Count() > 0)
|
||||
{
|
||||
urlBase += "+" + string.Join("+", param);
|
||||
}
|
||||
RestClient client = new RestClient();
|
||||
RestRequest request = new RestRequest(urlBase, Method.Get);
|
||||
var response =await client.ExecuteAsync(request);
|
||||
var model = JsonConvert.DeserializeObject<HfModel>(response.Content);
|
||||
_modelList.AddRange(model.models);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var param = searchKey.ConvertToString().Split(" ");
|
||||
|
||||
string urlBase = $"https://hf-mirror.com/models-json?sort=trending&search={_modelType}";
|
||||
if (param.Count() > 0)
|
||||
{
|
||||
urlBase += "+" + string.Join("+", param);
|
||||
}
|
||||
RestClient client = new RestClient();
|
||||
RestRequest request = new RestRequest(urlBase, Method.Get);
|
||||
var response = await client.ExecuteAsync(request);
|
||||
var model = JsonConvert.DeserializeObject<HfModel>(response.Content);
|
||||
_modelList = model.models;
|
||||
}
|
||||
|
||||
loaddding = false;
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task Search(string searchKey)
|
||||
{
|
||||
InitData(searchKey);
|
||||
}
|
||||
|
||||
private void Down(string modelPath)
|
||||
{
|
||||
NavigationManager.NavigateTo($"/modelmanager/modeldown/detail/{modelPath}");
|
||||
}
|
||||
|
||||
private void OnModelTypeChange(string value)
|
||||
{
|
||||
InitData("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
|
||||
/* stylelint-disable no-duplicate-selectors */
|
||||
/* stylelint-disable */
|
||||
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
|
||||
.filterCardList .ant-card-meta-content {
|
||||
margin-top: 0;
|
||||
}
|
||||
.filterCardList .ant-card-meta-avatar {
|
||||
font-size: 0;
|
||||
}
|
||||
.filterCardList .ant-list .ant-list-item-content-single {
|
||||
max-width: 100%;
|
||||
}
|
||||
.filterCardList .cardInfo {
|
||||
margin-top: 16px;
|
||||
margin-left: 40px;
|
||||
zoom: 1;
|
||||
}
|
||||
.filterCardList .cardInfo::before,
|
||||
.filterCardList .cardInfo::after {
|
||||
display: table;
|
||||
content: ' ';
|
||||
}
|
||||
.filterCardList .cardInfo::after {
|
||||
clear: both;
|
||||
height: 0;
|
||||
font-size: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
.filterCardList .cardInfo > div {
|
||||
position: relative;
|
||||
float: left;
|
||||
width: 50%;
|
||||
text-align: left;
|
||||
}
|
||||
.filterCardList .cardInfo > div p {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
}
|
||||
.filterCardList .cardInfo > div p:first-child {
|
||||
margin-bottom: 4px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
@namespace AntSK.Pages.Setting.AIModel
|
||||
@page "/modelmanager/modeldown/detail/{ModelName}/{ModelPath}"
|
||||
@using AntSK.Services.Auth
|
||||
@inherits AuthComponentBase
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using AntSK.Domain.Domain.Model.hfmirror;
|
||||
using AntSK.Domain.Domain.Model.hfmirror
|
||||
@attribute [Authorize(Roles = "AntSKAdmin")]
|
||||
|
||||
|
||||
<div>
|
||||
<PageContainer Title="模型下载">
|
||||
<ChildContent>
|
||||
<div class="standardList">
|
||||
<Card Class="listCard"
|
||||
Title="模型列表"
|
||||
Style="margin-top: 24px;"
|
||||
BodyStyle="padding: 0 32px 40px 32px">
|
||||
<Extra>
|
||||
|
||||
</Extra>
|
||||
<ChildContent>
|
||||
<AntList TItem="HfModelDetail"
|
||||
DataSource="modelList"
|
||||
ItemLayout="ListItemLayout.Horizontal">
|
||||
<ListItem Actions="new[] {
|
||||
down(()=> Down(context.Path))
|
||||
}" Style="width:100%">
|
||||
<div class="listContent" style="width:100%">
|
||||
<div class="listContentItem" style="width:20%">
|
||||
<b>名称</b>
|
||||
<p>@context.Name</p>
|
||||
</div>
|
||||
<div class="listContentItem" style="width:20%">
|
||||
<b>文件大小</b>
|
||||
<p>@context.Size</p>
|
||||
</div>
|
||||
<div class="listContentItem" style="width:20%">
|
||||
<b>更新时间</b>
|
||||
<p>@context.Time</p>
|
||||
</div>
|
||||
</div>
|
||||
</ListItem>
|
||||
</AntList>
|
||||
</ChildContent>
|
||||
</Card>
|
||||
</div>
|
||||
</ChildContent>
|
||||
</PageContainer>
|
||||
</div>
|
||||
|
||||
@code
|
||||
{
|
||||
RenderFragment down(Action clickAction) =>@<a key="down" @onclick="@clickAction">下载</a>;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using AntSK.Domain.Domain.Model.hfmirror;
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using HtmlAgilityPack;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using RestSharp;
|
||||
|
||||
namespace AntSK.Pages.Setting.AIModel
|
||||
{
|
||||
public partial class ModelDownDetail
|
||||
{
|
||||
[Parameter]
|
||||
public string ModelName { get; set; }
|
||||
[Parameter]
|
||||
public string ModelPath { get; set; }
|
||||
|
||||
List<HfModelDetail> modelList = new List<HfModelDetail>();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
InitData();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
string urlBase = $"https://hf-mirror.com/{ModelName}/{ModelPath}/tree/main";
|
||||
RestClient client = new RestClient();
|
||||
RestRequest request = new RestRequest(urlBase, Method.Get);
|
||||
var response = client.Execute(request);
|
||||
var htmlDocument = new HtmlDocument();
|
||||
htmlDocument.LoadHtml(response.Content);
|
||||
|
||||
foreach (var listItem in htmlDocument.DocumentNode.SelectNodes("//li[contains(@class,'grid')]"))
|
||||
{
|
||||
var modelNameNode = listItem.SelectSingleNode(".//span[contains(@class,'truncate')]");
|
||||
var fileSizeNode = listItem.SelectSingleNode(".//a[contains(@class,'text-[0.8rem]')]");
|
||||
var downloadNode = listItem.SelectSingleNode(".//a[@title='Download file']");
|
||||
var timeNode = listItem.SelectSingleNode(".//time");
|
||||
|
||||
var modelName = modelNameNode?.InnerText.Trim();
|
||||
var fileSizeInfo = fileSizeNode?.InnerText.Trim().Split(' ');
|
||||
var fileSize = fileSizeInfo?.Length > 1 ? fileSizeInfo[fileSizeInfo.Length - 2] : null;
|
||||
var downloadUrl = downloadNode?.GetAttributeValue("href", null)?.Trim();
|
||||
var time= timeNode?.InnerText.Trim();
|
||||
|
||||
modelList.Add(new HfModelDetail() { Name = modelName, Size = string.Join(" ",fileSizeInfo), Path = downloadUrl,Time=time });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Down(string path)
|
||||
{
|
||||
NavigationManager.NavigateTo($"/modelmanager/model/addbypath/{path.Replace("?download=true", "").Replace("/", "---")}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
/* stylelint-disable at-rule-empty-line-before,at-rule-name-space-after,at-rule-no-unknown */
|
||||
/* stylelint-disable no-duplicate-selectors */
|
||||
/* stylelint-disable */
|
||||
/* stylelint-disable declaration-bang-space-before,no-duplicate-selectors,string-no-newline */
|
||||
.standardList .ant-card-head {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.standardList .ant-card-head-title {
|
||||
padding: 24px 0;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.standardList .ant-card-extra {
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.standardList .ant-list-pagination {
|
||||
margin-top: 24px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.standardList .ant-avatar-lg {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
line-height: 48px;
|
||||
}
|
||||
|
||||
.standardList .headerInfo {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.standardList .headerInfo > span {
|
||||
display: inline-block;
|
||||
margin-bottom: 4px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
font-size: 14px;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.standardList .headerInfo > p {
|
||||
margin: 0;
|
||||
color: rgba(0, 0, 0, 0.85);
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.standardList .headerInfo > em {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 1px;
|
||||
height: 56px;
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.standardList .listContent {
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.standardList .listContent .listContentItem {
|
||||
display: inline-block;
|
||||
margin-left: 40px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
font-size: 14px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.standardList .listContent .listContentItem > span {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.standardList .listContent .listContentItem > p {
|
||||
margin-top: 4px;
|
||||
margin-bottom: 0;
|
||||
line-height: 22px;
|
||||
}
|
||||
|
||||
.standardList .extraContentSearch {
|
||||
width: 272px;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 480px) {
|
||||
.standardList .ant-list-item-content {
|
||||
display: block;
|
||||
flex: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.standardList .ant-list-item-action {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.standardList .listContent {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.standardList .listContent > div {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.standardList .listCard .ant-card-head-title {
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 576px) {
|
||||
.standardList .extraContentSearch {
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.standardList .headerInfo {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.standardList .headerInfo > em {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.standardList .listContent > div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.standardList .listContent > div:last-child {
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.listCard .ant-radio-group {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 992px) and (min-width: 768px) {
|
||||
.standardList .listContent > div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.standardList .listContent > div:last-child {
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1200px) {
|
||||
.standardList .listContent > div {
|
||||
margin-left: 24px;
|
||||
}
|
||||
|
||||
.standardList .listContent > div:last-child {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1400px) {
|
||||
.standardList .listContent {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.standardList .listContent > div:last-child {
|
||||
top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.standardListForm .ant-form-item {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.standardListForm .ant-form-item:last-child {
|
||||
margin-bottom: 32px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.formResult {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.formResult [class^='title'] {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
@@ -39,7 +39,11 @@
|
||||
delete(async ()=>await Delete(context.Id))
|
||||
}" Style="width:100%">
|
||||
<div class="listContent" style="width:100%">
|
||||
<div class="listContentItem" style="width:15%">
|
||||
<div class="listContentItem" style="width:20%">
|
||||
<b>模型ID</b>
|
||||
<p title="@context.Id">@context.Id</p>
|
||||
</div>
|
||||
<div class="listContentItem" style="width:5%">
|
||||
<b>模型描述</b>
|
||||
<p title="@context.ModelDescription">@context.ModelDescription</p>
|
||||
</div>
|
||||
@@ -54,10 +58,6 @@
|
||||
{
|
||||
<Tag Color="@PresetColor.Red.ToString()">AzureOpenAI</Tag>
|
||||
}
|
||||
else if (context.AIType == AIType.LLamaSharp)
|
||||
{
|
||||
<Tag Color="@PresetColor.Yellow.ToString()">LLamaSharp</Tag>
|
||||
}
|
||||
else if (context.AIType == AIType.SparkDesk)
|
||||
{
|
||||
<Tag Color="@PresetColor.Cyan.ToString()">SparkDesk</Tag>
|
||||
@@ -78,9 +78,9 @@
|
||||
{
|
||||
<Tag Color="@PresetColor.GeekBlue.ToString()">BgeRerank</Tag>
|
||||
}
|
||||
else if (context.AIType == AIType.StableDiffusion)
|
||||
{
|
||||
<Tag Color="@PresetColor.Magenta.ToString()">StableDiffusion</Tag>
|
||||
else if (context.AIType == AIType.Ollama || context.AIType == AIType.OllamaEmbedding)
|
||||
{
|
||||
<Tag Color="@PresetColor.Pink.ToString()">Ollama</Tag>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
@@ -97,21 +97,17 @@
|
||||
{
|
||||
<Tag Color="@PresetColor.Green.ToString()">向量模型</Tag>
|
||||
}
|
||||
else if (context.AIModelType == AIModelType.Image)
|
||||
{
|
||||
<Tag Color="@PresetColor.Lime.ToString()">图片模型</Tag>
|
||||
}
|
||||
else if (context.AIModelType == AIModelType.Rerank)
|
||||
{
|
||||
<Tag Color="@PresetColor.GeekBlue.ToString()">Rerank重排模型</Tag>
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
<div class="listContentItem" style="width:25%">
|
||||
<div class="listContentItem" style="width:20%">
|
||||
<b>模型地址</b>
|
||||
<p title="@context.EndPoint">@context.EndPoint</p>
|
||||
</div>
|
||||
<div class="listContentItem" style="width:15%">
|
||||
<div class="listContentItem" style="width:10%">
|
||||
<b>模型名称</b>
|
||||
<p title="@context.ModelName">@context.ModelName</p>
|
||||
</div>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>AntSK</title>
|
||||
<base href="~/" />
|
||||
<link href="_content/AntDesign/css/ant-design-blazor.css" rel="stylesheet" />
|
||||
<link href="_content/AntDesign.ProLayout/css/ant-design-pro-layout-blazor.css" rel="stylesheet" />
|
||||
<link href="./css/ant-design-blazor.css" rel="stylesheet" />
|
||||
<link href="./css/ant-design-pro-layout-blazor.css" rel="stylesheet" />
|
||||
<link href="./css/site.css" rel="stylesheet" />
|
||||
<link href="AntSK.styles.css" rel="stylesheet" />
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<component type="typeof(App)" render-mode="Server" />
|
||||
</app>
|
||||
|
||||
<script type="text/javascript" src="@("https://unpkg.com/@antv/g2plot@2.4.17/dist/g2plot.min.js")"></script>
|
||||
<script src="./js/g2plot.min.js"></script>
|
||||
<script src="_content/AntDesign/js/ant-design-blazor.js"></script>
|
||||
<script src="_content/AntDesign.Charts/ant-design-charts-blazor.js"></script>
|
||||
<script src="_framework/blazor.server.js"></script>
|
||||
|
||||
@@ -10,7 +10,6 @@ using AntSK.Domain.Utils;
|
||||
using AntSK.plugins.Functions;
|
||||
using AntSK.Services.Auth;
|
||||
using Blazored.LocalStorage;
|
||||
using LLama.Native;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -37,7 +36,6 @@ builder.AddServiceDefaults();
|
||||
|
||||
builder.Configuration.GetSection("DBConnection").Get<DBConnectionOption>();
|
||||
builder.Configuration.GetSection("Login").Get<LoginOption>();
|
||||
builder.Configuration.GetSection("LLamaSharp").Get<LLamaSharpOption>();
|
||||
builder.Configuration.GetSection("KernelMemory").Get<KernelMemoryOption>();
|
||||
builder.Configuration.GetSection("FileDir").Get<FileDirOption>();
|
||||
|
||||
@@ -79,27 +77,6 @@ builder.Services.AddBlazoredLocalStorage(config =>
|
||||
builder.Services.AddMapper();
|
||||
//后台队列任务
|
||||
builder.Services.AddBackgroundTaskBroker().AddHandler<ImportKMSTaskReq, BackGroundTaskHandler>("ImportKMSTask");
|
||||
// 读取连接字符串配置
|
||||
|
||||
if (LLamaSharpOption.RunType.ToUpper() == "CPU")
|
||||
{
|
||||
NativeLibraryConfig
|
||||
.All
|
||||
.WithCuda(false)
|
||||
.WithLogCallback((level, message) => {
|
||||
logger.LogInformation($"[llama {level}]: {message.TrimEnd('\n')}");
|
||||
});
|
||||
}
|
||||
else if (LLamaSharpOption.RunType.ToUpper() == "GPU")
|
||||
{
|
||||
NativeLibraryConfig
|
||||
.All
|
||||
.WithCuda(true)
|
||||
.WithLogCallback((level, message) => {
|
||||
logger.LogInformation($"[llama {level}]: {message.TrimEnd('\n')}");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//增加API允许跨域调用
|
||||
builder.Services.AddCors(options => options.AddPolicy("Any",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using AntSK.Domain.Common.DependencyInjection;
|
||||
using AntSK.Domain.Domain.Interface;
|
||||
using AntSK.Domain.Domain.Model.Dto.OpenAPI;
|
||||
using AntSK.Domain.Domain.Other.Bge;
|
||||
using AntSK.Domain.Repositories;
|
||||
using AntSK.Domain.Utils;
|
||||
using Microsoft.KernelMemory;
|
||||
@@ -17,6 +18,8 @@ namespace AntSK.Services.OpenApi
|
||||
public interface IOpenApiService
|
||||
{
|
||||
Task Chat(OpenAIModel model, string sk, HttpContext HttpContext);
|
||||
|
||||
Task<double> Rerank(RerankModel model, string sk, HttpContext HttpContext);
|
||||
}
|
||||
|
||||
[ServiceDescription(typeof(IOpenApiService), ServiceLifetime.Scoped)]
|
||||
@@ -24,7 +27,8 @@ namespace AntSK.Services.OpenApi
|
||||
IApps_Repositories _apps_Repositories,
|
||||
IKernelService _kernelService,
|
||||
IKMService _kMService,
|
||||
IChatService _chatService
|
||||
IChatService _chatService,
|
||||
IAIModels_Repositories _aIModels_Repositories
|
||||
) : IOpenApiService
|
||||
{
|
||||
public async Task Chat(OpenAIModel model, string sk, HttpContext HttpContext)
|
||||
@@ -95,7 +99,7 @@ namespace AntSK.Services.OpenApi
|
||||
|
||||
private async Task SendChatStream(HttpContext HttpContext, OpenAIStreamResult result, Apps app, ChatHistory history)
|
||||
{
|
||||
HttpContext.Response.Headers.Add("Content-Type", "text/event-stream");
|
||||
HttpContext.Response.Headers.Add("Content-Type", "text/event-stream;charset=utf-8");
|
||||
var chatResult = _chatService.SendChatByAppAsync(app, history);
|
||||
await foreach (var content in chatResult)
|
||||
{
|
||||
@@ -165,7 +169,7 @@ namespace AntSK.Services.OpenApi
|
||||
|
||||
private async Task SendKmsStream(HttpContext HttpContext, OpenAIStreamResult result, Apps app, string questions,ChatHistory history)
|
||||
{
|
||||
HttpContext.Response.Headers.Add("Content-Type", "text/event-stream");
|
||||
HttpContext.Response.Headers.Add("Content-Type", "text/event-stream;charset=utf-8");
|
||||
var chatResult = _chatService.SendKmsByAppAsync(app, questions, history, "");
|
||||
int i = 0;
|
||||
await foreach (var content in chatResult)
|
||||
@@ -252,5 +256,16 @@ namespace AntSK.Services.OpenApi
|
||||
}
|
||||
return (questions,history);
|
||||
}
|
||||
|
||||
public async Task<double> Rerank(RerankModel model, string sk, HttpContext HttpContext)
|
||||
{
|
||||
var rerankModel = _aIModels_Repositories.GetById(model.modelId);
|
||||
BegRerankConfig.LoadModel(rerankModel.EndPoint, rerankModel.ModelName);
|
||||
List<string> rerank = new List<string>();
|
||||
rerank.Add(model.query);
|
||||
rerank.Add(model.document);
|
||||
var result= BegRerankConfig.Rerank(rerank);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,11 +33,6 @@
|
||||
"ConnectionString": "Host=;Port=;Database=antsk;Username=;Password=",
|
||||
"TableNamePrefix": "km-"
|
||||
},
|
||||
"LLamaSharp": {
|
||||
"RunType": "GPU",
|
||||
"ContextSize": 2048,
|
||||
"GpuLayerCount": 20
|
||||
},
|
||||
"FileDir": {
|
||||
"DirectoryPath": "D:\\model"
|
||||
},
|
||||
|
||||
43
src/AntSK/wwwroot/assets/KDpgvguMpGfqaHPjicRK.svg
Normal file
43
src/AntSK/wwwroot/assets/KDpgvguMpGfqaHPjicRK.svg
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="200px" height="200px" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 47.1 (45422) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Group 28 Copy 5</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs>
|
||||
<linearGradient x1="62.1023273%" y1="0%" x2="108.19718%" y2="37.8635764%" id="linearGradient-1">
|
||||
<stop stop-color="#4285EB" offset="0%"></stop>
|
||||
<stop stop-color="#2EC7FF" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="69.644116%" y1="0%" x2="54.0428975%" y2="108.456714%" id="linearGradient-2">
|
||||
<stop stop-color="#29CDFF" offset="0%"></stop>
|
||||
<stop stop-color="#148EFF" offset="37.8600687%"></stop>
|
||||
<stop stop-color="#0A60FF" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="69.6908165%" y1="-12.9743587%" x2="16.7228981%" y2="117.391248%" id="linearGradient-3">
|
||||
<stop stop-color="#FA816E" offset="0%"></stop>
|
||||
<stop stop-color="#F74A5C" offset="41.472606%"></stop>
|
||||
<stop stop-color="#F51D2C" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<linearGradient x1="68.1279872%" y1="-35.6905737%" x2="30.4400914%" y2="114.942679%" id="linearGradient-4">
|
||||
<stop stop-color="#FA8E7D" offset="0%"></stop>
|
||||
<stop stop-color="#F74A5C" offset="51.2635191%"></stop>
|
||||
<stop stop-color="#F51D2C" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="logo" transform="translate(-20.000000, -20.000000)">
|
||||
<g id="Group-28-Copy-5" transform="translate(20.000000, 20.000000)">
|
||||
<g id="Group-27-Copy-3">
|
||||
<g id="Group-25" fill-rule="nonzero">
|
||||
<g id="2">
|
||||
<path d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C99.2571609,26.9692191 101.032305,26.9692191 102.20193,28.1378823 L129.985225,55.8983314 C134.193707,60.1033528 141.017005,60.1033528 145.225487,55.8983314 C149.433969,51.69331 149.433969,44.8756232 145.225487,40.6706018 L108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z" id="Shape" fill="url(#linearGradient-1)"></path>
|
||||
<path d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C100.999864,25.6271836 105.751642,20.541824 112.729652,19.3524487 C117.915585,18.4685261 123.585219,20.4140239 129.738554,25.1889424 C125.624663,21.0784292 118.571995,14.0340304 108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z" id="Shape" fill="url(#linearGradient-2)"></path>
|
||||
</g>
|
||||
<path d="M153.685633,135.854579 C157.894115,140.0596 164.717412,140.0596 168.925894,135.854579 L195.959977,108.842726 C200.659183,104.147384 200.659183,96.5636133 195.960527,91.8688194 L168.690777,64.7181159 C164.472332,60.5180858 157.646868,60.5241425 153.435895,64.7316526 C149.227413,68.936674 149.227413,75.7543607 153.435895,79.9593821 L171.854035,98.3623765 C173.02366,99.5310396 173.02366,101.304724 171.854035,102.473387 L153.685633,120.626849 C149.47715,124.83187 149.47715,131.649557 153.685633,135.854579 Z" id="Shape" fill="url(#linearGradient-3)"></path>
|
||||
</g>
|
||||
<ellipse id="Combined-Shape" fill="url(#linearGradient-4)" cx="100.519339" cy="100.436681" rx="23.6001926" ry="23.580786"></ellipse>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
69
src/AntSK/wwwroot/assets/TVYTbAXWheQpRcWDaDMu.svg
Normal file
69
src/AntSK/wwwroot/assets/TVYTbAXWheQpRcWDaDMu.svg
Normal file
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg width="1361px" height="609px" viewBox="0 0 1361 609" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Group 21</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="Ant-Design-Pro-3.0" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="账户密码登录-校验" transform="translate(-79.000000, -82.000000)">
|
||||
<g id="Group-21" transform="translate(77.000000, 73.000000)">
|
||||
<g id="Group-18" opacity="0.8" transform="translate(74.901416, 569.699158) rotate(-7.000000) translate(-74.901416, -569.699158) translate(4.901416, 525.199158)">
|
||||
<ellipse id="Oval-11" fill="#CFDAE6" opacity="0.25" cx="63.5748792" cy="32.468367" rx="21.7830479" ry="21.766008"></ellipse>
|
||||
<ellipse id="Oval-3" fill="#CFDAE6" opacity="0.599999964" cx="5.98746479" cy="13.8668601" rx="5.2173913" ry="5.21330997"></ellipse>
|
||||
<path d="M38.1354514,88.3520215 C43.8984227,88.3520215 48.570234,83.6838647 48.570234,77.9254015 C48.570234,72.1669383 43.8984227,67.4987816 38.1354514,67.4987816 C32.3724801,67.4987816 27.7006688,72.1669383 27.7006688,77.9254015 C27.7006688,83.6838647 32.3724801,88.3520215 38.1354514,88.3520215 Z" id="Oval-3-Copy" fill="#CFDAE6" opacity="0.45"></path>
|
||||
<path d="M64.2775582,33.1704963 L119.185836,16.5654915" id="Path-12" stroke="#CFDAE6" stroke-width="1.73913043" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M42.1431708,26.5002681 L7.71190162,14.5640702" id="Path-16" stroke="#E0B4B7" stroke-width="0.702678964" opacity="0.7" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="1.405357899873153,2.108036953469981"></path>
|
||||
<path d="M63.9262187,33.521561 L43.6721326,69.3250951" id="Path-15" stroke="#BACAD9" stroke-width="0.702678964" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="1.405357899873153,2.108036953469981"></path>
|
||||
<g id="Group-17" transform="translate(126.850922, 13.543654) rotate(30.000000) translate(-126.850922, -13.543654) translate(117.285705, 4.381889)" fill="#CFDAE6">
|
||||
<ellipse id="Oval-4" opacity="0.45" cx="9.13482653" cy="9.12768076" rx="9.13482653" ry="9.12768076"></ellipse>
|
||||
<path d="M18.2696531,18.2553615 C18.2696531,13.2142826 14.1798519,9.12768076 9.13482653,9.12768076 C4.08980114,9.12768076 0,13.2142826 0,18.2553615 L18.2696531,18.2553615 Z" id="Oval-4" transform="translate(9.134827, 13.691521) scale(-1, -1) translate(-9.134827, -13.691521) "></path>
|
||||
</g>
|
||||
</g>
|
||||
<g id="Group-14" transform="translate(216.294700, 123.725600) rotate(-5.000000) translate(-216.294700, -123.725600) translate(106.294700, 35.225600)">
|
||||
<ellipse id="Oval-2" fill="#CFDAE6" opacity="0.25" cx="29.1176471" cy="29.1402439" rx="29.1176471" ry="29.1402439"></ellipse>
|
||||
<ellipse id="Oval-2" fill="#CFDAE6" opacity="0.3" cx="29.1176471" cy="29.1402439" rx="21.5686275" ry="21.5853659"></ellipse>
|
||||
<ellipse id="Oval-2-Copy" stroke="#CFDAE6" opacity="0.4" cx="179.019608" cy="138.146341" rx="23.7254902" ry="23.7439024"></ellipse>
|
||||
<ellipse id="Oval-2" fill="#BACAD9" opacity="0.5" cx="29.1176471" cy="29.1402439" rx="10.7843137" ry="10.7926829"></ellipse>
|
||||
<path d="M29.1176471,39.9329268 L29.1176471,18.347561 C23.1616351,18.347561 18.3333333,23.1796097 18.3333333,29.1402439 C18.3333333,35.1008781 23.1616351,39.9329268 29.1176471,39.9329268 Z" id="Oval-2" fill="#BACAD9"></path>
|
||||
<g id="Group-9" opacity="0.45" transform="translate(172.000000, 131.000000)" fill="#E6A1A6">
|
||||
<ellipse id="Oval-2-Copy-2" cx="7.01960784" cy="7.14634146" rx="6.47058824" ry="6.47560976"></ellipse>
|
||||
<path d="M0.549019608,13.6219512 C4.12262681,13.6219512 7.01960784,10.722722 7.01960784,7.14634146 C7.01960784,3.56996095 4.12262681,0.670731707 0.549019608,0.670731707 L0.549019608,13.6219512 Z" id="Oval-2-Copy-2" transform="translate(3.784314, 7.146341) scale(-1, 1) translate(-3.784314, -7.146341) "></path>
|
||||
</g>
|
||||
<ellipse id="Oval-10" fill="#CFDAE6" cx="218.382353" cy="138.685976" rx="1.61764706" ry="1.61890244"></ellipse>
|
||||
<ellipse id="Oval-10-Copy-2" fill="#E0B4B7" opacity="0.35" cx="179.558824" cy="175.381098" rx="1.61764706" ry="1.61890244"></ellipse>
|
||||
<ellipse id="Oval-10-Copy" fill="#E0B4B7" opacity="0.35" cx="180.098039" cy="102.530488" rx="2.15686275" ry="2.15853659"></ellipse>
|
||||
<path d="M28.9985381,29.9671598 L171.151018,132.876024" id="Path-11" stroke="#CFDAE6" opacity="0.8"></path>
|
||||
</g>
|
||||
<g id="Group-10" opacity="0.799999952" transform="translate(1054.100635, 36.659317) rotate(-11.000000) translate(-1054.100635, -36.659317) translate(1026.600635, 4.659317)">
|
||||
<ellipse id="Oval-7" stroke="#CFDAE6" stroke-width="0.941176471" cx="43.8135593" cy="32" rx="11.1864407" ry="11.2941176"></ellipse>
|
||||
<g id="Group-12" transform="translate(34.596774, 23.111111)" fill="#BACAD9">
|
||||
<ellipse id="Oval-7" opacity="0.45" cx="9.18534718" cy="8.88888889" rx="8.47457627" ry="8.55614973"></ellipse>
|
||||
<path d="M9.18534718,17.4450386 C13.8657264,17.4450386 17.6599235,13.6143199 17.6599235,8.88888889 C17.6599235,4.16345787 13.8657264,0.332739156 9.18534718,0.332739156 L9.18534718,17.4450386 Z" id="Oval-7"></path>
|
||||
</g>
|
||||
<path d="M34.6597385,24.809694 L5.71666084,4.76878945" id="Path-2" stroke="#CFDAE6" stroke-width="0.941176471"></path>
|
||||
<ellipse id="Oval" stroke="#CFDAE6" stroke-width="0.941176471" cx="3.26271186" cy="3.29411765" rx="3.26271186" ry="3.29411765"></ellipse>
|
||||
<ellipse id="Oval-Copy" fill="#F7E1AD" cx="2.79661017" cy="61.1764706" rx="2.79661017" ry="2.82352941"></ellipse>
|
||||
<path d="M34.6312443,39.2922712 L5.06366663,59.785082" id="Path-10" stroke="#CFDAE6" stroke-width="0.941176471"></path>
|
||||
</g>
|
||||
<g id="Group-19" opacity="0.33" transform="translate(1282.537219, 446.502867) rotate(-10.000000) translate(-1282.537219, -446.502867) translate(1142.537219, 327.502867)">
|
||||
<g id="Group-17" transform="translate(141.333539, 104.502742) rotate(275.000000) translate(-141.333539, -104.502742) translate(129.333539, 92.502742)" fill="#BACAD9">
|
||||
<circle id="Oval-4" opacity="0.45" cx="11.6666667" cy="11.6666667" r="11.6666667"></circle>
|
||||
<path d="M23.3333333,23.3333333 C23.3333333,16.8900113 18.1099887,11.6666667 11.6666667,11.6666667 C5.22334459,11.6666667 0,16.8900113 0,23.3333333 L23.3333333,23.3333333 Z" id="Oval-4" transform="translate(11.666667, 17.500000) scale(-1, -1) translate(-11.666667, -17.500000) "></path>
|
||||
</g>
|
||||
<circle id="Oval-5-Copy-6" fill="#CFDAE6" cx="201.833333" cy="87.5" r="5.83333333"></circle>
|
||||
<path d="M143.5,88.8126685 L155.070501,17.6038544" id="Path-17" stroke="#BACAD9" stroke-width="1.16666667"></path>
|
||||
<path d="M17.5,37.3333333 L127.466252,97.6449735" id="Path-18" stroke="#BACAD9" stroke-width="1.16666667"></path>
|
||||
<polyline id="Path-19" stroke="#CFDAE6" stroke-width="1.16666667" points="143.902597 120.302281 174.935455 231.571342 38.5 147.510847 126.366941 110.833333"></polyline>
|
||||
<path d="M159.833333,99.7453842 L195.416667,89.25" id="Path-20" stroke="#E0B4B7" stroke-width="1.16666667" opacity="0.6"></path>
|
||||
<path d="M205.333333,82.1372105 L238.719406,36.1666667" id="Path-24" stroke="#BACAD9" stroke-width="1.16666667"></path>
|
||||
<path d="M266.723424,132.231988 L207.083333,90.4166667" id="Path-25" stroke="#CFDAE6" stroke-width="1.16666667"></path>
|
||||
<circle id="Oval-5" fill="#C1D1E0" cx="156.916667" cy="8.75" r="8.75"></circle>
|
||||
<circle id="Oval-5-Copy-3" fill="#C1D1E0" cx="39.0833333" cy="148.75" r="5.25"></circle>
|
||||
<circle id="Oval-5-Copy-2" fill-opacity="0.6" fill="#D1DEED" cx="8.75" cy="33.25" r="8.75"></circle>
|
||||
<circle id="Oval-5-Copy-4" fill-opacity="0.6" fill="#D1DEED" cx="243.833333" cy="30.3333333" r="5.83333333"></circle>
|
||||
<circle id="Oval-5-Copy-5" fill="#E0B4B7" cx="175.583333" cy="232.75" r="5.25"></circle>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.7 KiB |
16
src/AntSK/wwwroot/assets/method-draw-image.svg
Normal file
16
src/AntSK/wwwroot/assets/method-draw-image.svg
Normal file
@@ -0,0 +1,16 @@
|
||||
<svg width="500" height="480" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
<g>
|
||||
<title>background</title>
|
||||
<rect fill="none" id="canvas_background" height="482" width="502" y="-1" x="-1"/>
|
||||
</g>
|
||||
<g>
|
||||
<title>Layer 1</title>
|
||||
<g id="svg_1">
|
||||
<path id="svg_2" d="m495.300012,240.049988c0,-32.5 -40.7,-63.3 -103.1,-82.4c14.4,-63.6 8,-114.2 -20.2,-130.4c-6.5,-3.8 -14.1,-5.6 -22.4,-5.6l0,22.3c4.6,0 8.3,0.9 11.4,2.6c13.6,7.8 19.5,37.5 14.9,75.7c-1.1,9.4 -2.9,19.3 -5.1,29.4c-19.6,-4.8 -41,-8.5 -63.5,-10.9c-13.5,-18.5 -27.5,-35.3 -41.6,-50c32.6,-30.3 63.2,-46.9 84,-46.9l0,-22.3c0,0 0,0 0,0c-27.5,0 -63.5,19.6 -99.9,53.6c-36.4,-33.8 -72.4,-53.2 -99.9,-53.2l0,22.3c20.7,0 51.4,16.5 84,46.6c-14,14.7 -28,31.4 -41.3,49.9c-22.6,2.4 -44,6.1 -63.6,11c-2.3,-10 -4,-19.7 -5.2,-29c-4.7,-38.2 1.1,-67.9 14.6,-75.8c3,-1.8 6.9,-2.6 11.5,-2.6l0,-22.3c0,0 0,0 0,0c-8.4,0 -16,1.8 -22.6,5.6c-28.1,16.2 -34.4,66.7 -19.9,130.1c-62.2,19.2 -102.7,49.9 -102.7,82.3c0,32.5 40.7,63.3 103.1,82.4c-14.4,63.6 -8,114.2 20.2,130.4c6.5,3.8 14.1,5.6 22.5,5.6c27.5,0 63.5,-19.6 99.9,-53.6c36.4,33.8 72.4,53.2 99.9,53.2c8.4,0 16,-1.8 22.6,-5.6c28.1,-16.2 34.4,-66.7 19.9,-130.1c62,-19.1 102.5,-49.9 102.5,-82.3zm-130.2,-66.7c-3.7,12.9 -8.3,26.2 -13.5,39.5c-4.1,-8 -8.4,-16 -13.1,-24c-4.6,-8 -9.5,-15.8 -14.4,-23.4c14.2,2.1 27.9,4.7 41,7.9zm-45.8,106.5c-7.8,13.5 -15.8,26.3 -24.1,38.2c-14.9,1.3 -30,2 -45.2,2c-15.1,0 -30.2,-0.7 -45,-1.9c-8.3,-11.9 -16.4,-24.6 -24.2,-38c-7.6,-13.1 -14.5,-26.4 -20.8,-39.8c6.2,-13.4 13.2,-26.8 20.7,-39.9c7.8,-13.5 15.8,-26.3 24.1,-38.2c14.9,-1.3 30,-2 45.2,-2c15.1,0 30.2,0.7 45,1.9c8.3,11.9 16.4,24.6 24.2,38c7.6,13.1 14.5,26.4 20.8,39.8c-6.3,13.4 -13.2,26.8 -20.7,39.9zm32.3,-13c5.4,13.4 10,26.8 13.8,39.8c-13.1,3.2 -26.9,5.9 -41.2,8c4.9,-7.7 9.8,-15.6 14.4,-23.7c4.6,-8 8.9,-16.1 13,-24.1zm-101.4,106.7c-9.3,-9.6 -18.6,-20.3 -27.8,-32c9,0.4 18.2,0.7 27.5,0.7c9.4,0 18.7,-0.2 27.8,-0.7c-9,11.7 -18.3,22.4 -27.5,32zm-74.4,-58.9c-14.2,-2.1 -27.9,-4.7 -41,-7.9c3.7,-12.9 8.3,-26.2 13.5,-39.5c4.1,8 8.4,16 13.1,24c4.7,8 9.5,15.8 14.4,23.4zm73.9,-208.1c9.3,9.6 18.6,20.3 27.8,32c-9,-0.4 -18.2,-0.7 -27.5,-0.7c-9.4,0 -18.7,0.2 -27.8,0.7c9,-11.7 18.3,-22.4 27.5,-32zm-74,58.9c-4.9,7.7 -9.8,15.6 -14.4,23.7c-4.6,8 -8.9,16 -13,24c-5.4,-13.4 -10,-26.8 -13.8,-39.8c13.1,-3.1 26.9,-5.8 41.2,-7.9zm-90.5,125.2c-35.4,-15.1 -58.3,-34.9 -58.3,-50.6c0,-15.7 22.9,-35.6 58.3,-50.6c8.6,-3.7 18,-7 27.7,-10.1c5.7,19.6 13.2,40 22.5,60.9c-9.2,20.8 -16.6,41.1 -22.2,60.6c-9.9,-3.1 -19.3,-6.5 -28,-10.2zm53.8,142.9c-13.6,-7.8 -19.5,-37.5 -14.9,-75.7c1.1,-9.4 2.9,-19.3 5.1,-29.4c19.6,4.8 41,8.5 63.5,10.9c13.5,18.5 27.5,35.3 41.6,50c-32.6,30.3 -63.2,46.9 -84,46.9c-4.5,-0.1 -8.3,-1 -11.3,-2.7zm237.2,-76.2c4.7,38.2 -1.1,67.9 -14.6,75.8c-3,1.8 -6.9,2.6 -11.5,2.6c-20.7,0 -51.4,-16.5 -84,-46.6c14,-14.7 28,-31.4 41.3,-49.9c22.6,-2.4 44,-6.1 63.6,-11c2.3,10.1 4.1,19.8 5.2,29.1zm38.5,-66.7c-8.6,3.7 -18,7 -27.7,10.1c-5.7,-19.6 -13.2,-40 -22.5,-60.9c9.2,-20.8 16.6,-41.1 22.2,-60.6c9.9,3.1 19.3,6.5 28.1,10.2c35.4,15.1 58.3,34.9 58.3,50.6c-0.1,15.7 -23,35.6 -58.4,50.6z" fill="#61DAFB"/>
|
||||
<polygon id="svg_3" points="149.8000030517578,21.949989318847656 149.8000030517578,21.949989318847656 149.8000030517578,21.949989318847656 " fill="#61DAFB"/>
|
||||
<circle id="svg_4" r="45.700001" cy="240.049988" cx="249.900012" fill="#61DAFB"/>
|
||||
<polygon id="svg_5" points="349.5,21.649986267089844 349.5,21.649986267089844 349.5,21.649986267089844 " fill="#61DAFB"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
27136
src/AntSK/wwwroot/css/ant-design-blazor.css
Normal file
27136
src/AntSK/wwwroot/css/ant-design-blazor.css
Normal file
File diff suppressed because it is too large
Load Diff
1
src/AntSK/wwwroot/css/ant-design-pro-layout-blazor.css
Normal file
1
src/AntSK/wwwroot/css/ant-design-pro-layout-blazor.css
Normal file
File diff suppressed because one or more lines are too long
96
src/AntSK/wwwroot/css/diag.css
Normal file
96
src/AntSK/wwwroot/css/diag.css
Normal file
@@ -0,0 +1,96 @@
|
||||
.diagram-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: inherit;
|
||||
outline: 0;
|
||||
overflow: hidden;
|
||||
cursor: -webkit-grab;
|
||||
cursor: grab;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.diagram-svg-layer, .diagram-html-layer {
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.html-layer, .svg-layer {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.diagram-node {
|
||||
position: absolute;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
cursor: move;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.diagram-node.locked {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.diagram-link {
|
||||
pointer-events: visiblePainted;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.diagram-navigator {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.diagram-navigator .current-view {
|
||||
position: absolute;
|
||||
border: 2px solid #000;
|
||||
}
|
||||
|
||||
.diagram-group {
|
||||
position: absolute;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
cursor: move;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.diagram-group .children {
|
||||
position: absolute;
|
||||
overflow: visible;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.diagram-link foreignObject.diagram-link-label {
|
||||
overflow: visible;
|
||||
pointer-events: none;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
div.diagram-control {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.executable.diagram-control {
|
||||
pointer-events: all;
|
||||
cursor: pointer;
|
||||
}
|
||||
2
src/AntSK/wwwroot/css/prism-coy.min.css
vendored
2
src/AntSK/wwwroot/css/prism-coy.min.css
vendored
@@ -1 +1 @@
|
||||
code[class*=language-],pre[class*=language-]{color:#000;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{position:relative;margin:.5em 0;overflow:visible;padding:1px}pre[class*=language-]>code{position:relative;z-index:1;border-left:10px solid #358ccb;box-shadow:-1px 0 0 0 #358ccb,0 0 0 1px #dfdfdf;background-color:#fdfdfd;background-image:linear-gradient(transparent 50%,rgba(69,142,209,.04) 50%);background-size:3em 3em;background-origin:content-box;background-attachment:local}code[class*=language-]{max-height:inherit;height:inherit;padding:0 1em;display:block;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background-color:#fdfdfd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:1em}:not(pre)>code[class*=language-]{position:relative;padding:.2em;border-radius:.3em;color:#c92c2c;border:1px solid rgba(0,0,0,.1);display:inline;white-space:normal}pre[class*=language-]:after,pre[class*=language-]:before{content:'';display:block;position:absolute;bottom:.75em;left:.18em;width:40%;height:20%;max-height:13em;box-shadow:0 13px 8px #979797;-webkit-transform:rotate(-2deg);-moz-transform:rotate(-2deg);-ms-transform:rotate(-2deg);-o-transform:rotate(-2deg);transform:rotate(-2deg)}pre[class*=language-]:after{right:.75em;left:auto;-webkit-transform:rotate(2deg);-moz-transform:rotate(2deg);-ms-transform:rotate(2deg);-o-transform:rotate(2deg);transform:rotate(2deg)}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#7d8b99}.token.punctuation{color:#5f6364}.token.boolean,.token.constant,.token.deleted,.token.function-name,.token.number,.token.property,.token.symbol,.token.tag{color:#c92c2c}.token.attr-name,.token.builtin,.token.char,.token.function,.token.inserted,.token.selector,.token.string{color:#2f9c0a}.token.entity,.token.operator,.token.url,.token.variable{color:#a67f59;background:rgba(255,255,255,.5)}.token.atrule,.token.attr-value,.token.class-name,.token.keyword{color:#1990b8}.token.important,.token.regex{color:#e90}.language-css .token.string,.style .token.string{color:#a67f59;background:rgba(255,255,255,.5)}.token.important{font-weight:400}.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.namespace{opacity:.7}@media screen and (max-width:767px){pre[class*=language-]:after,pre[class*=language-]:before{bottom:14px;box-shadow:none}}pre[class*=language-].line-numbers.line-numbers{padding-left:0}pre[class*=language-].line-numbers.line-numbers code{padding-left:3.8em}pre[class*=language-].line-numbers.line-numbers .line-numbers-rows{left:0}pre[class*=language-][data-line]{padding-top:0;padding-bottom:0;padding-left:0}pre[data-line] code{position:relative;padding-left:4em}pre .line-highlight{margin-top:0}
|
||||
code[class*=language-],pre[class*=language-]{color:#000;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{position:relative;margin:.5em 0;overflow:visible;padding:1px}pre[class*=language-]>code{position:relative;z-index:1;border-left:10px solid #1890ff;box-shadow:-1px 0 0 0 #1890ff,0 0 0 1px #dfdfdf;background-color:#fdfdfd;background-image:linear-gradient(transparent 50%,rgba(69,142,209,.04) 50%);background-size:3em 3em;background-origin:content-box;background-attachment:local}code[class*=language-]{max-height:inherit;height:inherit;padding:0 1em;display:block;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background-color:#fdfdfd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:1em}:not(pre)>code[class*=language-]{position:relative;padding:.2em;border-radius:.3em;color:#c92c2c;border:1px solid rgba(0,0,0,.1);display:inline;white-space:normal}pre[class*=language-]:after,pre[class*=language-]:before{content:'';display:block;position:absolute;bottom:.75em;left:.18em;width:40%;height:20%;max-height:13em;box-shadow:0 13px 8px #979797;-webkit-transform:rotate(-2deg);-moz-transform:rotate(-2deg);-ms-transform:rotate(-2deg);-o-transform:rotate(-2deg);transform:rotate(-2deg)}pre[class*=language-]:after{right:.75em;left:auto;-webkit-transform:rotate(2deg);-moz-transform:rotate(2deg);-ms-transform:rotate(2deg);-o-transform:rotate(2deg);transform:rotate(2deg)}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#7d8b99}.token.punctuation{color:#5f6364}.token.boolean,.token.constant,.token.deleted,.token.function-name,.token.number,.token.property,.token.symbol,.token.tag{color:#c92c2c}.token.attr-name,.token.builtin,.token.char,.token.function,.token.inserted,.token.selector,.token.string{color:#2f9c0a}.token.entity,.token.operator,.token.url,.token.variable{color:#a67f59;background:rgba(255,255,255,.5)}.token.atrule,.token.attr-value,.token.class-name,.token.keyword{color:#1990b8}.token.important,.token.regex{color:#e90}.language-css .token.string,.style .token.string{color:#a67f59;background:rgba(255,255,255,.5)}.token.important{font-weight:400}.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.namespace{opacity:.7}@media screen and (max-width:767px){pre[class*=language-]:after,pre[class*=language-]:before{bottom:14px;box-shadow:none}}pre[class*=language-].line-numbers.line-numbers{padding-left:0}pre[class*=language-].line-numbers.line-numbers code{padding-left:3.8em}pre[class*=language-].line-numbers.line-numbers .line-numbers-rows{left:0}pre[class*=language-][data-line]{padding-top:0;padding-bottom:0;padding-left:0}pre[data-line] code{position:relative;padding-left:4em}pre .line-highlight{margin-top:0}
|
||||
@@ -53,3 +53,29 @@ ol {
|
||||
min-height: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 1px; /* <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD> */
|
||||
height: 8px; /* <20><><EFBFBD><EFBFBD>ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ߶<C4B8> */
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #f5f5f5; /* <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ɫ */
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1; /* <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>Ĵָ<C4B4>ı<EFBFBD><C4B1><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD><CFB6>IJ<EFBFBD><C4B2>֣<EFBFBD> */
|
||||
border-radius: 8px; /* <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>Ĵָ<C4B4><D6B8>Բ<EFBFBD><D4B2> */
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #555; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣʱ<CDA3><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵָ<C4B4>ı<EFBFBD><C4B1><EFBFBD>ɫ */
|
||||
}
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Firefox */
|
||||
* {
|
||||
scrollbar-width: thin; /* <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>Ϊϸ<CEAA><CFB8> */
|
||||
scrollbar-color: #ccc #f1f1f1; /* <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>Ĵָ<C4B4><EFBFBD><CDB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ */
|
||||
}
|
||||
70
src/AntSK/wwwroot/css/theme.default.css
Normal file
70
src/AntSK/wwwroot/css/theme.default.css
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
/*@font-face {
|
||||
font-family: 'IBM Plex Mono';
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url(https://fonts.gstatic.com/s/ibmplexmono/v19/-F6qfjptAgt5VM-kVkqdyU8n3twJwl1FgtIU.woff2) format('woff2');
|
||||
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
|
||||
}*/
|
||||
|
||||
/*@font-face {
|
||||
font-family: ibmplexmono;
|
||||
src: url(fonts/ibmplexmono.woff2);
|
||||
display: swap;
|
||||
}*/
|
||||
|
||||
@font-face {
|
||||
font-family: CascadiaCode;
|
||||
src: url(fonts/CascadiaCode.ttf);
|
||||
display: swap;
|
||||
}
|
||||
|
||||
|
||||
.bc-terminal-theme {
|
||||
font-family: CascadiaCode, monospace;
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
background-color: rgb(29, 42, 53);
|
||||
color: rgb(203, 213, 225);
|
||||
}
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph {
|
||||
}
|
||||
|
||||
.bc-terminal-theme .bc-terminal-input {
|
||||
color: rgb(203, 213, 225);
|
||||
caret-color: rgb(5, 206, 145);
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
/*line-height: 1.15;*/
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-command > .bc-prompt > .bc-prompt-name {
|
||||
color: rgb(255, 157, 0);
|
||||
}
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-command > .bc-prompt > .bc-prompt-spr1 {
|
||||
}
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-command > .bc-prompt > .bc-prompt-host {
|
||||
color: rgb(5, 206, 145);
|
||||
}
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-command > .bc-prompt > .bc-prompt-spr2 {
|
||||
}
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-command > .bc-prompt > .bc-prompt-path {
|
||||
}
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-command > .bc-prompt > .bc-prompt-pmt {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.bc-terminal-theme > .bc-paragraph-response > .bc-command-content {
|
||||
}
|
||||
@@ -45,11 +45,6 @@
|
||||
"path": "/modelmanager/modellist",
|
||||
"name": "模型管理",
|
||||
"key": "modelmanager.modellist"
|
||||
},
|
||||
{
|
||||
"path": "/modelmanager/modeldown",
|
||||
"name": "模型下载",
|
||||
"key": "modelmanager.modeldown"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -77,8 +72,8 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "https://antsk.cn/",
|
||||
"name": "使用文档",
|
||||
"path": "https://antsk.cn",
|
||||
"name": "官方文档",
|
||||
"key": "antskdoc",
|
||||
"icon": "question-circle"
|
||||
},
|
||||
@@ -94,4 +89,4 @@
|
||||
"key": "antskvideo",
|
||||
"icon": "video-camera"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user