当前位置: 首页 > news >正文

php网站301重定向如何做分公司网站

php网站301重定向,如何做分公司网站,eclipse网站开发流程图,深圳推广开发工具:VS 2015 开发环境:.Net 4.0 使用技术:WPF 本篇文章内容: 本地部署DeepSeek以后一般使用网页工具(如Chatbox)或者DOS窗口与其对话。本篇文章使用WPF创建一个基础版的对话工具。 一、搭建本地DeepS…

开发工具:VS 2015
开发环境:.Net 4.0
使用技术:WPF

本篇文章内容:
本地部署DeepSeek以后一般使用网页工具(如Chatbox)或者DOS窗口与其对话。本篇文章使用WPF创建一个基础版的对话工具。

一、搭建本地DeepSeek环境

我参考的是一下几个教程:
1、DeepSeek本地搭建部署+搭建知识库+智能体详细图文教程
2、【问题记录】DeepSeek本地部署遇到问题
3、公司数据不泄露,DeepSeek R1本地化部署+web端访问+个人知识库搭建与使用,喂饭级实操教程,老旧笔记本竟跑出企业级AI
4、【大语言模型】本地快速部署Ollama运行大语言模型详细流程

二、vs2015 创建WPF项目

三、相关代码如下

Windows窗口界面

<Window x:Class="DeepSeekAI2.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:DeepSeekAI2"mc:Ignorable="d"Title="MainWindow" Height="680" Width="800"><Grid Margin="10,0,15,5"><Grid.RowDefinitions><RowDefinition Height="8.5*"/><RowDefinition Height="1.5*"/></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="750"/></Grid.ColumnDefinitions><!--第一个格子,AI对话格子--><Grid Grid.Row="0" Grid.Column="0"><ListBox Name="ChatListBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding}" TextWrapping="Wrap" MaxWidth="730"/></DataTemplate></ListBox.ItemTemplate></ListBox></Grid><!--第二个格子,用户输入框--><Grid Grid.Row="1" Grid.Column="0"><Grid.ColumnDefinitions><ColumnDefinition Width="8*" /><ColumnDefinition Width="2*"/></Grid.ColumnDefinitions><!--输入信息框--><Grid Grid.Column="0"><TextBox Name="InputTextBox" HorizontalAlignment="Left" VerticalAlignment="Bottom" KeyDown="InputTextBox_KeyDown"Height="62" Width="522" Margin="61,0,0,14" /></Grid><!--发送信息按钮框--><Grid Grid.Column="1"><Button Name="SendButton" Content="Send" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,58,20" Width="90" Height="50" Click="SendButton_Click" FontFamily="Arial Black" FontSize="13" Foreground="#FF424234"/></Grid><Grid Grid.Column="1"><Button Name="SendButton1" Content="new" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,2,60" Width="30" Height="30" Click="SendButton_Click1" FontFamily="Cambria" Foreground="#FF424234" Background="#FFB6F5C2"/></Grid></Grid></Grid>
</Window>

后端代码

