Skip to content

Latest commit

 

History

History
264 lines (203 loc) · 16.7 KB

File metadata and controls

264 lines (203 loc) · 16.7 KB

🚀 Spring AI Summary

中文 English document Spring AI Summary Visitors

Spring AI Summary is a modular collection of sample projects based on native Spring AI framework, helping developers quickly master Spring AI's core features through clear code examples and detailed documentation.

👥 Target Audience

Spring AI Summary is designed for developers interested in the Spring AI framework. Whether you're a beginner or experienced engineer, you can quickly understand the framework's core features and apply them to real projects through this project. With Spring AI Summary, you can:

  • Master Spring AI's core concepts and features
  • Learn how to build efficient AI applications
  • Get the latest technical insights and practical experience

Join Community 🎯 Scan the QR code to add the group owner on WeChat (note: Spring AI), let's explore the infinite possibilities of Spring AI together!

Community Chat Group

📖 Learning Path

If you're new to Spring AI, we recommend starting with the Spring AI Official Documentation to understand the framework's basic concepts and usage. Then you can practice through the various modules in this project to gradually deepen your understanding of the framework's core features.

Recommended Learning Sequence:

  1. 📚 Spring AI Official Documentation - Understand basic concepts
  2. 💬 spring-ai-chat - Chat application development (essential starting point)
  3. 🔧 spring-ai-tool-calling - Tool calling capabilities
  4. 🧠 spring-ai-vector - Vector database integration
  5. 🚀 MCP/RAG/AGENT - Advanced application patterns

👇Let's start the Spring AI journey below~

🚀 Quick Start

⚙️ Environment Requirements

Dependency Version/Requirement Note
SpringBoot 3.3.6 -
Spring AI 1.0.0 -
JDK 21+ -
Maven 3.6+ Strongly recommend using mvnd instead of mvn
Docker (for running Milvus, Nacos, etc.)

1. 🧬 Clone Project

# Clone project to local
git clone https://github.com/java-ai-tech/spring-ai-summary.git
# Enter project directory and compile
cd spring-ai-summary && mvn clean compile -DskipTests

If you encounter slow Maven dependency downloads, try using domestic Maven mirror sources like Aliyun, Tsinghua University, etc. If you have any other issues during runtime, you can scan the QR code to join the WeChat group above for consultation and discussion~~~

2. 🛠️ Configure Environment Variables

For the application.yml/application.properties files in each module's resource folder, configure the corresponding API keys according to your needs. For example, the spring-ai-chat-deepseek module:

# because we do not use the OpenAI protocol
spring.ai.deepseek.api-key=${spring.ai.deepseek.api-key}
spring.ai.deepseek.base-url=https://api.deepseek.com
spring.ai.deepseek.chat.completions-path=/v1/chat/completions
spring.ai.deepseek.chat.options.model=deepseek-chat

Replace your spring.ai.deepseek.api-key with the actual API key to start running. For how to apply for API keys, you can visit the project Wiki page.

💡 Security Tip: Use environment variables to store API keys to avoid code leakage. API Key Application Guide

3. ▶️ Run Examples

After completing the above steps, you can choose to run different example modules to experience Spring AI features. For example, start running the spring-ai-chat-deepseek module (specific port may vary according to your configuration):

