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

常州企业网站建设seo外链推广员

常州企业网站建设,seo外链推广员,我想做亚马逊网站怎么做,想给孩子找点题做 都有什么网站目录 一、创建好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/222933.html

相关文章:

  • 西安住房和城乡建设局网站西安seo排名扣费
  • 临朐网站建设价格专门制作小程序的公司
  • 自己在线制作logo免费圆形百度搜索引擎优化方案
  • 做网站的好公司推广方案设计
  • app网站开发河 又精准获客
  • 郑州模板建站平台汕头seo建站
  • photoshop手机版安卓seo快排
  • 淘宝联盟交钱建设网站长春关键词优化报价
  • 关于怎么做网站如何进行网络推广
  • 医药网站建设以网络营销为主题的论文
  • 转业做网站的工具关键词seo报价
  • php网站开发系统线上销售平台都有哪些
  • 周口在线网站建设济南新站seo外包
  • 深互动平台网站seo服务外包
  • 网站首页设计代码百度广告太多
  • 镇江微网站建设网络广告推广平台
  • 厦门网站建设制作工具排名seo怎么样
  • 做公司网站建设价格低百度下载应用
  • html网站地图模板如何推广自己的网站
  • asp网站发布ftp西安seo学院
  • 做网站用phpcms还是网站推广及seo方案
  • php完整电商网站开发源码河南靠谱seo电话
  • 服务号不认证可做微网站吗官方网站营销
  • 金华建设公司网站网络推广公司专业网络
  • 广西钦州有人帮做网站的公司吗网络黄页平台网址有哪些
  • 如何制作个人网页最简单的方法seo是干嘛的
  • 惠州市网站制作有限公司海外aso优化
  • 嘉兴推广网站sem是什么分析方法
  • 建设银行网站首页seo排名点击软件
  • 河北省建设机械协会网站首页广州信息流推广公司