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

常州工厂网站建设最好用的搜索引擎排名

常州工厂网站建设,最好用的搜索引擎排名,取公司名字,网站做百度竞价的标志目录 一、创建好Springboot项目 (一)、创建简单的springboot项目 (二)创建一个简单的接口 (三)使用postman调用该接口进行测试 二、注册“阿里云百炼”平台 (一)没有账户的先在…

目录

一、创建好Springboot项目

(一)、创建简单的springboot项目

(二)创建一个简单的接口

(三)使用postman调用该接口进行测试

二、注册“阿里云百炼”平台

(一)没有账户的先在阿里云百炼注册

(二)创建api-key

(三)获取api-key

(四)获取模型名称

(三)项目集成Ai模型

(一)pom文件加入依赖

(二)controller代码更改

(三)启动类加入ChatMemory   Bean

(四)yml添加配置apiKey和模型名称


一、创建好Springboot项目

(一)、创建简单的springboot项目

要使用springboot的3.4.2版本,jdk使用17

我的项目名为testAi

pom文件内容如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>testAi</artifactId><version>1.0-SNAPSHOT</version><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.4.2</version><relativePath/></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><jdk>17</jdk></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional><version>1.18.20</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>2.4</version><configuration><excludes><exclude>*</exclude></excludes></configuration></plugin></plugins><resources><resource><directory>src/main/resources</directory></resource></resources></build>
</project>

(二)创建一个简单的接口

(三)使用postman调用该接口进行测试

二、注册“阿里云百炼”平台

(一)没有账户的先在阿里云百炼注册

地址:百炼控制台

(二)创建api-key

按下列四步创建出一个api-key

(三)获取api-key

点击查看,然后可获取apiKey

(四)获取模型名称

点击模型广场,然后选择DeepSeek,最后在筛选结果点击“查看详情”

然后选择“deepseek-r1”

(三)项目集成Ai模型

(一)pom文件加入依赖

        <dependency><groupId>com.alibaba.cloud.ai</groupId><artifactId>spring-ai-alibaba-starter</artifactId><version>1.0.0-M3.3</version></dependency>------------------------------------------------------<dependencyManagement><dependencies><dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-bom</artifactId><version>1.0.0-M3</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><repositories><repository><id>spring-milestone-repo</id><url>https://repo.spring.io/milestone</url></repository></repositories>

(二)controller代码更改

package org.example.controller;import org.example.api.req.CallAiReq;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.AbstractChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.PromptChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;@RestController
public class CallAiController {ChatClient chatClient;public CallAiController(ChatClient.Builder chatClientBuilder, ChatMemory chatMemory){this.chatClient = chatClientBuilder.defaultAdvisors(new PromptChatMemoryAdvisor(chatMemory)).build();}@RequestMapping("/callAi")public Flux<String> callAi(@RequestBody CallAiReq req){System.out.println("入参=" + req.getMessage());Flux<String> content = chatClient.prompt().user(req.getMessage()).advisors(a -> a.param(AbstractChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY, 100)).stream().content();return content;}}

(三)启动类加入ChatMemory   Bean

package org.example;import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;@SpringBootApplication
public class TestAiApplication {public static void main(String[] args) {SpringApplication.run(TestAiApplication.class, args);}@Beanpublic ChatMemory chatMemory(){return new InMemoryChatMemory();}
}

(四)yml添加配置apiKey和模型名称

根据第二步中的(三)和(四)获取的apiKey和模型名称加入配置文件中

server:port: 8100spring:ai:dashscope:api-key: sk-**************************38(替换自己的)chat:options:model: deepseek-r1

这块代码是有前面对话的记忆

结束!

http://www.dtcms.com/wzjs/60164.html

相关文章:

  • 网站建设优化公司哪家好宁德市人社局官网
  • 网站空间商盗取数据百度搜索网页版
  • 不常见的网络营销方式安卓优化神器
  • 高仿做的最好的网站免费的企业黄页网站
  • 网站建设制作公司地址外贸网站营销推广
  • 昆明手机网站推荐百度浏览器网址大全
  • 门户网站建设经验总结报告网络营销专业学什么课程
  • 现在一般做B2B类网站用vue百度seo优化怎么做
  • 做网站图片怎么找b2b外贸接单平台
  • 多页网站制作中国十大电商公司排名
  • 网站建设的编程语言怎么自己制作网页
  • 产品推荐词seo要点
  • 平台网站建设需要什么技术最好的免费建站网站
  • 中小企业加盟网站建设wordpress企业网站模板
  • 上海网站建设 知名做百度推广平台有哪些
  • 手机网站怎么做推广网络营销专员的就业前景
  • java做的视频网站百度指数app官方下载
  • 海外网站建设推广免费推广网站推荐
  • 网站开发需要学些什么?免费域名申请的方法
  • 网站建设教程最新资讯百度站长工具官网
  • 吉林企业建站系统费用营销技巧培训ppt
  • 网站开发包括软件吗网站设计与制作毕业论文范文
  • 有没有哪个网站怎么做动漫新闻的互联网广告投放公司
  • 免费论坛建站排行榜网站
  • 网站建设:上海珍岛湖南网站网络推广哪家奿
  • 网站支付的功能如何做怎么做网站链接
  • 电子商务网站建设与管理课程评价高级seo是什么职位
  • 如何建立搜索功能的网站seo是什么意思新手怎么做seo
  • 网站备案后证书软文推广渠道
  • 五金日杂店做网站最新国际新闻头条新闻