0


Spring AI + 智谱 + 千帆 国内大模型平台对接

Spring AI是基于Spring Boot开发的开源机器学习框架,它可以帮助开发者快速搭建机器学习应用。Spring AI提供了丰富的机器学习算法,包括分类、回归、聚类、降维、推荐系统等,并提供了统一的API接口,开发者可以基于Spring AI轻松实现机器学习应用。

一、智谱平台对接

对接前提:

  1. 平台的Api密钥 : fc9ef92b86d6ed3ae02b5.d6ed3ae0

  2. 平台的调用基址 : https://open.bigmodel.cn/api/paas

注:根据需求去找对应的对接模型

1. 进入智谱官网登录获取平台Api密钥

⬆️点击上边蓝色文字跳转到相应官网

2. 登录后点击右侧Api密钥

3. 进入API keys 界面后可以点击添加新的Api Key 按钮添加,添加后在界面获取添加的Api密钥

4. Java对接

pom.xml引入相关依赖

  1. <dependencies>
  2. <!-- AI dependencies -->
  3. <!-- 智谱 -->
  4. <dependency>
  5. <groupId>org.springframework.ai</groupId>
  6. <artifactId>spring-ai-zhipuai-spring-boot-starter</artifactId>
  7. <version>1.0.0-SNAPSHOT</version>
  8. </dependency>
  9. <!-- AI BOM(Bill of Materials,组件清单) -->
  10. <dependency>
  11. <groupId>org.springframework.ai</groupId>
  12. <artifactId>spring-ai-bom</artifactId>
  13. <version>1.0.0-SNAPSHOT</version>
  14. <type>pom</type>
  15. <scope>import</scope>
  16. </dependency>
  17. </dependencies>
  18. <!-- AI repositories(存储库) -->
  19. <repositories>
  20. <repository>
  21. <id>spring-milestones</id>
  22. <name>Spring Milestones</name>
  23. <url>https://repo.spring.io/milestone</url>
  24. <snapshots>
  25. <enabled>false</enabled>
  26. </snapshots>
  27. </repository>
  28. <repository>
  29. <id>spring-snapshots</id>
  30. <name>Spring Snapshots</name>
  31. <url>https://repo.spring.io/snapshot</url>
  32. <releases>
  33. <enabled>false</enabled>
  34. </releases>
  35. </repository>
  36. </repositories>

application.yml配置智谱的相关配置

  1. spring:
  2. application:
  3. name: ai-demo
  4. # AI配置
  5. ai:
  6. # 智谱AI
  7. zhipuai:
  8. # 智谱API key
  9. api-key: 你的智谱Api密钥
  10. # 模型基础URL
  11. base-url: https://open.bigmodel.cn/api/paas
  12. # 聊天配置
  13. chat:
  14. options:
  15. # 聊天模型
  16. model: glm-4-plus

cont

标签: java ai 人工智能

本文转载自: https://blog.csdn.net/qq_29391129/article/details/143185038
版权归原作者 敲代码的熊先生 所有, 如有侵权,请联系我们删除。

“Spring AI + 智谱 + 千帆 国内大模型平台对接”的评论:

还没有评论