Zongsoft.Intelligences
0.1.1
dotnet add package Zongsoft.Intelligences --version 0.1.1
NuGet\Install-Package Zongsoft.Intelligences -Version 0.1.1
<PackageReference Include="Zongsoft.Intelligences" Version="0.1.1" />
<PackageVersion Include="Zongsoft.Intelligences" Version="0.1.1" />
<PackageReference Include="Zongsoft.Intelligences" />
paket add Zongsoft.Intelligences --version 0.1.1
#r "nuget: Zongsoft.Intelligences, 0.1.1"
#:package Zongsoft.Intelligences@0.1.1
#addin nuget:?package=Zongsoft.Intelligences&version=0.1.1
#tool nuget:?package=Zongsoft.Intelligences&version=0.1.1
人工智能扩展库
安装 Ollama
在 Windows 11 中确保 WSL 2 和 Podman 安装成功。
确保 Podman 虚拟机已经启动,可通过下列命令进行查验:
podman machine list #查看虚拟机列表 podman machine info #查看虚拟机信息 podman machine start #启动默认虚拟机
💡 提示: Docker 与 Podman 的操作方式基本一致,只需将
podman
命令改成docker
即可。
在 Podman 中安装 Ollama
根据 Ollama 官方文档 《Ollama is now available as an official Docker image》 的指引,在 PowerShell 中执行下列命令安装 Ollama 镜像。
podman run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
等待下载安装完成后,通过下面命令进行查验 (此时镜像列表为空):
podman exec -it ollama ollama list
安装模型
在 Ollama 官方模型库 (https://ollama.com/search) 中查找需要的大语言模型。
💡 如果只是本地开发测试,推荐使用 阿里千问 (
qwen3:0.6b
) 模型,它只有523MB
大小,可在无显卡的低配电脑上流畅运行。
podman exec -it ollama ollama pull qwen3:0.6b
等待下载安装完成后,通过下面命令进行查验:
# 查看本地模型库列表 podman exec -it ollama ollama list # 运行 qwen3:0.6b 模型 # 运行成功后自动进入交互模式,可通过 `/bye` 命令退出 podman exec -it ollama ollama run qwen3:0.6b # 查看正在运行的模型列表 podman exec -it ollama ollama ps
运行调试
本扩展库提供了 命令行 和 RESTful API 接口两种方式。
命令行
- 执行 terminal 项目的
deploy.cmd
部署命令; - 启动编译后的 terminal 本地宿主程序;
如果 Ollama 没有安装在本机,则需要修改该插件的
Zongsoft.Intelligences.option
配置文件中的连接地址。
命令说明
查看AI助手列表
ai.assistant
激活指定的AI助手
注意:后续命令皆基于该命令设置的AI助手。
# 设置AI助手配置(注:该命令参数即为配置文件中的连接名) ai.assistant ollama
模型命令
# 查看本地模型库列表 ai.assistant.model.list # 查看正在运行的模型列表 ai.assistant.model.list -running # 查看指定的模型信息 ai.assistant.model.info "qwen3:0.6b" # 下载并安装指定的大语言模型 ai.assistant.model.install "qwen3:0.6b" # 删除并卸载指定的大语言模型 ai.assistant.model.uninstall "qwen3:0.6b"
会话命令
# 创建一个新的会话 ai.assistant.chat.open # 进入指定的会话 ai.assistant.chat.open 'session|chatroom' # 关闭当前会话 ai.assistant.chat.close # 关闭指定会话 ai.assistant.chat.close 'session|chatroom' # 清空当前会话的历史记录 ai.assistant.chat.clear # 清空指定会话的历史记录 ai.assistant.chat.clear 'session|chatroom' # 查看当前会话的历史纪录 ai.assistant.chat.history # 查看指定会话的历史记录 ai.assistant.chat.history 'session|chatroom'
聊天命令
# 对话 ai.assistant.chat "内容" # 对话:结果为纯文本 ai.assistant.chat -format:text "内容" # 对话:结果为异步流 ai.assistant.chat -streaming "内容" # 对话:结果为纯文本的异步流 ai.assistant.chat -streaming -format:text "内容" # 进入交互对话模式 ai.assistant.chat -interactive
RESTful API 接口
获取AI助手列表
GET /ai/assistants
获取指定AI助手信息
GET /ai/assistants/{name}
获取模型列表
GET /ai/assistants/{name}/models
获取模型详情
GET /ai/assistants/{name}/models/{id}
获取会话列表
GET /ai/assistants/{name}/chats
获取会话详情
GET /ai/assistants/{name}/chats/{id}
创建新的会话
POST /ai/assistants/{name}/chats
关闭一个会话
DELETE /ai/assistants/{name}/chats/{id}
获取指定会话的聊天历史记录
GET /ai/assistants/{name}/chats/{id}/history
清空指定会话的聊天历史记录
DELETE /ai/assistants/{name}/chats/{id}/history
聊天对话 (无会话历史)
POST /ai/assistants/{name}/chats/chat
聊天对话 (有会话历史)
POST /ai/assistants/{name}/chats/{id}/chat
完整信息请参考 api 项目中的
Zongsoft.Intelligences.Web.http
文档。
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.AI (>= 9.8.0)
- Microsoft.Extensions.AI.Abstractions (>= 9.8.0)
- Microsoft.Extensions.Configuration (>= 6.0.0)
- Microsoft.Extensions.VectorData.Abstractions (>= 9.7.0)
- Microsoft.SemanticKernel (>= 1.63.0)
- Microsoft.SemanticKernel.Abstractions (>= 1.63.0)
- Microsoft.SemanticKernel.Core (>= 1.63.0)
- OllamaSharp (>= 5.3.6)
- Zongsoft.Core (>= 7.17.0)
-
net7.0
- Microsoft.Extensions.AI (>= 9.8.0)
- Microsoft.Extensions.AI.Abstractions (>= 9.8.0)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.VectorData.Abstractions (>= 9.7.0)
- Microsoft.SemanticKernel (>= 1.63.0)
- Microsoft.SemanticKernel.Abstractions (>= 1.63.0)
- Microsoft.SemanticKernel.Core (>= 1.63.0)
- OllamaSharp (>= 5.3.6)
- Zongsoft.Core (>= 7.17.0)
-
net8.0
- Microsoft.Extensions.AI (>= 9.8.0)
- Microsoft.Extensions.AI.Abstractions (>= 9.8.0)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.VectorData.Abstractions (>= 9.7.0)
- Microsoft.SemanticKernel (>= 1.63.0)
- Microsoft.SemanticKernel.Abstractions (>= 1.63.0)
- Microsoft.SemanticKernel.Core (>= 1.63.0)
- OllamaSharp (>= 5.3.6)
- Zongsoft.Core (>= 7.17.0)
-
net9.0
- Microsoft.Extensions.AI (>= 9.8.0)
- Microsoft.Extensions.AI.Abstractions (>= 9.8.0)
- Microsoft.Extensions.Configuration (>= 9.0.2)
- Microsoft.Extensions.VectorData.Abstractions (>= 9.7.0)
- Microsoft.SemanticKernel (>= 1.63.0)
- Microsoft.SemanticKernel.Abstractions (>= 1.63.0)
- Microsoft.SemanticKernel.Core (>= 1.63.0)
- OllamaSharp (>= 5.3.6)
- Zongsoft.Core (>= 7.17.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Zongsoft.Intelligences:
Package | Downloads |
---|---|
Zongsoft.Intelligences.Web
This is a web class library about artificial intelligence development. |
GitHub repositories
This package is not used by any popular GitHub repositories.