【deepseek实战】绿色好用,不断网

前言

        最佳deepseek火热网络,我也开发一款windows的电脑端,接入了deepseek,基本是复刻了网页端,还加入一些特色功能。

        助力国内AI,发出自己的热量

        说一下开发过程和内容的使用吧。


目录

一、介绍

二、具体工作

        1.1、引用

        1.2、主界面

        1.3、主界面布局

        1.4 、消息类

        1.5 、设置

三、运行图示 

四、总结

五、下载


一、介绍

  •    目标:个人桌面AI助手,避免与专属API冲突,因为官网一些原因断网,自己接入API,确保能上deepseek。
    先上图,确定是否需要使用:
  • 软件是免费的,自己用自己的key或者别人的key,没有key可以联系我

二、具体工作

        1.1、引用

        dotnet8.0

  <TargetFramework>net8.0-windows</TargetFramework>

        PackageReference 

    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /><PackageReference Include="System.Drawing.Common" Version="8.0.0" /><PackageReference Include="System.Speech" Version="8.0.0" /><PackageReference Include="Spire.Doc" Version="12.8.0" />

            Newtonsoft.Json 编译和反编译API信息
            System.Drawing 绘制库,画界面主要
            System.Speech 语音接入
            Spire.Doc 文档使用

        这几个引用根据自己需要添加

        1.2、主界面

        信息处理,分为及时信息和二次信息处理,这样能对文本信息进行个人需要处理

