### Run Chatbot Example with Maven Wrapper Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/README.md Execute this command to build and run the chatbot example. Maven installation is optional if you use the Maven Wrapper (mvnw). ```shell # Maven installation is optional when using mvnw. ./mvnw -pl examples/chatbot spring-boot:run ``` -------------------------------- ### Run Multimodal Example Application Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multimodal/README.md Commands to execute the multimodal example project using Maven. ```bash ./mvnw -pl examples/multimodal spring-boot:run ``` ```bash AI_DASHSCOPE_API_KEY=your_key ./mvnw -pl examples/multimodal spring-boot:run ``` -------------------------------- ### Build and Run AgentScope Examples Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/agentscope/handoffs/README.md Commands to install the required agent framework and build the multi-agent example project using Maven. ```bash # Install agent-framework to local Maven repo ./mvnw -pl spring-ai-alibaba-agent-framework -am -B install -DskipTests # Build the example cd examples/multiagent-patterns/agentscope ../../../../mvnw -B package -DskipTests # Run the application ./mvnw spring-boot:run ``` -------------------------------- ### Start Frontend Service Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/README-zh.md Launch the development server for the frontend application. ```bash cd packages/main npm run dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/frontend/README.zh-CN.md Commands to install development and project-wide dependencies. ```bash npm install rimraf copyfiles --save-dev ``` ```bash npm run re-install ``` -------------------------------- ### Start Backend Service Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/README-zh.md Launch the Spring Boot application from the server-start directory. ```bash mvn spring-boot:run ``` -------------------------------- ### Start Middleware Services Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/README-zh.md Execute the startup script to initialize required infrastructure like MySQL, Elasticsearch, Nacos, Redis, and RocketMQ. ```bash cd docker/middleware sh run.sh ``` -------------------------------- ### Bash Build and Run Commands Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/handoffs-multiagent/README.md Provides bash commands for building the project using Maven and running the application. Includes options for running with the demo enabled or starting the app for manual interaction. ```bash # Navigate to the module directory cd examples/multi-agent-patterns/handoffs-multiagent # Build the project, skipping tests ./mvnw -B package -DskipTests # Run the app with the demo enabled (set env var or in application.yml) export HANDOFFS_RUNNER_ENABLED=true java -jar target/handoffs-multiagent-0.0.1-SNAPSHOT.jar # Or run without the demo runner ./mvnw spring-boot:run ``` -------------------------------- ### Environment Variable Configuration File Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/frontend/README.zh-CN.md Example content for the .env configuration file. ```text # 后端接口的 Host WEB_SERVER="http://127.0.0.1:8080" # 后端语言类型(部分功能会根据实现不同略有不同,比如 java、python) BACK_END="java" # 默认账号 DEFAULT_USERNAME=saa # 默认密码 DEFAULT_PASSWORD=123456 ``` -------------------------------- ### Run ChatBot Application Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/chatbot/README.md Execute the ChatBot example using the Maven wrapper from the repository root. ```shell # Run from repository root. ./mvnw -pl examples/chatbot spring-boot:run ``` -------------------------------- ### Start Middleware and Application Services Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/README.md Commands to start the required infrastructure middleware, the Spring Boot backend, and the frontend development server. ```bash # Start middleware cd docker/middleware sh run.sh # Start backend cd spring-ai-alibaba-admin-server-start mvn spring-boot:run # Start frontend cd packages/main npm run dev ``` -------------------------------- ### Clone and Run Standalone Chat UI Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-studio/README.md Step-by-step commands to clone the repository, install dependencies using pnpm, and start the standalone development environment. ```bash git clone https://github.com/alibaba/spring-ai-alibaba.git cd spring-ai-alibaba/spring-ai-alibaba-studio/agent-chat-ui pnpm install pnpm dev ``` -------------------------------- ### Initialize and Run Spark Flow Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/frontend/packages/spark-flow/README.md Commands to install project dependencies and start the development environment for the Spark Flow package. ```shell npm run re-install && cd packages/spark-flow && npm start ``` -------------------------------- ### Start Chat UI Development Server Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-studio/README.md Commands to install dependencies and launch the development server for the Agent Chat UI. This is required for the standalone mode of the application. ```shell npm install npm run dev ``` -------------------------------- ### Maven Build Command Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md This command builds the Spring Boot application for the routing example using Maven. It specifies the module (`:routing`), ensures all necessary parent modules are also built (`-am`), packages the application, and skips running tests to speed up the build process. ```bash ./mvnw -pl :routing -am -B package -DskipTests ``` -------------------------------- ### Clone and Initialize Spring AI Alibaba Admin Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/README.md Commands to clone the repository and navigate to the project directory to begin the installation process. ```bash git clone https://github.com/spring-ai-alibaba/spring-ai-alibaba-admin.git cd spring-ai-alibaba-admin ``` -------------------------------- ### Run Skills Application (Default) Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/README.md Execute the built JAR file to run the skills application. By default, the application starts without running the demo. ```bash java -jar target/skills-0.0.1-SNAPSHOT.jar ``` -------------------------------- ### Install Dependencies (pnpm/npm) Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-studio/agent-chat-ui/README.md Instructions for installing project dependencies using either pnpm or npm package managers. ```bash pnpm install # or # npm install ``` -------------------------------- ### Run Skills Application with Maven (Default) Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/README.md Run the skills application using the Maven wrapper, starting without the demo. This is an alternative to running the JAR directly. ```bash ./mvnw -pl :skills spring-boot:run ``` -------------------------------- ### Run Multi-Agent Example in Interactive Mode (Bash) Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/subagent/README.md Provides instructions to run the multi-agent example in interactive mode from the project root. It requires JDK 17+ and the AI_DASHSCOPE_API_KEY environment variable to be set. ```bash # From project root - run with interactive chat cd /path/to/spring-ai-alibaba AI_DASHSCOPE_API_KEY=your_key ./mvnw -f examples/multiagent-patterns/subagent/pom.xml spring-boot:run \ -Dspring-boot.run.arguments="--subagent.run-interactive=true" ``` -------------------------------- ### Bash: Build and Run Spring Boot Application Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/handoffs-singleagent/README.md Commands to build the Spring Boot application using Maven Wrapper and then run it. The application can be configured to run a four-turn demo on startup by setting an environment variable or a configuration property. ```bash # Navigate to the module directory cd examples/multiagent-patterns/handoffs-singleagent # Build the application, skipping tests ./mvnw -B package -DskipTests # Run the application (default behavior, no demo) java -jar target/handoffs-singleagent-0.0.1-SNAPSHOT.jar # Or run using Maven (default behavior, no demo) ./mvnw spring-boot:run # To run the four-turn demo on startup, set the environment variable: export HANDOFFS_RUN_EXAMPLES=true java -jar target/handoffs-singleagent-0.0.1-SNAPSHOT.jar # Alternatively, set handoffs.run-examples=true in application.yml ``` -------------------------------- ### Run Development Server (pnpm/npm) Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-studio/agent-chat-ui/README.md Commands to start the development server for the Agent Chat UI using pnpm or npm. ```bash pnpm dev # or # npm run dev ``` -------------------------------- ### Running the Routing Application Demo Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md This command runs the Spring Boot application with the demo enabled. When `routing.runner.enabled` is set to true (either via environment variable or application.yml), the application will execute a predefined query upon startup and log the classifications and the final synthesized answer. ```bash export routing.runner.enabled=true java -jar target/routing-0.0.1-SNAPSHOT.jar ``` -------------------------------- ### Set DashScope API Key Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/README.md Before running the chatbot example, set your Aliyun DashScope API key as an environment variable. Visit Aliyun Bailian to obtain your API key. ```shell # this example uses 'spring-ai-alibaba-starter-dashscope', visit https://java2ai.com to learn how to use OpenAI/DeepSeek. export AI_DASHSCOPE_API_KEY=your-api-key ``` -------------------------------- ### Clone and Navigate Spring AI Alibaba Repository (Bash) Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-studio/agent-chat-ui/README.md Commands to clone the spring-ai-alibaba repository and navigate into the agent-chat-ui directory for standalone setup. ```bash git clone https://github.com/alibaba/spring-ai-alibaba.git cd spring-ai-alibaba/spring-ai-alibaba-studio/agent-chat-ui ``` -------------------------------- ### 远程服务连接与部署更新 Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/CONFIGURATION.md 常见问题场景下的配置覆盖与 Kubernetes 滚动更新命令。 ```bash export SPRING_DATASOURCE_URL="jdbc:mysql://remote-host:3306/admin?..." mvn spring-boot:run ``` ```bash kubectl apply -f deploy/backend/backend-deployment.yaml kubectl rollout restart deployment/spring-ai-admin-server -n spring-ai-admin ``` -------------------------------- ### Clone the Project Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/README-zh.md Initial step to download the source code from the repository. ```bash git clone https://github.com/spring-ai-alibaba/spring-ai-alibaba-admin.git cd spring-ai-alibaba-admin ``` -------------------------------- ### Enable Skills Runner Demo Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/README.md Set the 'skills.runner.enabled' environment variable to true to run the demo on startup. The demo executes a predefined user query and logs the assistant's SQL response. ```bash export skills.runner.enabled=true ``` -------------------------------- ### Build Skills Module from Directory Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/README.md Navigate to the skills directory and build the module using Maven. This command also skips tests. ```bash cd examples/multiagents/skills mvn -B package -DskipTests ``` -------------------------------- ### 故障排查命令 Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/deploy/docker-compose/README.md 针对常见问题(如 MySQL 初始化、ES 内存、后端启动、端口冲突)的排查指令。 ```bash # 检查 MySQL 日志 docker logs spring-ai-admin-mysql # 确保初始化脚本存在 ls -la ../../docker/middleware/init/mysql/ ``` ```bash # 调整 ES_JAVA_OPTS(修改 docker-compose-service.yaml) - "ES_JAVA_OPTS=-Xms512m -Xmx512m" # 降低内存使用 ``` ```bash # 查看后端日志 docker logs -f spring-ai-admin-backend # 检查环境变量是否正确传递 docker exec spring-ai-admin-backend env | grep SPRING ``` ```bash # 检查端口占用 lsof -i :8080 # 修改 docker-compose-service.yaml 中的端口映射 ports: - "8081:8080" # 改为其他端口 ``` -------------------------------- ### Build Project for Deployment Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/frontend/README.zh-CN.md Command to build the project for a Java backend environment. ```bash # 如果后端是 java npm run build:subtree:java ``` -------------------------------- ### YAML Configuration for Handoffs Runner Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/handoffs-multiagent/README.md Configuration snippet for enabling or disabling the multi-agent handoffs demo runner. This can be set in application.yml or as an environment variable. ```yaml # Enable the demo runner on startup handoffs: runner: enabled: true # Alternatively, set as an environment variable: # export HANDOFFS_RUNNER_ENABLED=true ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/frontend/README.zh-CN.md Commands to navigate to the main package and copy the environment configuration file. ```bash cd packages/main ``` ```bash cp .env.example .env ``` ```bash Copy-Item .env.example .env ``` -------------------------------- ### Commit Message Format Example Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/CONTRIBUTING.md Use this format for commit messages to ensure compliance with PR specifications. The 'type' can be feat, fix, docs, chore, etc., and 'module' specifies the affected part of the project. ```bash git commit -m "type(module): descriptive message" ``` ```bash feat(docs): update contribute-zh ``` -------------------------------- ### WebSocket Voice Agent Interaction Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/voice-agent/README.md Example of sending text input to the voice agent via WebSocket and handling the streaming JSON response events. ```javascript const ws = new WebSocket('ws://localhost:8080/voice/ws'); ws.onopen = () => ws.send(JSON.stringify({text: "One turkey sandwich"})); ws.onmessage = (e) => { const ev = JSON.parse(e.data); if (ev.type === 'agent_chunk') process.stdout.write(ev.text); if (ev.type === 'tts_chunk') { /* decode base64, play audio */ } }; ``` -------------------------------- ### Enable Interactive Mode via application.yml Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/subagent/README.md Configures the multi-agent example to run in interactive mode by setting the 'subagent.run-interactive' property to 'true' in the application.yml file. ```yaml subagent: run-interactive: true ``` -------------------------------- ### Docker 容器运行配置 Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/CONFIGURATION.md 在 Docker 运行时通过 -e 参数覆盖环境变量。 ```bash docker run -d \ -e SPRING_DATASOURCE_URL="jdbc:mysql://mysql-host:3306/admin?..." \ -e SPRING_REDIS_HOST="redis-host" \ -e SPRING_ELASTICSEARCH_URIS="http://es-host:9200" \ -e NACOS_SERVER_ADDR="nacos-host:8848" \ spring-ai-admin-server:latest ``` -------------------------------- ### Configure Development Environment Variables Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-studio/agent-chat-ui/README.md Example of the .env.development file used to configure the backend API URL, application name, and user ID for the Agent Chat UI. ```properties # .env.development NEXT_PUBLIC_API_URL=http://localhost:8080 # The agent to call in the backend application, backend application should register agent as required, check examples for how to configure. NEXT_PUBLIC_APP_NAME=research_agent NEXT_PUBLIC_USER_ID=user-001 ``` -------------------------------- ### Java Handoffs Multi-Agent Service Invocation Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/handoffs-multiagent/README.md Invokes the multi-agent handoff service with a user query and prints the resulting messages. This demonstrates how to integrate the service into your own Java code. ```java import org.springframework.beans.factory.annotation.Autowired; import com.alibaba.spring.ai.example.multiagent.handoffs.service.MultiAgentHandoffsService; // ... inside a Spring component or service @Autowired MultiAgentHandoffsService service; public void processQuery(String query) { var result = service.run(query); result.messages().forEach(msg -> System.out.println(msg.getText())); } ``` -------------------------------- ### 本地开发配置覆盖 Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/CONFIGURATION.md 通过环境变量或 dev profile 覆盖默认配置。 ```bash export SPRING_DATASOURCE_URL="jdbc:mysql://127.0.0.1:3306/admin?..." mvn spring-boot:run ``` ```bash cp src/main/resources/application-dev.yml.example src/main/resources/application-dev.yml # 编辑 application-dev.yml,然后使用 dev profile 启动 mvn spring-boot:run -Dspring-boot.run.profiles=dev ``` -------------------------------- ### Checkout Main Branch Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/CONTRIBUTING.md Switch to the main branch in your local repository. ```bash git checkout main ``` -------------------------------- ### Using RouterService in Application Code Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md This snippet shows how to inject and use the RouterService in your Spring application. It demonstrates calling the `run` method with a user query and accessing the classifications and the final synthesized answer from the result. ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class RoutingApplication implements CommandLineRunner { @Autowired RouterService routerService; public static void main(String[] args) { SpringApplication.run(RoutingApplication.class, args); } @Override public void run(String... args) throws Exception { String query = "How do I authenticate API requests?"; RouterService.RouterResult result = routerService.run(query); System.out.println("Classifications: " + result.classifications()); System.out.println("Final answer: " + result.finalAnswer()); } } ``` -------------------------------- ### 本地开发启动命令 Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/CONFIGURATION.md 使用 Docker Compose 启动中间件并运行 Spring Boot 应用。 ```bash # 启动本地中间件(使用 Docker Compose) cd docker/middleware ./run.sh # 运行应用(使用默认配置) cd spring-ai-alibaba-admin-server-start mvn spring-boot:run ``` -------------------------------- ### Bash: Set DashScope API Key Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/handoffs-singleagent/README.md Instructions to set the DashScope API key as an environment variable, which is required for the application to communicate with the DashScope service. The application defaults to using this environment variable for authentication. ```bash export AI_DASHSCOPE_API_KEY=your-key ``` -------------------------------- ### Add Spring AI Alibaba Dependency to Maven Project Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/test/resources/reader/springaialibaba.txt Include these dependencies in your Spring Boot project's pom.xml to start developing AI agents with Spring AI Alibaba. The dependencyManagement section imports the Bill of Materials (BOM) for version management. ```xml com.alibaba.cloud.ai spring-ai-alibaba-bom 1.0.0.2 pom import com.alibaba.cloud.ai spring-ai-alibaba-starter-dashscope ``` -------------------------------- ### RouterService for Routing and Synthesis Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md The RouterService class wraps the LlmRoutingAgent to handle the invocation of the agent, collection of outputs, and synthesis of a final answer. It provides a run method to execute the entire process and can also be used to synthesize results separately. ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; @Service public class RouterService { @Autowired private LlmRoutingAgent routerAgent; // Placeholder for the actual RouterResult class public static class RouterResult { private String query; private Object classifications; private Object results; private String finalAnswer; public RouterResult(String query, Object classifications, Object results, String finalAnswer) { this.query = query; this.classifications = classifications; this.results = results; this.finalAnswer = finalAnswer; } public String query() { return query; } public Object classifications() { return classifications; } public Object results() { return results; } public String finalAnswer() { return finalAnswer; } } public RouterResult run(String query) { // In a real scenario, this would involve invoking the routerAgent and processing its output // For demonstration, returning a dummy result System.out.println("Running query: " + query); // Simulate agent invocation and synthesis Object classifications = "Simulated Classifications"; Object results = "Simulated Agent Results"; String finalAnswer = "This is a synthesized answer for: " + query; return new RouterResult(query, classifications, results, finalAnswer); } public String synthesize(String query, Map results) { // Placeholder for synthesis logic return "Synthesized answer for " + query + " based on results."; } } ``` -------------------------------- ### Enable SQL Agent Workflow Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/workflow/src/main/java/com/alibaba/cloud/ai/examples/multiagents/workflow/sqlagent/README.md Configure the application to enable the SQL agent workflow and optionally the demo runner. ```yaml workflow.sql.enabled: true workflow.runner.enabled: true # optional demo on startup ``` -------------------------------- ### Java: Inject and Use Support Agent with State Persistence Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/handoffs-singleagent/README.md Demonstrates how to inject the `supportAgent` and interact with it using a stable `thread_id` to maintain state across multiple turns. This ensures the state machine progresses correctly by loading previous state from the checkpointer. ```java import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.model.ChatResponse; import org.springframework.ai.chat.model.Generation; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.ai.chat.prompt.PromptTemplate; import org.springframework.ai.chat.model.ChatModel; import org.springframework.ai.chat.model.ChatResponse; import org.springframework.ai.chat.messages.AssistantMessage; import org.springframework.ai.chat.model.RunnableConfig; import org.springframework.ai.chat.agent.ReactAgent; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; // ... other imports public class SupportAgentExample { @Qualifier("supportAgent") @Autowired ReactAgent supportAgent; public void runSupportSession() { RunnableConfig config = RunnableConfig.builder().threadId("my-support-session").build(); // Turn 1 AssistantMessage r1 = supportAgent.call(new UserMessage("Hi, my device is broken"), config); System.out.println("Turn 1 Response: " + r1.getContent()); // Turn 2 (same thread_id → state is loaded from checkpoint) AssistantMessage r2 = supportAgent.call(new UserMessage("Yes, it's still under warranty"), config); System.out.println("Turn 2 Response: " + r2.getContent()); // Turn 3 AssistantMessage r3 = supportAgent.call(new UserMessage("Screen physically cracked from drop"), config); System.out.println("Turn 3 Response: " + r3.getContent()); // Turn 4 AssistantMessage r4 = supportAgent.call(new UserMessage("What should I do?"), config); System.out.println("Turn 4 Response: " + r4.getContent()); } } ``` -------------------------------- ### Stubbed Slack Tools for Routing Agent Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md This class provides stubbed implementations for Slack-related tools, including searching Slack messages and retrieving thread details. Annotated with @Tool and @ToolParam, these methods simulate interactions with Slack, serving as placeholders for actual API integrations. ```java package com.example.routing.tools; import org.springframework.ai.விலான.tools.annotation.Tool; import org.springframework.ai.விலான.tools.annotation.ToolParam; import org.springframework.stereotype.Component; @Component public class SlackStubTools { @Tool(description = "Search Slack messages") public String search_slack(@ToolParam(description = "The query to search Slack") String query) { return "Stubbed result for searching Slack: " + query; } @Tool(description = "Get a Slack thread by ID") public String get_thread(@ToolParam(description = "The ID of the Slack thread") String threadId) { return "Stubbed result for getting Slack thread: " + threadId; } } ``` -------------------------------- ### Stubbed Notion Tools for Routing Agent Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md These are stubbed implementations of tools for the Notion agent. They define methods for searching Notion and retrieving page content using @Tool and @ToolParam annotations. These stubs are for demonstration and would be replaced with actual API calls in a production environment. ```java package com.example.routing.tools; import org.springframework.ai.விலான.tools.annotation.Tool; import org.springframework.ai.விலான.tools.annotation.ToolParam; import org.springframework.stereotype.Component; @Component public class NotionStubTools { @Tool(description = "Search Notion") public String search_notion(@ToolParam(description = "The query to search Notion") String query) { return "Stubbed result for searching Notion: " + query; } @Tool(description = "Get a Notion page by ID") public String get_page(@ToolParam(description = "The ID of the Notion page") String pageId) { return "Stubbed result for getting Notion page: " + pageId; } } ``` -------------------------------- ### Build and Run Routing Graph Application Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/graph/README.md Commands to build the Maven project and execute the application, with options to enable the demo runner. ```bash ./mvnw -pl :routing-graph -am -B package -DskipTests java -jar target/routing-graph-0.0.1-SNAPSHOT.jar export routing-graph.runner.enabled=true ``` -------------------------------- ### Stubbed GitHub Tools for Routing Agent Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/routing/src/main/java/com/alibaba/cloud/ai/examples/multiagents/routing/simple/README.md These are stubbed implementations of tools for the GitHub agent. They use the @Tool and @ToolParam annotations to define their functionality and parameters, allowing them to be used within the Spring AI framework for routing purposes. In production, these would interact with the actual GitHub API. ```java package com.example.routing.tools; import org.springframework.ai.விலான.tools.annotation.Tool; import org.springframework.ai.விலான.tools.annotation.ToolParam; import org.springframework.stereotype.Component; @Component public class GitHubStubTools { @Tool(description = "Search GitHub code") public String search_code(@ToolParam(description = "The query to search for code") String query) { return "Stubbed result for searching code: " + query; } @Tool(description = "Search GitHub issues") public String search_issues(@ToolParam(description = "The query to search for issues") String query) { return "Stubbed result for searching issues: " + query; } @Tool(description = "Search GitHub pull requests") public String search_prs(@ToolParam(description = "The query to search for pull requests") String query) { return "Stubbed result for searching pull requests: " + query; } } ``` -------------------------------- ### Clone Spring AI Alibaba Repository Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/README.md Use this command to download the project's source code. The --depth=1 option fetches only the latest commit, making the download faster. ```shell git clone --depth=1 https://github.com/alibaba/spring-ai-alibaba.git cd spring-ai-alibaba ``` -------------------------------- ### Build Skills Module with Maven Wrapper Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/README.md Build the skills module from the repository root using the Maven wrapper. This command skips tests during the build process. ```bash ./mvnw -pl :skills -am -B package -DskipTests ``` -------------------------------- ### SQL Query for Top Customers by Revenue Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/src/main/resources/skills/sales_analytics/SKILL.md An example SQL query to retrieve the top 10 customers by revenue generated from completed orders within the last quarter. It joins the customers and orders tables, filters by order status and date, and groups results by customer to calculate total revenue. ```sql -- Get top 10 customers by revenue in the last quarter SELECT c.customer_id, c.name, c.customer_tier, SUM(o.total_amount) as total_revenue FROM customers c JOIN orders o ON c.customer_id = o.customer_id WHERE o.status = 'completed' AND o.order_date >= CURRENT_DATE - INTERVAL '3 months' GROUP BY c.customer_id, c.name, c.customer_tier ORDER BY total_revenue DESC LIMIT 10; ``` -------------------------------- ### Enable Skills Runner Demo in application.yml Source: https://github.com/alibaba/spring-ai-alibaba/blob/main/examples/multiagent-patterns/skills/README.md Alternatively, enable the demo by setting 'skills.runner.enabled' to true in the application.yml configuration file. ```yaml skills.runner.enabled: true ```