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

网站备案目的网络营销是干嘛的

网站备案目的,网络营销是干嘛的,xps13适合网站开发吗,计算机网站建设实训报告在上一篇概述中(Spring-ai 1.0.0 学习(一)——概述-CSDN博客)大概介绍了spring-ai,接下来我们直接上代码,看一个最小化的spring-ai样例 首先是pom.xml文件,仅需引入spring-boot-starter-web和s…

在上一篇概述中(Spring-ai 1.0.0 学习(一)——概述-CSDN博客)大概介绍了spring-ai,接下来我们直接上代码,看一个最小化的spring-ai样例

首先是pom.xml文件,仅需引入spring-boot-starter-web和spring-ai-starter-model-zhipuai(根据所选大语言模型不同)即可

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.5.0</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.example</groupId><artifactId>spring-ai</artifactId><version>0.0.1-SNAPSHOT</version><name>spring-ai</name><description>Demo project for Spring AI</description><properties><java.version>24</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-starter-model-zhipuai</artifactId><version>1.0.0</version></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

然后是application.properties,仅需配置大语言模型对应的api-key和model即可,your key为在对应大模型网站申请的key

spring.ai.zhipuai.api-key=<your key>
spring.ai.zhipuai.chat.options.model=glm-4-air

然后是启动类SpringAiApplication

package com.example.spring_ai;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class SpringAiApplication {public static void main(String[] args) {SpringApplication.run(SpringAiApplication.class, args);}}

最后是大语言模型调用类SpringAiExample01

package com.example.spring_ai.controller;import org.springframework.ai.zhipuai.ZhiPuAiChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import java.util.Map;@RestController
public class SpringAiExample01
{private final ZhiPuAiChatModel chatModel;@Autowiredpublic SpringAiExample01(ZhiPuAiChatModel chatModel){this.chatModel = chatModel;}/*** 简单调用* @param message* @return*/@GetMapping("/ai/generate")public Map generate(@RequestParam(value = "message", defaultValue = "给我讲个笑话") String message){return Map.of("generation", this.chatModel.call(message));}}

spring会根据我们配置在application.properties中的属性帮我们自动生成ZhiPuAiChatModel

然后我们将程序启动,在浏览器中访问http://localhost:8080/ai/generate​​​​​​?message=介绍下成都​​​​​​,即可观察到大模型返回的结果

这里我使用的智谱的ZhipuAiChatModel,生产中更推荐封装了大语言模型的ChatClient

package com.example.spring_ai.controller;import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class SpringAiExample02ChatClient
{private final ChatClient chatClient;public SpringAiExample02ChatClient(ChatClient.Builder chatClientBuilder){//ChatClient封装了ChatModel,屏蔽了不同底层模型的差异this.chatClient = chatClientBuilder.build();}@GetMapping("/ai")String generation(String userInput){return this.chatClient.prompt().user(userInput).call().content();}}

ChatClient会自动匹配可用的ChatModel,它封装了ChatModel,屏蔽了不同底层模型的差异,方便一键切换底层大模型

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

相关文章:

  • 个人网站建设 免费培训中心
  • 数字营销证书高级seo
  • 宝鸡做网站的南昌seo排名
  • vs2013做网站教程河北优化seo
  • 一图读懂制作网站网站推广平台有哪些
  • 学ui可以做网站么周口网络推广公司
  • 易语言做购物网站优化落实防控措施
  • 中国城乡建设结合部网站怎么建立网站
  • 贵阳有没有网站建设公司怎样通过网络销售自己的产品
  • 自己做的网站怎么添加采集模块百度图片搜索
  • 网上做批发那个网站好seo关键词大搜
  • 济南网站制作工作室百度搜索风云榜明星
  • 网站做跳转的意义软文推广是什么
  • 传奇私服网站做ssl百度搜索引擎下载
  • 制作网站商网站怎么优化排名的方法
  • 六安今天新闻最新消息整站优化要多少钱
  • 哪个网站名片做的号优化推广联盟
  • 装饰工程设计东莞网站建设合肥关键词排名推广
  • 注册公司的条件和费用郑州百度搜索优化
  • 淮北市网站建设接推广app任务的平台
  • 怎样建网站域名查询ip138
  • 有什么网站可以做微信支付宝支付百度seo公司哪家最好
  • 抖音小程序开发工具树枝seo
  • 电商网站建设与运营考试答案安卓优化大师
  • asp做bs网站怎么写网页seo如何优化
  • 网站搜索量查询新品怎么刷关键词
  • 怎样注册自己网站不花钱网站推广
  • 精品资料seo做的好的网站
  • 扬州网站建设外包百度网盘人工申诉电话
  • 什么叫电商怎么做电商正规网站优化公司