agents-flex
<p align="center"> <img src="./docs/assets/images/banner.png"/> </p> <p align="center"> <strong>An Elegant Java Framework for LLM Application Development | Truly Open Source Β· Easy Integration Β· Production Ready</strong> </p> ## π Core Features Agents-Flex is designed for Java engineers and architects, delivering a **lightweight, modular, and extensible** AI agent development experience to help enterprises rapidly build production-grade LLM applications. ### β¨ New Core Capabilities (v2.0+) | Feature | Description | Use Cases | |---------|-------------|-----------| | **MCP Support** | Native integration with Model Context Protocol for standardized connection to external data sources and tools | Cross-system context sharing, tool orchestration | | **AI Skills** | Encapsulate business capabilities into reusable, composable Skill units | Rapid domain Agent construction, skill marketplace | | **Text2SQL / Smart Data Query** | Built-in Text2SQL and natural language data analysis capabilities | Zero-code querying for business users, data insights | ### π§ Core Capabilities Matrix ``` π§ Model Integration π Tool Invocation π Knowledge Enhancement ββ Mainstream LLMs ββ Function Calling ββ Multi-format Document Loading ββ Ollama Local Deploy ββ MCP Tool Protocol ββ Intelligent Text Splitting ββ HTTP/SSE/WS Protocolsββ Local Method Reflection ββ Vector Store Integration ββ Multi-Provider Mgmt ββ Execution Interceptors ββ Custom Embedding Support βοΈ Engineering Support π Observability π‘οΈ Enterprise-Grade Assurance ββ Prompt Template Engineββ OpenTelemetry Integrationββ Sensitive Data Masking ββ Multi-turn Memory ββ Distributed Tracing ββ Safe Resource Shutdown ββ Async/Streaming Resp ββ Structured Logging ββ Apache 2.0 License ``` > π‘ **Design Principles**: Zero-Intrusion Integration Β· Interface-Driven Extension Β· Configuration Over Code Β· Production-Friendly ## β‘ Quick Start ### 1οΈβ£ Add Dependencies (Maven) ```xml <dependency> <groupId>com.agentsflex</groupId> <artifactId>agents-flex-core</artifactId> <version>2.1.8</version> </dependency> <!-- Optional: Add extension modules as needed --> <dependency> <groupId>com.agentsflex</groupId> <artifactId>agents-flex-mcp</artifactId> <version>2.1.8</version> </dependency> ``` ### 2οΈβ£ Hello World ```java public class QuickStart { public static void main(String[] args) { // 1. Configure the model (supports GiteeAI / OpenAI / Ollama, etc.) OpenAIChatModel chatModel = OpenAIChatConfig.builder() .provider("GiteeAI") .endpoint("https://ai.gitee.com") .requestPath("/v1/chat/completions") .apiKey(System.getenv("GITEE_AI_KEY")) // β Recommended: load from environment variable .model("Qwen3-32B") .buildModel(); // 2. Start a conversation (sync/streaming/async all supported) String response = chatModel.chat("Explain what humor is in a way that Java developers can understand?"); // 3. Output the result System.out.println("π€ Agents-Flex: " + response); } } ``` **Console Output Example**: ```text [Agents-Flex] >>> [GiteeAI/Qwen3-32B] Request: {"model":"Qwen3-32B","messages":[...]} [Agents-Flex] <<< [GiteeAI/Qwen3-32B] Response: 200 OK (1.2s) π€ Agents-Flex: Humor is like elegant exception handling in codeβseemingly unexpected, yet meticulously designed... ``` > π The `[Agents-Flex]` log prefix can be customized or disabled via `application.properties`. For production environments, SLF4J integration is recommended. ## π¦ Module Overview ``` agents-flex/ βββ agents-flex-bom # π¦ BOM dependency management for unified versioning βββ agents-flex-core # π§± Core abstractions: Model/Prompt/Memory/Tool SPI βββ agents-flex-chat # π¬ Chat engine: sync/streaming/async invocation βββ agents-flex-tool # π§ Function Calling engine: method definition/parsing/execution βββ agents-flex-mcp # π MCP protocol support: standardized context & tool connection (New) βββ agents-flex-skills # π― AI Skills: capability encapsulation & dynamic loading (New) βββ agents-flex-text2sql # π Text2SQL & natural language data analysis (New) βββ agents-flex-embedding # π’ Embedding service: model integration & vector generation βββ agents-flex-store # ποΈ Storage extensions: VectorStore/Memory persistence implementations βββ agents-flex-search-engine # π Search engine integration: ES/DB/custom retrieval sources βββ agents-flex-rerank # π Re-ranking service: improve RAG retrieval relevance βββ agents-flex-image # πΌοΈ Image capabilities: text-to-image / image-to-text model integration βββ agents-flex-spring-boot-starter # βοΈ Spring Boot auto-configuration (Production Recommended) βββ demos/ # π§ͺ Sample projects: MCP / Skills / Text2SQL demos βββ docs/ # π Documentation source (VitePress) βββ testresource/ # π§ͺ Test resource files ``` β **Production-Ready Recommendations**: - Use `agents-flex-spring-boot-starter` with a configuration center for API key management in production - Inject sensitive information (API Keys / DB passwords) via `@Value("${xxx}")` + encrypted configuration - Enable `management.endpoints.web.exposure.include=metrics,trace` for monitoring integration - For RAG scenarios, combine: `data` + `embedding` + `store` + `rerank` modules ## π Documentation & Resources | Type | Link | Description | |------|------|-------------| | π Chinese Docs | [https://agentsflex.com](https://agentsflex.com) | Complete API guide + best practices | | π§ͺ Sample Projects | [/demos](./demos) | MCP integration / Skills orchestration / Text2SQL demos | | π Changelog | [/changes.md](./changes.md) | Version history and migration guide | | π Issue Tracker | [GitHub Issues](https://github.com/agents-flex/agents-flex/issues) | Bug reports / feature requests | | π¬ Community | [Join Discussion](https://github.com/agents-flex/agents-flex/discussions) | Q&A, ideas, and community support | ## π€ Contributing We follow the [Apache Way](https://apache.org/theapacheway) and [Contributor Covenant](https://www.contributor-covenant.org/) guidelines: 1. Fork the repo β Create a feature branch (`feature/xxx`) 2. Code style: Run `mvn spotless:apply` for auto-formatting (Google Java Style) 3. Add unit tests: Aim for β₯ 80% coverage on core modules 4. Submit a PR linked to an issue, describing the motivation and impact of changes > π Especially welcome: Java 8/11/17 compatibility tests, enterprise use cases, and documentation translations --- ## π License Agents-Flex is released under the **Apache License 2.0**. You are free to: - β Use commercially in your projects - β Modify and deploy privately - β Contribute code to grow the ecosystem > Please retain the original copyright notice and indicate modifications when distributing. See [LICENSE](./LICENSE) for details. ## β FAQ ### What is Agents-Flex? **Agents-Flex** is an elegant Java framework for LLM application development. It provides a lightweight, modular, and extensible AI agent development experience designed for Java engineers and architects to help enterprises rapidly build production-grade LLM applications. ### Key Features | Feature | Description | |---------|-------------| | **MCP Support** | Native integration with Model Context Protocol for standardized connection to external data sources and tools | | **AI Skills** | Encapsulate business capabilities into reusable, composable Skill units | | **Text2SQL** | Built-in Text2SQL and natural language data analysis capabilities | | **Model Integration** | Mainstream LLMs, Ollama local deploy, HTTP/SSE/WS protocols, multi-provider management | | **Tool Invocation** | Function Calling, MCP Tool Protocol, Local Method Reflection | | **Knowledge Enhancement** | Multi-format document loading, intelligent text splitting, vector store integration | ### How to Install? Add Maven dependencies: ```xml <dependency> <groupId>com.agentsflex</groupId> <artifactId>agents-flex-core</artifactId> <version>2.1.3</version> </dependency> <!-- Optional: Add extension modules --> <dependency> <groupId>com.agentsflex</groupId> <artifactId>agents-flex-mcp</artifactId> <version>2.1.3</version> </dependency> ``` ### Supported LLM Providers | Provider | Endpoint | Models | |----------|----------|--------| | **GiteeAI** | https://ai.gitee.com | Qwen3-32B, etc. | | **OpenAI** | https://api.openai.com | GPT-4, GPT-3.5-turbo | | **Ollama** | Local | llama3, mistral, etc. | | **Custom** | Custom endpoint | Any OpenAI-compatible API | ### Requirements - Java 8 / 11 / 17 compatible - Maven or Gradle for dependency management - LLM API key (GiteeAI / OpenAI / Ollama) - Optional: Spring Boot for production ### Module Overview | Module | Description | |--------|-------------| | `agents-flex-core` | Core abstractions: Model/Prompt/Memory/Tool SPI | | `agents-flex-chat` | Chat engine: sync/streaming/async | | `agents-flex-mcp` | MCP protocol support | | `agents-flex-skills` | AI Skills: capability encapsulation | | `agents-flex-text2sql` | Text2SQL & data analysis | | `agents-flex-spring-boot-starter` | Spring Boot auto-configuration | ### License **Apache License 2.0** - Free for commercial use, modification, and contribution. ### Help Resources - π [Chinese Documentation](https://agentsflex.com) - π§ͺ [Sample Projects](https://github.com/agents-flex/agents-flex/tree/main/demos) - π [Changelog](https://github.com/agents-flex/agents-flex/blob/main/changes.md) - π [Issue Tracker](https://github.com/agents-flex/agents-flex/issues) - π¬ [Community Discussions](https://github.com/agents-flex/agents-flex/discussions)