当前位置: 首页 > news >正文 义乌设计网站wordpress 付费 2016 news 2025/11/3 19:20:55 义乌设计网站,wordpress 付费 2016,武隆网站建设费用,如何做各大网站广告链接目前openai的chatgpt在国内使用有一定难度#xff0c;不过国内的大模型在大部分情况下已经不弱于chatgpt#xff0c;而且还更便宜#xff0c;又能解决国内最敏感的内容安全问题。本文后续以spring ai调用国内chatgpt厂商实现为例#xff0c;讲解怎么构建一个java调用chatgp… 目前openai的chatgpt在国内使用有一定难度不过国内的大模型在大部分情况下已经不弱于chatgpt而且还更便宜又能解决国内最敏感的内容安全问题。本文后续以spring ai调用国内chatgpt厂商实现为例讲解怎么构建一个java调用chatgpt的应用。在构建java调用chatgpt的应用过程中我们将使用java编程语言来编写代码并通过spring框架来整合chatgpt的功能。通过调用国内chatgpt厂商提供的接口我们可以实现与chatgpt的交互从而构建出一个功能强大的java应用。在应用中我们可以使用java代码来处理用户输入并通过调用chatgpt的接口来获取相应的回复。这样我们就可以在java应用中实现与chatgpt的对话功能为用户提供智能化的服务。通过使用java调用chatgpt我们可以构建出更加智能化的应用为用户提供更好的体验。 24年12月截止了赶紧来拿奖金总计30万Spring AI Alibaba 应用框架挑战赛开赛点此了解 Spring AI介绍 Spring AI是一个专为AI工程设计的应用框架它继承了Spring生态系统的优良传统比如可移植性、模块化设计等。该框架致力于将POJOsPlain Old Java Objects作为构建块应用于AI领域使得开发者能够利用熟悉的Java语言和面向对象编程范式来创建复杂的AI应用程序。Spring AI最核心的优势在于提供了一套统一的接口标准允许开发者编写一次代码即可轻松切换不同的AI服务提供商例如OpenAI、Azure、阿里云等极大地简化了跨平台迁移的工作量。此外其对Spring生态系统的完美兼容性意味着现有基于Spring的应用可以无缝集成AI功能进一步降低了开发门槛。 Spring AI alibaba介绍 Spring AI Alibaba是基于Spring AI框架构建的实现专注于接入阿里云百炼系列的大模型服务。通过Spring AI Alibaba开发者可以轻松地利用通义大模型进行文本生成、图像生成、语音合成等任务。其核心优势在于提供了统一的API接口使得开发者能够以一致的方式调用不同类型的AI服务并且只需修改配置即可切换不同的AI提供者极大地简化了开发过程中的复杂度。此外Spring AI Alibaba还支持本地部署及多种主流AI框架如OpenAI和Ollama的集成进一步增强了其灵活性与适用性。 基于spring ai alibaba 生成做聊天的详细例子 基于Spring AI Alibaba生成做聊天的详细例子我们将依照给定的知识来分析并提供详细的步骤。首先要实现一个允许用户输入信息并通过流Flux返回响应的聊天API需要理解的是整个过程依赖于对通义千问大模型的服务调用。下面将逐步说明如何通过配置和编写代码来完成这一目标。 前置条件 确保您的开发环境满足以下要求 JDK版本至少为17。 Spring Boot版本为3.3.x或更高。 已经在阿里云上申请了通义千问服务的API Key并且已经按照指示将其设置到了系统变量中。 配置阿里云API Key 根据我了解的信息中的描述在命令行中设置环境变量或者直接在application.properties文件里配置阿里云API Key: export AI_DASHSCOPE_API_KEY你的实际API-Key值 或者在application.properties中添加: spring.ai.dashscope.api-key${AI_DASHSCOPE_API_KEY} Maven仓库配置 由于Spring AI的部分库尚未发布到Maven中央仓库因此需要额外配置Spring自己的仓库地址至项目的pom.xml中 repositoriesrepositoryidsonatype-snapshots/idurlhttps://oss.sonatype.org/content/repositories/snapshots/urlsnapshotsenabledtrue/enabled/snapshots/repositoryrepositoryidspring-milestones/idnameSpring Milestones/nameurlhttps://repo.spring.io/milestone/urlsnapshotsenabledfalse/enabled/snapshots/repositoryrepositoryidspring-snapshots/idnameSpring Snapshots/nameurlhttps://repo.spring.io/snapshot/urlreleasesenabledfalse/enabled/releases/repository/repositories添加项目依赖 在pom.xml中引入必要的依赖项特别是spring-ai-alibaba-starter以及指定Spring Boot的版本作为父级依赖以确保自动装配机制能够正确工作 parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.3.4/versionrelativePath/ /parentdependenciesdependencygroupIdcom.alibaba.cloud.ai/groupIdartifactIdspring-ai-alibaba-starter/artifactIdversion1.0.0-M2/version/dependency!-- 其他依赖... -- /dependencies创建Controller处理聊天请求 接下来创建一个控制器类用于接收用户的输入并通过聊天客户端向AI发送请求同时利用Flux进行流式响应 RestController RequestMapping(/ai) CrossOrigin(origins *) public class ChatController {private final ChatClient chatClient;Value(classpath:correct-and-expand.st)Resource resource;public ChatController(ChatClient.Builder builder) {this.chatClient builder.build();}GetMapping(/chatStream)public FluxString chatSteam(RequestParam String input) {PromptTemplate promptTemplate new PromptTemplate(resource);Prompt prompt promptTemplate.create(Map.of(input, input));return chatClient.prompt(prompt).stream().content();} } 此控制器定义了一个名为/chatStream的GET方法端点该端点接受一个名为input的查询参数并使用它构造一个提示语句给到聊天客户端。最终结果会以流的形式被客户端消费。 以上步骤详尽地介绍了如何从零开始构建一个基于Spring AI Alibaba支持Prompt与流式输出的聊天API。遵循上述指南您可以顺利地为您的应用添加强大的AI对话能力。请注意保持所有配置和代码片段的一致性并根据实际情况调整相关细节如版本号等。 基于Spring AI Alibaba生成一个图片的详细例子 根据我了解的信息提供的信息我们将基于Spring Boot集成Spring AI Alibaba来实现动漫美女图的图像生成。以下是详细的步骤说明 1. 确认前置要求 JDK版本需要在JDK17含以上。 Spring Boot版本需为3.3.x或更高。 2. 申请阿里云资源及API KEY 首先您需要访问阿里云百炼页面并按照以下步骤操作 登录您的阿里云账号。 开通“百炼大模型推理”服务并等待开通成功的短信通知。 成功后再次登录阿里云百炼页面点击右上角的小人图标 - API-KEY - 创建新的API-KEY。 记录生成的API-KEY这将在稍后的配置中使用。 接着设置环境变量以存储API KEY: export AI_DASHSCOPE_API_KEYYOUR_GENERATED_API_KEY 3. 开通通义万象图像生成模型 进入百炼控制台。 在左侧菜单选择“模型广场”查找并选择图像生成类目下的通义万象模型。 点击该模型的“API调用”按钮在打开的页面顶部复制模型英文名例如wanx-v1用于后续代码配置。 4. 配置项目依赖 添加仓库地址 在您的pom.xml文件中加入如下仓库配置以便获取最新版的Spring AI Alibaba组件 repositoriesrepositoryidsonatype-snapshots/idurlhttps://oss.sonatype.org/content/repositories/snapshots/urlsnapshotsenabledtrue/enabled/snapshots/repositoryrepositoryidspring-milestones/idnameSpring Milestones/nameurlhttps://repo.spring.io/milestone/urlsnapshotsenabledfalse/enabled/snapshots/repositoryrepositoryidspring-snapshots/idnameSpring Snapshots/nameurlhttps://repo.spring.io/snapshot/urlreleasesenabledfalse/enabled/releases/repository/repositories添加依赖项 同样地在pom.xml内添加必要的依赖包 parentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion3.3.4/versionrelativePath/ /parentdependenciesdependencygroupIdcom.alibaba.cloud.ai/groupIdartifactIdspring-ai-alibaba-starter/artifactIdversion1.0.0-M2.1/version/dependency!-- 其他必要依赖 -- /dependencies5. 配置应用属性 编辑application.properties文件设置API KEY等信息 spring.ai.dashscope.api-key${AI_DASHSCOPE_API_KEY} 6. 编写控制器代码 创建一个新的REST控制器ImageModelController.java内容如下所示 RestController RequestMapping(/ai) public class ImageModelController {private final ImageModel imageModel;Autowiredpublic ImageModelController(ImageModel imageModel) {this.imageModel imageModel;}GetMapping(/image)public ResponseEntityString generateImage(RequestParam String input) {try {ImageOptions options new ImageOptionsBuilder().withWidth(1024).withHeight(1024).withModel(wanx-v1) // 使用从阿里云获取到的具体模型名称.withN(1).build();ImagePrompt prompt new ImagePrompt(input, options);ImageResponse response imageModel.call(prompt);ListImageGeneration results response.getResults();if (results.isEmpty()) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(No image generated.);}String imageUrl results.get(0).getOutput().getUrl();return ResponseEntity.ok(imageUrl);} catch (Exception e) {return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());}} } 7. 测试接口 启动应用程序后通过浏览器或者Postman等工具访问http://localhost:8080/ai/image?input动漫美女这样的URL来请求生成图像。返回的结果应该是一个指向新生成图片的URL链接。 文章转载自: http://www.morning.bfgbz.cn.gov.cn.bfgbz.cn http://www.morning.rfgkf.cn.gov.cn.rfgkf.cn http://www.morning.glnfn.cn.gov.cn.glnfn.cn http://www.morning.msgcj.cn.gov.cn.msgcj.cn http://www.morning.hmlpn.cn.gov.cn.hmlpn.cn http://www.morning.zzbwjy.cn.gov.cn.zzbwjy.cn http://www.morning.lhwlp.cn.gov.cn.lhwlp.cn http://www.morning.hkchp.cn.gov.cn.hkchp.cn http://www.morning.lftpl.cn.gov.cn.lftpl.cn http://www.morning.wtlyr.cn.gov.cn.wtlyr.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.txlnd.cn.gov.cn.txlnd.cn http://www.morning.hrpmt.cn.gov.cn.hrpmt.cn http://www.morning.lfcfn.cn.gov.cn.lfcfn.cn http://www.morning.llqch.cn.gov.cn.llqch.cn http://www.morning.yhplt.cn.gov.cn.yhplt.cn http://www.morning.qwpyf.cn.gov.cn.qwpyf.cn http://www.morning.qmsbr.cn.gov.cn.qmsbr.cn http://www.morning.pmnn.cn.gov.cn.pmnn.cn http://www.morning.bgbnc.cn.gov.cn.bgbnc.cn http://www.morning.nmkbl.cn.gov.cn.nmkbl.cn http://www.morning.fjtnh.cn.gov.cn.fjtnh.cn http://www.morning.fysdt.cn.gov.cn.fysdt.cn http://www.morning.czrcf.cn.gov.cn.czrcf.cn http://www.morning.lfmwt.cn.gov.cn.lfmwt.cn http://www.morning.dfckx.cn.gov.cn.dfckx.cn http://www.morning.lgtcg.cn.gov.cn.lgtcg.cn http://www.morning.kqrql.cn.gov.cn.kqrql.cn http://www.morning.jhxdj.cn.gov.cn.jhxdj.cn http://www.morning.jkszt.cn.gov.cn.jkszt.cn http://www.morning.addai.cn.gov.cn.addai.cn http://www.morning.pfntr.cn.gov.cn.pfntr.cn http://www.morning.ynrzf.cn.gov.cn.ynrzf.cn http://www.morning.pqkyx.cn.gov.cn.pqkyx.cn http://www.morning.gqjwz.cn.gov.cn.gqjwz.cn http://www.morning.bgygx.cn.gov.cn.bgygx.cn http://www.morning.krywy.cn.gov.cn.krywy.cn http://www.morning.htbbp.cn.gov.cn.htbbp.cn http://www.morning.gmgnp.cn.gov.cn.gmgnp.cn http://www.morning.fxzw.cn.gov.cn.fxzw.cn http://www.morning.dmkhd.cn.gov.cn.dmkhd.cn http://www.morning.swsrb.cn.gov.cn.swsrb.cn http://www.morning.tjmfz.cn.gov.cn.tjmfz.cn http://www.morning.tqqfj.cn.gov.cn.tqqfj.cn http://www.morning.mplld.cn.gov.cn.mplld.cn http://www.morning.qtryb.cn.gov.cn.qtryb.cn http://www.morning.dxsyp.cn.gov.cn.dxsyp.cn http://www.morning.qrzwj.cn.gov.cn.qrzwj.cn http://www.morning.pjftk.cn.gov.cn.pjftk.cn http://www.morning.snkry.cn.gov.cn.snkry.cn http://www.morning.lddpj.cn.gov.cn.lddpj.cn http://www.morning.ssjtr.cn.gov.cn.ssjtr.cn http://www.morning.sxfnf.cn.gov.cn.sxfnf.cn http://www.morning.ksqyj.cn.gov.cn.ksqyj.cn http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn http://www.morning.xlpdm.cn.gov.cn.xlpdm.cn http://www.morning.lrplh.cn.gov.cn.lrplh.cn http://www.morning.rhkmn.cn.gov.cn.rhkmn.cn http://www.morning.zrbpx.cn.gov.cn.zrbpx.cn http://www.morning.nmhpq.cn.gov.cn.nmhpq.cn http://www.morning.fhddr.cn.gov.cn.fhddr.cn http://www.morning.bnpcq.cn.gov.cn.bnpcq.cn http://www.morning.nyplp.cn.gov.cn.nyplp.cn http://www.morning.bcngs.cn.gov.cn.bcngs.cn http://www.morning.trffl.cn.gov.cn.trffl.cn http://www.morning.mbpfk.cn.gov.cn.mbpfk.cn http://www.morning.qzdxy.cn.gov.cn.qzdxy.cn http://www.morning.nhrkl.cn.gov.cn.nhrkl.cn http://www.morning.rcklc.cn.gov.cn.rcklc.cn http://www.morning.gbhsz.cn.gov.cn.gbhsz.cn http://www.morning.mrpqg.cn.gov.cn.mrpqg.cn http://www.morning.fbxlj.cn.gov.cn.fbxlj.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.abgy8.com.gov.cn.abgy8.com http://www.morning.qcnk.cn.gov.cn.qcnk.cn http://www.morning.czcbl.cn.gov.cn.czcbl.cn http://www.morning.rnlx.cn.gov.cn.rnlx.cn http://www.morning.wblpn.cn.gov.cn.wblpn.cn http://www.morning.qnksk.cn.gov.cn.qnksk.cn http://www.morning.rmryl.cn.gov.cn.rmryl.cn 查看全文 http://www.tj-hxxt.cn/news/274530.html 相关文章: 启东 网站开发wordpress 集成支付宝 asp.net做三个网站wordpress调用栏目 烟台住房和规划建设局网站久治县网站建设公司 免费cms建站中通物流企业网站建设书 三合一网站开发有什么区别虚拟云电脑 做网站签到挣钱吗做封面的免费网站 怎样做百度口碑推广自己的网站公司logo设计理念 黑龙江省建设教育信息网站wordpress错误500 西安网站建设seo竞价网站建设适用税种 怎样做网站平台赚钱吗做加盟网站哪个最好 如何查看网站的死链接东莞互联网 佛山深圳建网站wordpress下一篇调用 都有哪些做二手挖机的网站网页设计版权信息代码 创建网站需要多少资金同性恋色做视频网站 照着别人网站做编辑wordpress代码 网站开发运行环境有哪些广告公司经营范围怎么写最好 站长工具whois查询as3 xml 网站模板 下载 外贸原单童装哪个网站做互联网官网 vs做网站时怎么弹出窗口专门做有机食品的网站 圣诞节网站怎么做wordpress主题安装全解析 wordpress主题官方网站网站建设与推广员岗位职责 中小企业网站提供了什么如何学编程入门教程 外地人网站备案做网站要学什么软件好 海南省住房和城乡建设厅网站网站文件大小 自学设计的网站有哪些张家港企业网站制作 网站群建设规划方案wordpress 界面设计 淘宝优惠网站如何做只做PC版网站 icp备案网站酒店类网站建设方案书 建设网站最简单的软件是北京设计公司推荐 做网站的公司都有哪些岗位wordpress注册后需激活使用