using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using System.Net;namespace DeepSeekAI2
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}/// <summary>/// 输入按钮框/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void InputTextBox_KeyDown(object sender, KeyEventArgs e){if (e.Key == Key.Enter){RunAI();//InputTextBox.Text = "";}}/// <summary>/// 确认发送按钮/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void SendButton_Click(object sender, RoutedEventArgs e){// 异步方法需在同步上下文中调用(需手动处理)RunAI();//InputTextBox.Text = "";}// 用于存储对话的历史记录static StringBuilder conversationHistory = new StringBuilder();static string apiUrl = "http://localhost:11434/api/generate";public void RunAI(){// 用户输入string userInput = InputTextBox.Text;// 如果输入不正确,不输出if (userInput.ToLower() == "" || userInput.ToLower() == "\n"){return;}// 用户输入添加到历史对话记录conversationHistory.AppendLine($"用户: {userInput}");ChatListBox.Items.Add("-----------用户:-----------");ChatListBox.Items.Add(userInput);var requestData = new{model = "deepseek-r1:1.5b",prompt = conversationHistory.ToString(),stream = true};string jsonContent = Newtonsoft.Json.JsonConvert.SerializeObject(requestData);byte[] byteArray = Encoding.UTF8.GetBytes(jsonContent);HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);request.Method = "POST";request.ContentType = "application/json";request.ContentLength = byteArray.Length;using (Stream dataStream = request.GetRequestStream()){dataStream.Write(byteArray, 0, byteArray.Length);}try{using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())using (Stream responseStream = response.GetResponseStream())using (StreamReader reader = new StreamReader(responseStream)){string line;string line2 = "";while ((line = reader.ReadLine()) != null){if (!string.IsNullOrEmpty(line)){dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(line);if (result != null && result.response != null){//Console.Write(result.response);//Console.Out.Flush(); // 强制刷新控制台输出//ChatListBox.Items.Add(result.response);line2 += result.response;}}}// 处理AI回话// 去掉所有的换行符line2 = line2.Replace("\n\n", "");// 使用正则表达式去掉 <think> 和 </think> 标签line2 = Regex.Replace(line2, @"<\/?think>", "\n");// 去掉开头的换行符line2 = line2.TrimStart('\r', '\n');ChatListBox.Items.Add("-----------DeepSeek: -----------");//Console.WriteLine();  AI回话DeePSeek回话 line2ChatListBox.Items.Add(line2);conversationHistory.AppendLine($"DeepSeek: {line2}");line2 = "";}InputTextBox.Text = "";}catch (WebException ex){MessageBox.Show("请求异常: " + ex.Message);InputTextBox.Text = "";}}/// <summary>/// 开启新的对话/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void SendButton_Click1(object sender, RoutedEventArgs e){//1 清空历史记录conversationHistory.Clear();//2 清空 ListBox 的内容ChatListBox.Items.Clear();//3 清空输入框InputTextBox.Text = "";}}
}

四、内容介绍

static string apiUrl = "http://localhost:11434/api/generate";

其中这个代码是本地DeepSeek默认的调用接口,如果自己修改了相关内容将此修改就可以

model = "deepseek-r1:1.5b"

这串代码的意思是指定使用本地安装的某个DeepSeek版本。
在这里插入图片描述
因为7b的版本在我电脑上太慢。所以直接使用最快的模型。

五、完成效果如下

在这里插入图片描述
这样就搭建了基础的对话模型。大家可以不断优化,做一个自己的对话模型。

http://www.yayakq.cn/news/554146/

相关文章:

  • 索莱宝做网站金华市开发区人才网
  • 关于网站建设的通知正能量不良网站软件下载
  • 平顶山网站关键词优化学做网站需要
  • 物流管理网站怎么做食品网站建设策划书
  • 公司网站无法收录wordpress区块链模板
  • 李宁网站建设计划书网站建设的公司联系方式
  • 网站推广句子传奇手游在线玩网页游戏
  • qt 可以做网站吗西安app定制开发公司
  • 市民服务中心网站建设网站突然搜不到了
  • 律师在哪个网站做宁波网站推广人
  • 外汇申报在哪个网站上做建网站书籍
  • 网站怎样才能在百度被搜索到wordpress怎么添加友链
  • 番禺制作网站平台怎样做网站排名优化
  • 新沂建设网站网站建设需要哪些工作室
  • 建永久网站深圳app开发公司排名前十
  • 制作网站学什么软件手机网站页面尺寸大小
  • 网站建设与管理卷子爱奇艺推广联盟
  • 申请永久网站空间网络营销的渠道
  • 帝国cms影视网站模板公司网站手机版设计
  • mediwiki 做网站百度推广登录地址
  • 深圳网站seo教程seo短视频保密路线
  • 网站建设步和客户沟通山西住房与城乡建设部网站
  • 西安谁家的集团门户网站建设比较好公众号运营一年多少钱
  • 北京网站排名优化如何在网站搜关键字
  • 网站平台设计团队网站制作价格服务
  • 成都网站建设与网站制作公司logo设计费用一般多少钱
  • 福州建设银行官网招聘网站东营网站建设服务电话
  • 国外做电商网站有哪些wordpress 下拉框链接
  • 廊坊网站排名优化公司哪家好江苏网站建设哪家有
  • 潍坊制作网站wordpress侧边小工具栏