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

成都网站建设制作网站如何做ip签名图片

成都网站建设制作,网站如何做ip签名图片,商标免费生成器,广州做网站lomuw目录结构Ollama是什么安装 Ollama下载大模型运行模型Java和IDEA版本创建一个springboot项目创建一个简单的对话接口启动spring boot流式对话输出用原生 HTML 打造可交互前端接入 OpenAI、DeepSeek 等云模型#xff08;可选#xff09;原文地址传送门 我是想做一个大模型本地部… 目录结构Ollama是什么安装 Ollama下载大模型运行模型Java和IDEA版本创建一个springboot项目创建一个简单的对话接口启动spring boot流式对话输出用原生 HTML 打造可交互前端接入 OpenAI、DeepSeek 等云模型可选原文地址传送门 我是想做一个大模型本地部署辅助工具类似当前手机上各家厂商的AI助手结合 MCPModel Context Protocol协议可实现 AI 与文件系统交互、自动生成文件等强大能力。 但是这篇文章中的内容比较精炼很多细节容易踩坑所以记录一下 Ollama是什么 Ollama 是一个简洁好用的本地大模型运行工具你可以在自己的电脑上直接部署和运行 LLM。 安装 Ollama 访问官网下载安装支持 Windows/Mac/Linux https://ollama.com/download下载好安装包后会一键安装到C盘不能改路径是我没想到的 启动客户端就是一个和AI的对话框 在命令行cmd中输入 ollama --help出现如下提示证明安装成功 下载大模型 依旧是在cmd中输入指令 ollama pull qwen3其中qwen3是我准备使用的模型原文中使用的是gemma3:1b但后续我准备接入MCP当前Qwen3是支持的所以我选择它。 如果没用梯子可以使用阿里云镜像 ollama pull qwen3 --registry https://hub.aliyun.com # 阿里云镜像站最后出现TLS超时 核心原因中国网络环境对 TLS 通信有特殊限制防火墙/网络策略Ollama 默认用国际 Hugging Face 仓库 → 国内访问会超时Qwen3 模型在 Hugging Face 上的国际地址 → 中国网络无法正常 TLS 握手 但我实际使用下来还是可以正常运行证明自己安装成功指令如下 ollama list出现自己想要的模型名称证明安装成功 运行模型 依旧cmd执行命令ollama会自动下载相关的内容并执行 ollama run qwen3实测能够进行中文问答并且有思考过程和最终呈现内容 使用 /bye 结束对话 至此本地模型就算是搭建好了暂时不要关闭等待spring boot调用这个接口 Java和IDEA版本 使用Spring AI 1.0.1 要求Java 17 我当前的Java还是老掉牙的8所以去升级了一下参考教程 值得一提的是Java已经有24的版本了我还纠结了要不要安装最新的以防后期又要安装新版本问了下AI 在用上Java17之后我又发现IDEA出现了报错 本来以为是Java17没安装好实际结合参考文章 我确实是在用IDEA2020太老啦无法解析了所以又去更新IDEA参考文章 彻底卸载旧的IDEA安装最新的2025版本说起来2020版本已经陪我度过5年了真不容易 maven版本也需要升级一下Spring Boot 3.2.1 要求Maven 3.8.x 参考文章 文章最后要记得使用Java17并且\mirror标签貌似有问题我把完整的mirror文件粘贴如下 ?xml version1.0 encodingUTF-8?!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless 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. --!--| This is the configuration file for Maven. It can be specified at two levels:|| 1. User Level. This settings.xml file provides configuration for a single user,| and is normally provided in ${user.home}/.m2/settings.xml.|| NOTE: This location can be overridden with the CLI option:|| -s /path/to/user/settings.xml|| 2. Global Level. This settings.xml file provides configuration for all Maven| users on a machine (assuming theyre all using the same Maven| installation). Its normally provided in| ${maven.conf}/settings.xml.|| NOTE: This location can be overridden with the CLI option:|| -gs /path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||-- settings xmlnshttp://maven.apache.org/SETTINGS/1.2.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd!-- localRepository| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repositorylocalRepository/path/to/local/repo/localRepository--localRepositoryF:\Environment\apache-maven-3.8.9\maven_repositroy/localRepository!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: trueinteractiveModetrue/interactiveMode--!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: falseofflinefalse/offline--!-- pluginGroups| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.| when invoking a command line like mvn prefix:goal. Maven will automatically add the group identifiers| org.apache.maven.plugins and org.codehaus.mojo if these are not already contained in the list.|--pluginGroups!-- pluginGroup| Specifies a further group identifier to use for plugin lookup.pluginGroupcom.your.plugins/pluginGroup--/pluginGroups!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--proxies!-- proxy| Specification for one proxy, to be used in connecting to the network.|proxyidoptional/idactivetrue/activeprotocolhttp/protocolusernameproxyuser/usernamepasswordproxypass/passwordhostproxy.host.net/hostport80/portnonProxyHostslocal.net|some.host.com/nonProxyHosts/proxy--/proxies!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--servers!-- server| Specifies the authentication information to use when connecting to a particular server, identified by| a unique name within the system (referred to by the id attribute below).|| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are| used together.|serveriddeploymentRepo/idusernamerepouser/usernamepasswordrepopwd/password/server--!-- Another sample, using keys to authenticate.serveridsiteServer/idprivateKey/path/to/private/key/privateKeypassphraseoptional; leave empty if not used./passphrase/server--/servers!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--mirrors!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|mirroridmirrorId/idmirrorOfrepositoryId/mirrorOfnameHuman Readable Name for this Mirror./nameurlhttp://my.repository.com/repo/path/url/mirror--mirroridnexus-aliyun/idmirrorOfcentral/mirrorOfnameNexus aliyun/nameurlhttp://maven.aliyun.com/nexus/content/groups/public/url/mirror!-- mirroridmaven-default-http-blocker/idmirrorOfexternal:http:*/mirrorOfnamePseudo repository to mirror external repositories initially using HTTP./nameurlhttp://0.0.0.0//urlblockedtrue/blocked/mirror --/mirrors!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is| dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a| value of 1.4 might activate a profile when the build is executed on a JDK version of 1.4.2_07.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact| repositories, plugin repositories, and free-form properties to be used as configuration| variables for plugins in the POM.||--profiles!-- profile| Specifies a set of introductions to the build process, to be activated using one or more of the| mechanisms described above. For inheritance purposes, and to activate profiles via activatedProfiles/| or the command line, profiles have to have an ID that is unique.|| An encouraged best practice for profile identification is to use a consistent naming convention| for profiles, such as env-dev, env-test, env-production, user-jdcasey, user-brett, etc.| This will make it more intuitive to understand what the set of introduced profiles is attempting| to accomplish, particularly when you only have a list of profile ids for debug.|| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.profileidjdk-1.4/idactivationjdk1.4/jdk/activationrepositoriesrepositoryidjdk14/idnameRepository for JDK 1.4 builds/nameurlhttp://www.myhost.com/maven/jdk14/urllayoutdefault/layoutsnapshotPolicyalways/snapshotPolicy/repository/repositories/profile-- profile!-- 以下配置会自动使用Java 17 --profileidjava-17/idactivationactiveByDefaulttrue/activeByDefault/activationpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingmaven.compiler.source17/maven.compiler.sourcemaven.compiler.target17/maven.compiler.target/properties/profile /profile!--| Here is another profile, activated by the system property target-env with a value of dev,| which provides a specific path to the Tomcat instance. To use this, your plugin configuration| might hypothetically look like:|| ...| plugin| groupIdorg.myco.myplugins/groupId| artifactIdmyplugin/artifactId|| configuration| tomcatLocation${tomcatPath}/tomcatLocation| /configuration| /plugin| ...|| NOTE: If you just wanted to inject this configuration whenever someone set target-env to| anything, you could just leave off the value/ inside the activation-property.|profileidenv-dev/idactivationpropertynametarget-env/namevaluedev/value/property/activationpropertiestomcatPath/path/to/tomcat/instance/tomcatPath/properties/profile--/profiles!-- activeProfiles| List of profiles that are active for all builds.|activeProfilesactiveProfilealwaysActiveProfile/activeProfileactiveProfileanotherAlwaysActiveProfile/activeProfile/activeProfiles-- /settings 我使用的是 Java 17 Maven 3.8.9 Spring Boot 3.2.1 Spring AI 1.0.1 创建一个springboot项目 修改pom.xml文件并且maven编译以下是我的可以参考一下 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.example/groupIdartifactIdQwen3/artifactIdversion0.0.1-SNAPSHOT/versionnameQwen3/namedescriptionQwen3/descriptionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.2.1/version/parentpropertiesjava.version17/java.versionproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncoding/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-jpa/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-jdbc/artifactId/dependencydependencygroupIdcom.mysql/groupIdartifactIdmysql-connector-j/artifactIdscoperuntime/scope/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!-- Spring AI Ollama Starter necessary--dependencygroupIdorg.springframework.ai/groupIdartifactIdspring-ai-starter-model-ollama/artifactId/dependency/dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.ai/groupIdartifactIdspring-ai-bom/artifactIdversion1.0.1/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementbuildpluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.8.1/versionconfigurationsource17/sourcetarget17/targetencodingUTF-8/encoding/configuration/pluginplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdconfigurationmainClasscom.example.qwen3.Qwen3Application/mainClass/configuration/plugin/plugins/build /project修改/src/main/resources下application.propertity为application.yml spring:ai:ollama:base-url: http://127.0.0.1:11434chat:enabled: true# 默认聊天模型model: qwen3:4boptions:temperature: 0.7top_p: 0.9num_predict: 512embedding:enabled: truemodel: qwen3options:num-batch: 512# MCP 配置用于插件/扩展对接mcp:client:stdio:servers-configuration: classpath:config/mcp-servers.jsonserver:port: 8181为了方便后面接入MCP我直接加上去了注意我这里的端口是8181默认应该是8080为了避免后续冲突我使用8181端口 创建一个简单的对话接口 在controller下创建Java文件LocalAIInvokeTest 原文中没用指明包我这里把全文都粘贴上以免包导入的不对 package com.example.qwen3.controller;import jakarta.annotation.Resource; import org.springframework.ai.chat.model.ChatResponse; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.ollama.OllamaChatModel; import org.springframework.ai.ollama.api.OllamaOptions; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux;RequestMapping(/ollama) RestController public class LocalAIInvokeTest {Resourceprivate OllamaChatModel ollamaChatModel;/*** 根据用户提问输出回答** param prompt* return*/GetMapping(/test)public String testChat(String prompt) {ChatResponse chatResponse ollamaChatModel.call(new Prompt(prompt,OllamaOptions.builder().model(qwen3:4b).build()));return chatResponse.getResult().getOutput().getText();}GetMapping(value /testStream, produces MediaType.TEXT_EVENT_STREAM_VALUE)public FluxChatResponse testChatStream(String prompt) {return ollamaChatModel.stream(new Prompt(prompt, OllamaOptions.builder().model(qwen3:4b).build()));} }启动spring boot 启动spring boot项目在浏览器中输入 http://localhost:8181/test?prompt你好过一会就会有相应 可以看到思考过程也是呈现出来的证明我们连接成功 流式对话输出 普通对话是要等很久一次性输出内容我们当前的AI大多都已经能够逐字输出更加人信汇使用springboot中的Flux TEXT_EVENT_STREAM_VALUE就能实现在参考文章中也有 在原来test映射后面加入上面这段内容我上面的代码已经给出了alt回车导入依赖就行重启springboot项目后在浏览器可以使用 http://localhost:8181/ollama/testStream?prompt你是什么模型测试一下结果确实是返回了很多json浏览器没有解析而已符合预期。 用原生 HTML 打造可交互前端 由于原文中的代码很多缺少空格导致编译器没法识别我粘贴我使用的代码具体就是把spring boot自带的index.html改成如下 我在原来代码基础上优化了思考内容和正文的显示样式并且 !DOCTYPE html html langzh headmeta charsetUTF-8 /title本地 AI 对话系统/titlescript srchttps://cdn.jsdelivr.net/npm/marked/marked.min.js/scriptscript srchttps://cdn.jsdelivr.net/npm/dompurify3.0.5/dist/purify.min.js/scriptstyle* { box-sizing: border-box; }body {font-family: Helvetica Neue, Arial, sans-serif;background: #f4f4f4;margin: 0;padding: 48px;display: flex;justify-content: center;align-items: center;height: 100vh;}.chat-wrapper {display: flex;flex-direction: column;width: 100%;max-width: 1200px;height: 100%;background: #fff;border-radius: 16px;box-shadow: 0 0 12px rgba(0, 0, 0, 0.1);overflow: hidden;}.chat-container {flex: 1;overflow-y: auto;padding: 24px;display: flex;flex-direction: column;}.message {max-width: 70%;padding: 12px 16px;margin: 8px 0;border-radius: 16px;word-break: break-word;line-height: 1.5;}.user {align-self: flex-end;background-color: #dcfce7;color: #0f5132;border: 1px solid #badbcc;}.ai {align-self: flex-start;background-color: #f8f9fa;border: 1px solid #dee2e6;display: flex;flex-direction: column;}.ai-thought {font-size: 12px;color: #6c757d;margin-bottom: 6px;font-style: italic;animation: blink 5s infinite;}keyframes blink {0%, 50%, 100% { opacity: 0.3; }25%, 75% { opacity: 1; }}.ai-reply {font-size: 16px;color: #212529;line-height: 1.6;}.input-bar {display: flex;padding: 16px 24px;border-top: 1px solid #ddd;background-color: #ffffff;}#promptInput {flex: 1;padding: 12px;font-size: 16px;border: 1px solid #ccc;border-radius: 8px;resize: none;height: 48px;line-height: 1.5;}#sendBtn {margin-left: 12px;padding: 12px 20px;font-size: 16px;background-color: #4caf50;color: white;border: none;border-radius: 8px;cursor: pointer;transition: background-color 0.2s ease;}#sendBtn:hover { background-color: #45a049; }pre code {background: #f6f8fa;padding: 8px;border-radius: 6px;display: block;overflow-x: auto;}/* 新增表格样式 */.ai-reply table {border-collapse: collapse;width: 100%;margin: 8px 0;background-color: #fff;border: 1px solid #dee2e6;}.ai-reply th,.ai-reply td {border: 1px solid #dee2e6;padding: 8px;text-align: left;}.ai-reply th {background-color: #e9ecef;font-weight: bold;}.ai-reply tr:nth-child(even) {background-color: #f8f9fa;}.ai-reply tr:hover {background-color: #e9ecef;}/style /head body div classchat-wrapperdiv classchat-container idchatContainer/divdiv classinput-bartextarea idpromptInput placeholder请输入你的问题... rows3/textareabutton idsendBtn发送/button/div /divscriptconst chatContainer document.getElementById(chatContainer);const input document.getElementById(promptInput);const button document.getElementById(sendBtn);// 创建消息容器function appendMessage(className) {const div document.createElement(div);div.className message ${className};chatContainer.appendChild(div);chatContainer.scrollTop chatContainer.scrollHeight;return div;}// 显示用户消息function displayUserMessage(text) {if (!text) return;const userDiv appendMessage(user);userDiv.textContent text;input.value ;input.style.height 48px;}// 显示AI消息包括思考过程和回复function displayAIMessage(prompt) {const aiDiv appendMessage(ai);const thoughtDiv document.createElement(div);thoughtDiv.className ai-thought;thoughtDiv.textContent 思考中...;aiDiv.appendChild(thoughtDiv);const replyDiv document.createElement(div);replyDiv.className ai-reply;aiDiv.appendChild(replyDiv);let inThought false;let thoughtBuffer ;let answerBuffer ;const eventSource new EventSource(http://localhost:8181/ollama/testStream?prompt${encodeURIComponent(prompt)});eventSource.onmessage (event) {const json JSON.parse(event.data);const textChunk json.result.output.text;if (textChunk.includes(think)) {inThought true;return;}if (textChunk.includes(/think)) {inThought false;thoughtDiv.textContent thoughtBuffer.trim();return;}if (inThought) {thoughtBuffer textChunk;thoughtDiv.textContent thoughtBuffer.trim();} else {answerBuffer textChunk;replyDiv.innerHTML DOMPurify.sanitize(marked.parse ? marked.parse(answerBuffer) : marked(answerBuffer));if (!inThought thoughtDiv.textContent ! ) {thoughtDiv.remove();}}chatContainer.scrollTop chatContainer.scrollHeight;};eventSource.onerror () {eventSource.close();if (thoughtDiv.textContent ! ) {thoughtDiv.remove();}};}// 发送用户消息并触发AI回复function sendUserMessage() {const prompt input.value.trim();if (!prompt) return;displayUserMessage(prompt);displayAIMessage(prompt);}// 显示AI开场白function sendAIGreeting() {const greeting 你好有什么可以帮你;const aiDiv appendMessage(ai);const replyDiv document.createElement(div);replyDiv.className ai-reply;replyDiv.textContent greeting;aiDiv.appendChild(replyDiv);}// 点击发送按钮button.onclick sendUserMessage;// 按回车键发送ShiftEnter换行input.addEventListener(keydown, (e) {if (e.key Enter !e.shiftKey) {e.preventDefault();sendUserMessage();}});// 自动调整 textarea 高度input.addEventListener(input, () {input.style.height auto;input.style.height input.scrollHeight px;});// 页面加载时显示AI开场白window.onload () {setTimeout(() {sendAIGreeting();}, 400);}; /script /body /html注意在184行那边要写自己的大模型访问接口就是上面我们测试流式输出的url地址 然后我们重启springboot浏览器访问 localhost:8181就可以顺利对话了 接入 OpenAI、DeepSeek 等云模型可选 这个部分我就没有继续尝试了因为我想做成本地部署的模型操作自己的文件使用在线大冒险多少会有安全风险感兴趣可以看教程进行探索
http://www.pierceye.com/news/129601/