private async Task<ChatMessage> StreamResponseAsync(string apiKey, List<ChatMessage> chatHistory, string language, CancellationToken cancellationToken)
{var deepseekService = new DeepseekService(currentUser, _printService);var messages = chatHistory.Select(m => new ChatMessage{Role = m.Role,MessageType = m.MessageType,Content = m.Content}).ToList();try{var typingDelay = TimeSpan.FromMilliseconds(50);var buffer = new StringBuilder();var responseMessage = new ChatMessage{Role = "assistant",MessageType = MessageType.Answer,Content = string.Empty,WrappedContent = string.Empty};// 创建响应消息但不立即添加到历史记录var responseIndex = _displayHistory .Count;// 实时处理流式响应 - deepseek输出开始var charCount = 0;var tempBuffer = new StringBuilder();await foreach (var chunk in deepseekService.StreamChatResponseAsync(apiKey, messages, language).WithCancellation(cancellationToken)){if (string.IsNullOrEmpty(chunk) || _isStopping || cancellationToken.IsCancellationRequested) {// Immediately return if stoppingreturn new ChatMessage{Role = "assistant",MessageType = MessageType.Answer,Content = "对话已终止",WrappedContent = "对话已终止"};}tempBuffer.Append(chunk);charCount += chunk.Length;// 每20个字符更新一次显示if (charCount >= 20){buffer.Append(tempBuffer.ToString());tempBuffer.Clear();charCount = 0;await Dispatcher.InvokeAsync(() => {responseMessage.Content = buffer.ToString();responseMessage.WrappedContent = WrapText(responseMessage.Content+"\n回答完成1",ChatHistoryRichTextBox?.ActualWidth - 20 ?? ChatMessage.DefaultBorderWidth);// 更新_curchat_curchatMesg = responseMessage;// 只在第一次更新时添加消息if (_displayHistory .Count == responseIndex) {_displayHistory .Add(responseMessage);} else {_displayHistory [responseIndex] = responseMessage;}UpdateChatHistoryDisplayList(_displayHistory);});          await Task.Delay(typingDelay);}}// 处理剩余不足20字符的内容if (tempBuffer.Length > 0){buffer.Append(tempBuffer.ToString());await Dispatcher.InvokeAsync(() => {responseMessage.Content = buffer.ToString() ;responseMessage.WrappedContent = WrapText(responseMessage.Content+"\n回答完成2",ChatHistoryRichTextBox?.ActualWidth - 20 ?? ChatMessage.DefaultBorderWidth);          // 更新_curchat_curchatMesg = responseMessage;_displayHistory [responseIndex] = responseMessage;UpdateChatHistoryDisplayList(_displayHistory);});}// deepseek输出完成 - 流式响应结束// 进行最后的换行检查await Dispatcher.InvokeAsync(() => {responseMessage.WrappedContent = WrapText(responseMessage.Content+"\n回答完成3", ChatHistoryRichTextBox?.ActualWidth - 20 ?? ChatMessage.DefaultBorderWidth);// 更新_curchat_curchatMesg = responseMessage;_displayHistory [responseIndex] = responseMessage;UpdateChatHistoryDisplayList(_displayHistory);});return responseMessage;}catch (Exception ex){return new ChatMessage{Role = "assistant",MessageType = MessageType.Answer,Content = $"Error: {ex.Message}",WrappedContent = $"Error: {ex.Message}"};}finally{// 清空输入框InputTextBox.Text = string.Empty;}
}

        1.3、主界面布局
<Window x:Class="AIzhushou.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:AIzhushou.Converters"Title="智能聊天助手" Height="820" Width="420" MinHeight="800" MinWidth="400"WindowStartupLocation="Manual"Background="#333333" ResizeMode="CanResizeWithGrip"><Window.Resources><ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="/Styles.xaml"/></ResourceDictionary.MergedDictionaries><local:EndMarkVisibilityConverter x:Key="EndMarkVisibilityConverter"/><local:MathConverter x:Key="MathConverter"/></ResourceDictionary></Window.Resources><Viewbox Stretch="Uniform"><Grid Width="420" Height="760" Background="#333333"><Grid.ColumnDefinitions><ColumnDefinition Width="63*"/><ColumnDefinition Width="337*"/></Grid.ColumnDefinitions><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/><RowDefinition Height="Auto"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><!-- Top Buttons --><DockPanel Grid.Row="0" Grid.Column="1" Margin="265,0,20,5" Width="88"><Button  x:Name="setting" Style="{StaticResource MainButtonStyle}"Click="setting_Click" Height="40" Width="40" RenderTransformOrigin="0.5,0.5"DockPanel.Dock="Right"><Image Source="pack://application:,,,/AIzhushou;component/Img/icons8-home-page-50.png" Width="30" Height="30"/></Button></DockPanel><!-- Chat History Label --><Label Style="{StaticResource SectionLabelStyle}" Content="聊天记录" Margin="22,0,0,0" Grid.ColumnSpan="2" VerticalAlignment="Center"/><!-- Chat History RichTextBox --><Border Grid.Row="1" Style="{StaticResource ChatBorderStyle}" HorizontalAlignment="Left"Grid.ColumnSpan="2" Margin="15,0,0,10"><Border.Resources><Style TargetType="ScrollViewer" BasedOn="{StaticResource CustomScrollViewerStyle}" /></Border.Resources><RichTextBox x:Name="ChatHistoryRichTextBox" Style="{StaticResource ChatHistoryRichTextBoxStyle}"Loaded="ChatHistoryRichTextBox_Loaded" Width="380" Margin="-10,0,0,0"><RichTextBox.Resources><!-- 设置 Paragraph 的 Margin --><Style TargetType="Paragraph"><Setter Property="Margin" Value="0"/></Style></RichTextBox.Resources></RichTextBox></Border><!-- New Conversation Button --><StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,10,0,10" Grid.Column="1"><!--<Button x:Name="FreshButton" Style="{StaticResource FreshButtonStyle}" Click="freshButton_Click" Height="36" Width="120"><Button.Content><StackPanel Orientation="Horizontal"><Image Source="pack://application:,,,/AIzhushou;component/Img/icons8-refresh-96.png" Width="20" Height="20" Margin="0,0,5,0"/><TextBlock Text="刷新刚才回答" VerticalAlignment="Center" Foreground="#4d6bfe"/></StackPanel></Button.Content></Button>--><Button x:Name="NewConversationButton" Style="{StaticResource NewConversationButtonStyle}"Click="NewConversationButton_Click" Margin="90,0,5,0" Height="36" Width="120"><Button.Content><StackPanel Orientation="Horizontal"><Image Source="pack://application:,,,/AIzhushou;component/Img/icons8-talk-64.png" Width="20" Height="20" Margin="0,0,5,0"/><TextBlock Text="开启新对话" VerticalAlignment="Center" Foreground="#4d6bfe"/></StackPanel></Button.Content></Button></StackPanel><!-- Input Label --><Label Grid.Row="3" Style="{StaticResource SectionLabelStyle}" Content="输入消息" Margin="22,0,0,0" Grid.ColumnSpan="2" VerticalAlignment="Center"/><!-- Input Section --><Grid Grid.Row="4" HorizontalAlignment="Left" VerticalAlignment="Bottom"Margin="22,0,0,-10" Width="378" Grid.ColumnSpan="2"><Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions><!-- Input TextBox --><TextBox x:Name="InputTextBox" Grid.Column="0"Style="{StaticResource InputTextBoxStyle}"TextWrapping="Wrap" AcceptsReturn="True"KeyDown="InputTextBox_KeyDown"PreviewKeyDown="InputTextBox_KeyDown"/><!-- Send Button --><Border Grid.Column="1" Style="{StaticResource SendButtonBorderStyle}" Margin="10,0,0,0"><Button x:Name="SendButton" Style="{StaticResource SendButtonStyle}"Content="发送" Click="SendButton_Click" IsEnabled="True"/></Border></Grid></Grid></Viewbox>
</Window>

        1.4 、消息类

        设计这个是为了对消息类对API的信息进行存入和处理

 public enum MessageType{Question,Answer}public class ChatMessage{public static double DefaultBorderWidth { get; set; } = 300;public string Role { get; set; }public string Content { get; set; }public string WrappedContent { get; set; }public double BorderWidth { get; set; } = DefaultBorderWidth;public Brush BackgroundColor { get; set; }public Brush TextColor { get; set; }public DateTime Timestamp { get; set; }    public MessageType MessageType { get; set; }public ChatMessage(){Role = string.Empty;Content = string.Empty;WrappedContent = string.Empty;Timestamp = DateTime.Now;BackgroundColor = Brushes.White;TextColor = Brushes.Black;}public ChatMessage(string content, string wrappedContent, double borderWidth) : this(){Content = content;WrappedContent = wrappedContent;BorderWidth = borderWidth;}}


        1.5 、设置

        API KEY这里是必须填写的,不填写是无法进行问题的回答

这里是代码

private void SaveButton_Click(object sender, RoutedEventArgs e)
{// 更新用户信息currentUser.Username = UsernameTextBox.Text;currentUser.Password = PasswordBox.Password;currentUser.AiUrl = AiUrlTextBox.Text;currentUser.ModelUrl = ModelUrlTextBox.Text;currentUser.ApiKey = ApiKeyTextBox.Text == "请输入deepseek的API keys" ? string.Empty : ApiKeyTextBox.Text;// 保存语言设置var selectedLanguage = ((ComboBoxItem)LanguageComboBox.SelectedItem).Content.ToString();string languageCode = selectedLanguage == "中文" ? "zh-CN" : "en-US";AppSettings.Instance.DefaultLanguage = languageCode;AppSettings.Instance.SaveLanguageSettings(languageCode);// 保存复制选项设置//AppSettings.Instance.CopyCurrent = CopyCurrentRadio.IsChecked == true;AppSettings.Instance.Save();// 保存到配置文件string configPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"AIzhushou","config.json");// 确保目录存在var directoryPath = System.IO.Path.GetDirectoryName(configPath);if (string.IsNullOrEmpty(directoryPath)){throw new InvalidOperationException("无法确定配置文件的目录路径");}System.IO.Directory.CreateDirectory(directoryPath);// 序列化保存string json = Newtonsoft.Json.JsonConvert.SerializeObject(currentUser);System.IO.File.WriteAllText(configPath, json);MessageBox.Show("设置保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);this.Close();
}


三、运行图示 


四、总结

  •    实测了windows c#版本和python版本, c#版比python版本的性能更好,可能C#是微软亲儿子原因?
  •    一定用要异步处理,没有什么特别需要
  •    AI里面,deepseek是真的强
  •    如果需要提供协助,可以私信我

写着写着就这么多了,可能不是特别全,不介意费时就看看吧。有时间还会接着更新。


五、下载

        AI助手绿色免安装下载 支持deepseek

        AI助手项目下载

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/69273.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【OS】AUTOSAR架构下的Interrupt详解(上篇)

目录 前言 正文 1.中断概念分析 1.1 中断处理API 1.2 中断级别 1.3 中断向量表 1.4 二类中断的嵌套 1.4.1概述 1.4.2激活 1.5一类中断 1.5.1一类中断的实现 1.5.2一类中断的嵌套 1.5.3在StartOS之前的1类ISR 1.5.4使用1类中断时的注意事项 1.6中断源的初始化 1.…

一条sql 在MySQL中是如何执行的

在 MySQL 中&#xff0c;SQL 查询的执行涉及多个内存区域和处理步骤&#xff0c;以确保查询能够高效地执行和返回结果。以下是 SQL 查询在 MySQL 中执行时通常会经过的内存路径&#xff1a; 1. 客户端内存 - SQL 文本发送 &#xff1a;SQL 查询首先从客户端发送到 MySQL 服务…

llama.cpp GGUF 模型格式

llama.cpp GGUF 模型格式 1. Specification1.1. GGUF Naming Convention (命名规则)1.1.1. Validating Above Naming Convention 1.2. File Structure 2. Standardized key-value pairs2.1. General2.1.1. Required2.1.2. General metadata2.1.3. Source metadata 2.2. LLM2.2.…

Day30-【AI思考】-错题分类进阶体系——12维错误定位模型

文章目录 错题分类进阶体系——12维错误定位模型**一、认知层错误&#xff08;根源性缺陷&#xff09;****二、操作层错误&#xff08;执行过程偏差&#xff09;****三、心理层错误&#xff08;元认知障碍&#xff09;****四、进阶错误&#xff08;专业级陷阱&#xff09;** 错…

Java/Kotlin双语革命性ORM框架Jimmer(一)——介绍与简单使用

概览 Jimmer是一个Java/Kotlin双语框架 包含一个革命性的ORM 以此ORM为基础打造了一套综合性方案解决方案&#xff0c;包括 DTO语言 更全面更强大的缓存机制&#xff0c;以及高度自动化的缓存一致性 更强大客户端文档和代码生成能力&#xff0c;包括Jimmer独创的远程异常 …

openAI官方prompt技巧(一)

1. 使用最新的模型 2. 将指令放在提示词的开头&#xff0c;并使用 ### 或 """ 来分隔指令和上下文&#xff0c;例如 错误示范❌ 将下面的文本总结为一个要点列表&#xff0c;列出最重要的内容。 Summarize the text below as a bullet point list of the most…

通过制作docker镜像的方式在阿里云部署前端后台服务

前端Dockerfile文件的内容&#xff1a; FROM nginx:版本&#xff0c;如果不指定&#xff0c;默认是latest COPY dist/ /usr/share/nginx/html/dist COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 端口 前端sh脚本文件内容&#xff1a; appName项目名 tar -xvf dist.tar …

Github 2025-02-04 Python开源项目日报 Top10

根据Github Trendings的统计,今日(2025-02-04统计)共有10个项目上榜。根据开发语言中项目的数量,汇总情况如下: 开发语言项目数量Python项目10TypeScript项目1Python中的算法实现集合 创建周期:2831 天开发语言:Python协议类型:MIT LicenseStar数量:178357 个Fork数量:…

yolov11模型在Android设备上运行【踩坑记录】

0) 参考资料: https://github.com/Tencent/ncnn?tabreadme-ov-file https://github.com/pnnx/pnnx https://github.com/nihui/ncnn-android-yolov5 https://github.com/Tencent/ncnn?tabreadme-ov-file 1) &#xff1a;将xxx.pt模型转化成 xxx.onnx ONNX&#xff08;Ope…