2025-06-04T14:18:43.939+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] c.g.ai.chat.deepseek.DsChatApplication   : Starting DsChatApplication using Java 21.0.2 with PID 88446 (/Users/glmapper/Documents/projects/glmapper/spring-ai-summary/spring-ai-chat/spring-ai-chat-deepseek/target/classes started by glmapper in /Users/glmapper/Documents/projects/glmapper/spring-ai-summary)
2025-06-04T14:18:43.941+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] c.g.ai.chat.deepseek.DsChatApplication   : The following 1 profile is active: "deepseek"
2025-06-04T14:18:44.469+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8081 (http)
2025-06-04T14:18:44.475+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2025-06-04T14:18:44.476+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.33]
2025-06-04T14:18:44.501+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2025-06-04T14:18:44.502+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 533 ms
2025-06-04T14:18:44.962+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 14 endpoints beneath base path '/actuator'
2025-06-04T14:18:44.988+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8081 (http) with context path '/'
2025-06-04T14:18:44.997+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [           main] c.g.ai.chat.deepseek.DsChatApplication   : Started DsChatApplication in 1.215 seconds (process running for 1.637)
2025-06-04T14:18:45.175+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [on(2)-127.0.0.1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2025-06-04T14:18:45.175+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [on(2)-127.0.0.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2025-06-04T14:18:45.176+08:00  INFO 88446 --- [spring-ai-chat-deepseek] [on(2)-127.0.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms

If you see similar startup logs as above, congratulations, you've started successfully 🎉🎉🎉🎉🎉....! You've opened the door to Spring AI, and you can now start exploring various functional modules. After startup, you can test using cUrl, HTTPie, or Postman and other tools.

curl localhost:8081/api/deepseek/chatWithMetric?userInput="Who are you?"

Results as follows:

Success Indicator 🎉: Seeing similar responses indicates successful operation!

Running Results

You can continue using the following requests to check Token usage:

# completion tokens
http://localhost:8081/actuator/metrics/ai.completion.tokens
# prompt tokens
http://localhost:8081/actuator/metrics/ai.prompt.tokens
# total tokens
http://localhost:8081/actuator/metrics/ai.total.tokens

Taking ai.completion.tokens as an example, the results are as follows:

{
   "name": "ai.completion.tokens",
   "measurements": [
      {
         "statistic": "COUNT",
         "value": 34
      }
   ],
   "availableTags": []
}

For usage methods and configurations of other modules, please check the Wiki page or each module's README.md file.

📚 Learning Resources (Continuously Updated)

Here are some recommended learning resources:

The official also has a learning resource collection, but it mainly aggregates overseas materials, so this project focuses more on aggregating domestic learning resources for your reference.

Technical Community

Project Series

Blog Series

Video Series

If you have good articles or resources, you're also welcome to submit PRs or Issues for supplementation and improvement. Below is the development and contribution guide.

🔧 Development Guide (Code, Documentation)

First, we warmly welcome any form of contribution, including but not limited to code, documentation, testing, code comments, etc. But please follow the process below before submitting contributions:

Contributing Code

  1. Fork Project

As shown in the figure below, fork the repository to your personal repository how-to-fork.png

  1. Clone Your Personal Repository Code

    # Fork the project on GitHub
    # Clone your fork repository
    git clone https://github.com/your-username/spring-ai-summary.git
    cd spring-ai-summary
  2. Create Feature Branch

    # Create and switch to new feature branch
    git checkout -b feature/your-feature-name
  3. Development Standards

    • Follow the project's code style and naming conventions
    • Ensure code passes all tests (if any)
    • Update relevant documentation
  4. Submit Code

    # Add modified files
    git add .
    # Commit code
    git commit -m "feat: add new feature"
    # Push to your fork repository
    git push origin feature/your-feature-name
  5. Create Pull Request

    • Create Pull Request on GitHub
    • Fill in PR description, explaining changes and reasons
    • Wait for code review and merge

📝 Important Notes

  1. API Key Security

    • Recommend using environment variables to store API keys to avoid leakage risks
    • Never hardcode keys in code repositories
    • Regularly rotate keys to enhance security
  2. Token Usage

    • Continuously monitor Token consumption to avoid overuse
    • Set reasonable Token limits to prevent abuse
    • Recommend implementing caching mechanisms to improve response speed and cost control

📄 License & Description

    1. This project adopts the MIT license. See LICENSE file for details. Additionally, this project is only for learning and research use, not suitable for production environments. Please do not use sample projects directly in production environments. Please comply with the terms and conditions of relevant models when using.
    1. All code and documentation in this project are independently developed and maintained by glmapper. Everyone is welcome to provide opinions and suggestions. If this helps you, please give a Star to support! If you have any questions or suggestions, please submit Issues or PRs on GitHub, or contact me through here. I will further synchronize Spring AI related technical articles to this repository and my personal WeChat public account: 磊叔的技术博客. You're also welcome to scan the code to follow.

WeChat Public Account

🙏 Acknowledgments

  • Spring AI - Provides powerful AI integration framework
  • OpenAI - Provides GPT series models
  • Qwen - Provides Qwen series models
  • Doubao - Provides Doubao series models
  • Milvus - Provides vector database support

This project is a completely open source project, with the main purpose of gathering more high-quality Spring AI related learning resources. Of course, related learning resources mainly come from the internet, if there is any infringement, please contact for deletion!!! Here we also express heartfelt thanks to all friends who participate in open source contributions and share technology in the technical community!

Star History

Star History Chart