相关文章:

  • 怎么设立网站赚广告费合肥新站区有做网站的吗
  • 管理系统 网站模板网站建立不安全
  • 模板网站的域名是什么意思百度教育智能小程序
  • 哪里有做配音的兼职网站wordpress菜单图标特效
  • 怎样自创广告网站海南网站建设推广公司哪家好
  • 网站开发团队人员网站建设开票属于什么服务
  • 学做网站初入门教程上海网站建设 觉策动力
  • 丰台建站公司做一个企业网站需要哪些技术
  • 黑色网站模板怎么写app程序
  • 常州建设局网站首页网站开发需求文档模板带er图
  • 网站名称是否已被注册简单的个人主页网站制作
  • 太仓网站开发wordpress留言板
  • 大型营销型网站制作装饰画
  • 移动网站和定制网站个体户 做网站
  • 网站建设的计划书网站源码下载 用户注册
  • 培训网站项目ppt怎么做抖音服务商
  • 做一个网站需要多少钱大概费用wordpress 2017
  • 惠州网页模板建站天河建设网站外包
  • html变Wordpress网络营销优化培训
  • 上海网站建设hxwlkj新浪网站源代码
  • 网站如何做美工想做代理商去哪找项目
  • 佛山市品牌网站建设多少钱印度网站开发成本
  • 群晖 nas 做网站软件开发视频网站
  • 建设银行云南分行招聘网站wordpress 教程
  • 杭州知名的网站制作策略创建一个购物网站需要什么
  • 新乡网站seo优化vs做的网站怎么让局域网的看到
  • 做静态网站怎样让图片自己切换重庆互联网公司排名
  • 微网站需要什么郑州哪家专业做淘宝网站
  • 郑州机械网站制作seo专业优化公司
  • 专注苏州网站优化长沙有哪些知名网站