快速上手——.net封装使用DeekSeek-V3 模型

📢欢迎点赞 :👍 收藏 ⭐留言 📝 如有错误敬请指正,赐人玫瑰,手留余香!📢本文作者:由webmote 原创📢作者格言:新的征程,用爱发电,去丈量人心,是否能达到人机合一?开工大吉 新的一年就这么水灵灵的开始了,在这里,祝各位读者新春快乐,万事如意! 新年伊…

2025蓝桥杯JAVA编程题练习Day2

1.大衣构造字符串 问题描述 已知对于一个由小写字母构成的字符串&#xff0c;每次操作可以选择一个索引&#xff0c;将该索引处的字符用三个相同的字符副本替换。 现有一长度为 NN 的字符串 UU&#xff0c;请帮助大衣构造一个最小长度的字符串 SS&#xff0c;使得经过任意次…

【WebLogic】Oracle发布WebLogic 14c最新版本-14.1.2.0

根据Oracle官方产品经理的博客&#xff0c;Oracle于2024年12月20日正式对外发布了WebLogic 14c的第二个正式版本&#xff0c;版本号为 14.1.2.0.0 &#xff0c;目前官方已开放客户端下载。该版本除继续支持 Jakarta EE 8 版本外&#xff0c;还增加了对 Java SE 17&#xff08;J…

