20240531每日后端------------项目引入Spring Cloud Alibaba AI (一)

Spring Cloud Alibaba AI 简介

Spring Cloud Alibaba AI 目前基于 Spring AI 0.8.1 版本 API 完成通义系列大模型的接入。通义接入是基于阿里云 灵积模型服务,灵积模型服务建立在"模型即服务"(Model-as-a-Service,MaaS)的理念基础之上,围绕 AI 各领域模型,通过标准化的API提供包括模型推理、模型微调训练在内的多种模型服务。

在当前最新版本中,Spring Cloud Alibaba AI 主要完成了几种常见生成式模型的适配,包括对话、文生图、文生语音等,开发者可以使用 Spring Cloud Alibaba AI 开发基于通义的聊天、图片或语音生成 AI 应用,框架还提供 OutParser、Prompt Template、Stuff 等实用能力。

具体官方项目例子可参考:

链接: AI项目

第一步:接入依赖

在项目 pom.xml 中加入 2023.0.1.0 版本 Spring Cloud Alibaba 依赖:

dart 复制代码
 <dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-alibaba-dependencies</artifactId>
      <version>2023.0.1.0</version>
      <type>pom</type>
      <scope>import</scope>
     </dependency>
   </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-starter-alibaba-ai</artifactId>
  </dependency>
</dependencies>

依赖接入后特别坑,下载不了依赖包,,,建议去这里直接下载我准备好的依赖包,本地应用。

链接: spring-ai-core 0.8.1

第二步: 在 application.yml 配置文件中加入以下配置:

dart 复制代码
server:
  port: 8080

spring:
  application:
    name: dive-ai
  cloud:
    ai:
      tongyi:
         # Replace the following key with a valid API-KEY.
         api-key: sk-fbasdasdasdasdasd356asdasdasad5f90

这里的 api-key需要去阿里云官网申请:
申请通义API-KEY

把申请好的key补充到配置文件即可

第三步:正常启动springboot项目即可,效果如下

项目源码以及具体实现后面我会继续解析哈~

相关推荐
zstar-_20 分钟前
【论文阅读】REFRAG:一个提升RAG解码效率的新思路
人工智能
慧一居士39 分钟前
SpringBoot改造MCP服务器(StreamableHTTP)
人工智能
索迪迈科技44 分钟前
安防芯片 ISP 的白平衡统计数据对图像质量有哪些影响?
人工智能·计算机视觉·白平衡
AiTop1001 小时前
腾讯推出AI CLI工具CodeBuddy,国内首家同时支持插件、IDE和CLI三种形态的AI编程工具厂商
ide·人工智能·ai·aigc·ai编程
山楂树下懒猴子1 小时前
ChatAI项目-ChatGPT-SDK组件工程
人工智能·chatgpt·junit·https·log4j·intellij-idea·mybatis
Learn Beyond Limits2 小时前
The learning process of Decision Tree Model|决策树模型学习过程
人工智能·深度学习·神经网络·学习·决策树·机器学习·ai
AI360labs_atyun2 小时前
2025世界智博会,揭幕AI触手可及的科幻生活
人工智能·ai·音视频·生活
luoganttcc2 小时前
小鹏汽车 vla 算法最新进展和模型结构细节
人工智能·算法·汽车
算家计算2 小时前
面壁智能开源多模态大模型——MiniCPM-V 4.5本地部署教程:8B参数开启多模态“高刷”时代!
人工智能·开源
居然JuRan2 小时前
从零开始学大模型之大语言模型
人工智能