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

【javaAI】SpringAI快速入门

依赖导入

<dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-ollama-spring-boot-starter</artifactId><version>1.0.0-M6</version>
</dependency>

编写配置

spring:application:name: spring-aiai:ollama:base-url: http://localhost:11434chat:model: deepseek-r1:7b

初始化写模型参数bean

@Bean
public ChatMemory chatMemory() {return new InMemoryChatMemory();
}@Bean
public ChatClient chatClient(OllamaChatModel model, ChatMemory chatMemory) {return ChatClient.builder(model)// 给 ai 一个身份.defaultSystem("你是一个博学的智能聊天助手,请根据用户提问回答!").defaultAdvisors(new SimpleLoggerAdvisor(),new MessageChatMemoryAdvisor(chatMemory)).build();
}

基础对话验证

在这里插入图片描述

再次对话,验证会话记忆

在这里插入图片描述

新建打开一个浏览器,验证会话不会冲突

在这里插入图片描述

小功能完结撒花,至此一个简单的对话机器人就实现了

完整代码请跳转仓库:
gitee地址:https://gitee.com/lndsnx/java-ai

http://www.lqws.cn/news/590113.html

相关文章:

  • 【C#】如果有一个数值如 168.0000100,如何去除末尾的无效零,只显示有效的小数位数,让DeepSeek给我们解答
  • 半加器和全加器
  • Disruptor架构哲学
  • 【机器学习2】正则化regularizaiton(降低模型过拟合)
  • 设备管理的11个指标、七大误区、六大特征
  • muduo
  • 数据结构——线性表的链式存储
  • QT笔记---环境和编译出现的问题
  • Golang的代码结构设计原则与实践与模式应用
  • helm安装配置jenkins
  • 百度轮岗:任命新CFO,崔珊珊退居业务二线
  • Redis-7.4.3-Windows-x64下载安装使用
  • 时空数据挖掘五大革新方向详解篇!
  • 我认知的AI宇宙系列第三期
  • 强化学习概述及学习流程
  • 3D词云图
  • 虚拟机配置过程中的知识点
  • shardingsphere5.2.1与SpringBoot3.X的版本冲突问题
  • 华为云Flexus+DeepSeek征文 | ​​华为云ModelArts Studio大模型与企业AI会议纪要场景的对接方案
  • 具身智能环境的构建和工作(具身智能入门四)
  • Oracle 进阶语法实战:从多维分析到数据清洗的深度应用​(第四课)
  • 贪心算法在C++中的应用与实践
  • Monorepo+Pnpm+Turborepo
  • 数据结构:链表
  • 认识 Spring AI
  • 华为云Flexus+DeepSeek征文|基于华为云Flexus云服务的Dify 快速构建联网搜索助手
  • Zookeeper安装使用教程
  • 产品背景知识——API、SDK、Library、Framework、Protocol
  • guava限流器RateLimiter源码详解
  • SpringBoot -- 自动配置原理