Spider 数据集上实现nlp2sql训练任务

NLP2SQL&#xff08;自然语言处理到 SQL 查询的转换&#xff09;是一个重要的自然语言处理&#xff08;NLP&#xff09;任务&#xff0c;其目标是将用户的自然语言问题转换为相应的 SQL 查询。这一任务在许多场景下具有广泛的应用&#xff0c;尤其是在与数据库交互的场景中&…

IDEA+DeepSeek让Java开发起飞

1.获取DeepSeek秘钥 登录DeepSeek官网 : https://www.deepseek.com/ 进入API开放平台&#xff0c;第一次需要注册一个账号 进去之后需要创建一个API KEY&#xff0c;然后把APIkey记录保存下来 接着我们获取DeepSeek的API对话接口地址&#xff0c;点击左边的&#xff1a;接口…

k8s常见面试题2

k8s常见面试题2 安全与权限RBAC配置如何保护 Kubernetes 集群的 API Server&#xff1f;如何管理集群中的敏感信息&#xff08;如密码、密钥&#xff09;&#xff1f;如何限制容器的权限&#xff08;如使用 SecurityContext&#xff09;&#xff1f;如何防止容器逃逸&#xff0…

flutter安卓打包签名

flutter安卓打包签名 1.创建签名文件 keytool -genkeypair -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-aliaskeytool 是一个用于管理密钥和证书的命令行工具&#xff0c;通常与 Java 开发工具包 (JDK) 一起使用。my-release-…

