Skip to content

Conversation

@lhpqaq
Copy link
Member

@lhpqaq lhpqaq commented Dec 19, 2025

Migration Plan: Replace LangChain4j with Spring AI

This PR migrates the AI module from LangChain4j to Spring AI, aligning the implementation with the Spring ecosystem and simplifying future maintenance.

Completed Tasks

  • Update BOM dependencies
    • Remove langchain4j
    • Add required Spring AI modules
  • Update bigtop-manager-ai module dependencies in pom.xml
  • Refactor core interfaces and abstractions
    • Update AIAssistant interface to use Spring AI types
    • Update AbstractAIAssistant to use Spring AI types
    • Update PersistentChatMemoryStore to implement ChatMemoryRepository
  • Migrate platform implementations
    • OpenAIAssistant – migrated to Spring AI OpenAI client
    • DeepSeekAssistant – implemented using Spring AI
    • QianFanAssistant – implemented using Spring AI
    • DashScopeAssistant – implemented using Spring AI
  • Update tests
    • PersistentChatMemoryStoreTest
    • GeneralAssistantFactoryTest
    • All tests passing
  • Build and verify
    • AI module builds and tests successfully
    • Fixed RestClient dependency issue by upgrading Spring Boot

Pending Tasks

  • Manual runtime verification
    • DashScopeAssistant
    • OpenAIAssistant
    • DeepSeekAssistant
    • QianFanAssistant
  • Refactor function-calling support
    • Reimplement using Spring AI APIs, or
    • Introduce a lightweight MCP-based client

Implementation Notes

AI Module Migration

  • Migrated from LangChain4j to Spring AI 1.0.0-RC1
  • Replaced ChatMemoryStore with Spring AI’s ChatMemoryRepository
  • A single OpenAiChatModel supports both synchronous and streaming calls

Server Module

  • Retained LangChain4j dependencies for tool/function calling:
    • ToolProvider
    • ToolSpecification
    • ToolExecutor
  • Tool migration to Spring AI is out of scope for this PR
  • Added required dependencies:
    • dev.langchain4j:langchain4j
    • org.jetbrains:annotations

Dependency Updates

  • Spring Boot upgraded from 3.1.1 to 3.2.0
    • Required for Spring Framework 6.1+
    • RestClient was introduced in Spring Framework 6.1
    • Spring AI OpenAI integration depends on RestClient
    • All tests pass after the upgrade
  • Note:
    • After upgrading, @PathVariable annotations must explicitly specify the parameter name
      (e.g. @PathVariable(name = "id"))

thank copilot~

commit f04f3aceeca9600d804502394d8082a4c060a8a7
Author: lhpqaq <657407891@qq.com>
Date:   Fri Dec 19 20:38:42 2025 +0800

    fix pathVar

commit fd4d75f
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Fri Dec 19 12:14:33 2025 +0000

    Upgrade Spring Boot to 3.2.0 to fix RestClient NoClassDefFoundError

    - Spring AI 1.0.0-RC1 requires Spring Framework 6.1+ which includes RestClient
    - Spring Boot 3.1.1 uses Spring Framework 6.0.x which doesn't have RestClient
    - Upgraded to Spring Boot 3.2.0 which includes Spring Framework 6.1.1
    - All tests passing, build successful

    Co-authored-by: lhpqaq <63844184+lhpqaq@users.noreply.github.com>

commit abbc78a
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Fri Dec 19 10:14:13 2025 +0000

    Add langchain4j dependencies back for server module tool support

    - Server module still uses langchain4j's ToolProvider for tool calling
    - Added dev.langchain4j:langchain4j to BOM and server dependencies
    - Added org.jetbrains:annotations for @NotNull annotations
    - AI module successfully migrated to Spring AI
    - Server module retains langchain4j for tool functionality

    Co-authored-by: lhpqaq <63844184+lhpqaq@users.noreply.github.com>

commit 66b542d
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Fri Dec 19 10:07:03 2025 +0000

    Fix Spring AI migration issues: use getText(), remove OpenAiStreamingChatModel, fix conversationId

    - Replace getContent() with getText() for Spring AI message types
    - Use OpenAiChatModel for both sync and streaming (Spring AI design)
    - Remove conversationId() from MessageWindowChatMemory builder (not in Spring AI API)
    - Update all platform implementations (OpenAI, DeepSeek, QianFan, DashScope)
    - Fix test files to use correct Spring AI ChatMemoryRepository methods
    - All tests now passing

    Co-authored-by: lhpqaq <63844184+lhpqaq@users.noreply.github.com>

commit 2e7ccf1
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Fri Dec 19 09:27:20 2025 +0000

    Continue migration to Spring AI - fix compilation errors with correct API usage

    Co-authored-by: lhpqaq <63844184+lhpqaq@users.noreply.github.com>

commit 589289c
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Fri Dec 19 09:22:27 2025 +0000

    WIP: Replace langchain4j with Spring AI - updating dependencies and core files

    Co-authored-by: lhpqaq <63844184+lhpqaq@users.noreply.github.com>

commit c77065f
Author: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date:   Fri Dec 19 09:08:56 2025 +0000

    Initial plan
@lhpqaq lhpqaq changed the title refactor: Replace langchain4j with Spring AI in bigtop-manager-ai module refactor: replace langchain4j with Spring AI in bigtop-manager-ai module Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant