feat(xxl-job): 新增AI执行器示例及OllamaChat任务

- 新增AI执行器示例,与Spring AI集成,支持快速开发AI类任务- 添加OllamaChat任务,支持自定义prompt和input等输入信息
- 更新文档,详细说明AI执行器的配置和使用方法
- 在示例项目中添加相关配置属性
3.1.0-release
xuxueli 6 months ago
parent 67da6864d1
commit 6da1e3f9d8

@ -1056,6 +1056,7 @@ public XxlJobSpringExecutor xxlJobExecutor() {
![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_eYrv.png "在这里输入图片标题")
## 三、任务详解
### 配置属性详细说明:
@ -1167,12 +1168,19 @@ public void demoJobHandler() throws Exception {
![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_ZAsz.png "在这里输入图片标题")
#### 原生内置Bean模式任务
为方便用户参考与快速使用示例执行器内原生提供多个Bean模式任务Handler可以直接配置使用如下
#### 原生内置Bean模式任务通用执行器
为方便用户参考与快速使用,提供 “通用执行器” 并内置多个Bean模式任务Handler可以直接配置使用如下
**通用执行器说明:**
- 执行器xxl-job-executor-sample
- 执行器代码:
- xxl-job-executor-sample-springbootspringboot版本
- xxl-job-executor-sample-frameless无框架版本
- demoJobHandler简单示例任务任务内部模拟耗时任务逻辑用户可在线体验Rolling Log等功能
- shardingJobHandler分片示例任务任务内部模拟处理分片参数可参考熟悉分片任务
- httpJobHandler通用HTTP任务Handler业务方只需要提供HTTP链接等信息即可不限制语言、平台。示例任务入参如下
**执行器内置任务列表:**
- a、demoJobHandler简单示例任务任务内部模拟耗时任务逻辑用户可在线体验Rolling Log等功能
- b、shardingJobHandler分片示例任务任务内部模拟处理分片参数可参考熟悉分片任务
- c、httpJobHandler通用HTTP任务Handler业务方只需要提供HTTP链接等信息即可不限制语言、平台。示例任务入参如下
```
{
"url": "http://www.baidu.com",
@ -1180,7 +1188,34 @@ public void demoJobHandler() throws Exception {
"data": "hello world"
}
```
- commandJobHandler通用命令行任务Handler业务方只需要提供命令行即可命令及参数之间通过空格隔开如任务参数 "ls la" 或 "pwd" 将会执行命令并输出数据;
- d、commandJobHandler通用命令行任务Handler业务方只需要提供命令行即可命令及参数之间通过空格隔开如任务参数 "ls la" 或 "pwd" 将会执行命令并输出数据;
#### 原生内置Bean模式任务AI执行器
为方便用户参考与快速使用,提供 “AI执行器” 并内置多个Bean模式任务Handler与spring-ai集成打通支持快速开发AI类任务如下
**AI执行器说明**
- 执行器xxl-job-executor-sample-ai
- 执行器代码xxl-job-executor-sample-springboot-ai
**执行器内置任务列表:**
- a、ollamaJobHandler OllamaChat任务支持自定义prompt、input等输入信息。示例任务入参如下
```
{
"input": "{输入信息,必填信息}",
"prompt": "{模型prompt可选信息}"
}
```
依赖1参考 [Ollama本地化部署大模型](https://www.xuxueli.com/blog/?blog=./notebook/13-AI/%E4%BD%BF%E7%94%A8Ollama%E6%9C%AC%E5%9C%B0%E5%8C%96%E9%83%A8%E7%BD%B2DeepSeek.md) 本文示例部署“qwen2.5:1.5b”模型,也可自定选择其他模型版本。
依赖2启动示例 “AI执行器” 相关配置文件说明如下:
```
### ollama 配置
spring.ai.ollama.base-url=http://localhost:11434
spring.ai.ollama.chat.enabled=true
### Model模型配置注意此处配置模型版本、必须本地先通过ollama进行安装运行。
spring.ai.ollama.chat.options.model=qwen2.5:1.5b
spring.ai.ollama.chat.options.temperature=0.8
```
### 3.3 GLUE模式(Java)
任务以源码方式维护在调度中心支持通过Web IDE在线更新实时编译和生效因此不需要指定JobHandler。开发流程如下
@ -1358,6 +1393,7 @@ try{
![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_1002.png "在这里输入图片标题")
## 五、总体设计
### 5.1 源码目录介绍
- /doc :文档资料
@ -1671,6 +1707,7 @@ XXL-JOB日志主要包含如下两部分均支持日志自动清理说明
针对该问题,调度中心提供内置组件进行处理,逻辑为:调度记录停留在 "运行中" 状态超过10min且对应执行器心跳注册失败不在线则将本地调度主动标记失败
## 六、调度中心/执行器 OpenApi
XXL-JOB 目标是一种跨平台、跨语言的任务调度规范和协议。

@ -29,6 +29,8 @@ xxl.job.executor.logretentiondays=30
### ollama
spring.ai.ollama.base-url=http://localhost:11434
### chat enabled
spring.ai.ollama.chat.enabled=true
### chat modelmust install it locally through ollama
spring.ai.ollama.chat.options.model=qwen2.5:1.5b
spring.ai.ollama.chat.options.temperature=0.8

Loading…
Cancel
Save