React - jsx 语法

在 React 中&#xff0c;JSX&#xff08;JavaScript XML&#xff09;是一种语法扩展&#xff0c;它允许开发者在 JavaScript 代码中使用类似 HTML 的语法。JSX 提升了代码的可读性和可维护性&#xff0c;使得编写和构建用户界面更加直观。它被广泛应用于 React 组件的定义。 一…

intra-mart实现简易登录页面笔记

一、前言 最近在学习intra-mart框架&#xff0c;在此总结下笔记。 intra-mart是一个前后端不分离的框架&#xff0c;开发时主要用的就是xml、html、js这几个文件&#xff1b; xml文件当做配置文件&#xff0c;html当做前端页面文件&#xff0c;js当做后端文件&#xff08;js里…

Linux+Docer 容器化部署之 Shell 语法入门篇 【Shell 替代】

&#x1f380;&#x1f380;Shell语法入门篇 系列篇 &#x1f380;&#x1f380; LinuxDocer 容器化部署之 Shell 语法入门篇 【准备阶段】LinuxDocer 容器化部署之 Shell 语法入门篇 【Shell变量】LinuxDocer 容器化部署之 Shell 语法入门篇 【Shell数组与函数】LinuxDocer 容…

Intellij IDEA如何查看当前文件的类

快捷键&#xff1a;CtrlF12&#xff0c;我个人感觉记快捷键很麻烦&#xff0c;知道具体的位置更简单&#xff0c;如果忘了快捷键&#xff08;KeyMap&#xff09;看一下就记起来了&#xff0c;不需要再Google or Baidu or GPT啥的&#xff0c;位置&#xff1a;Navigate > Fi…