前言
智谱 AI 大模型提供了多种模型的接口调用,并且其中glm-4-flash
还提供免费调用。
这里就简单体验一下
官方的体验入口
https://open.bigmodel.cn/console/trialcenter
接口
https://open.bigmodel.cn/dev/api/normal-model/glm-4
SDK
https://open.bigmodel.cn/dev/api/libraries
模型列表
https://open.bigmodel.cn/dev/howuse/model
免费服务
https://open.bigmodel.cn/dev/activities/freebie
.Net SDK
https://github.com/MetaGLM/zhipuai-sdk-csharp-v4.git
创建你的项目z_chat_ai
文件夹,并进入
1 | git clone https://github.com/MetaGLM/zhipuai-sdk-csharp-v4.git |
引用sdk
1 | cd ZChatAi |
调用示例
Program.cs
1 | using System.Text.Json; |
运行
1 | dotnet build |
流式调用
1 | using System.Text.Json; |
WPF
创建WPF项目
添加依赖
1 | dotnet add package System.Text.Json |
也就是
1 | <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> |
添加WebView2
1 | dotnet add package Microsoft.Web.WebView2 --version 1.0.2792.45 |
添加JS
1 | <script src="https://js.cybozu.cn/markedjs/v0.3.5/marked.min.js"> </script> |
解析Markdown
1 | //解析为html |