# Devs & Architects Assembly powered by Polymindra <center><img src="https://hackmd.io/_uploads/SJoDJapgT.png" width=400/></center> Polymindra *("Poly" "Mind")* is a mediator who supports developers and architects in their discussions. While conversational LLMs become more day to day technology which help individuals to enhance their work experience and results, this usage is not very collaborative. People are using LLMs as tools on their own, with no input from other people, which is not typical of a developers or architects daily work. Polymindra is configured to work in a team environment. It can distinguish different people and opinions, summarize them and add its own vast knowledge as a GPT-based conversational chat bot, similar to ChatGPT, but in "multi-user-mode". ## How does it look like? <a href="https://hackmd.io/_uploads/B1t1X1Axp.png"><img src="https://hackmd.io/_uploads/B1t1X1Axp.png"/></a> *Multi-User Chat UI with Polymindra* <a href="https://hackmd.io/_uploads/SkLRX1Ax6.png"><img src="https://hackmd.io/_uploads/SkLRX1Ax6.png"/></a> *Helping with achieving consensus* <a href="https://hackmd.io/_uploads/ryGTSJ0lT.png"> <img src="https://hackmd.io/_uploads/ryGTSJ0lT.png"/></a> *Trying to mediate between different opinions* <a href="https://hackmd.io/_uploads/ryIy3JRg6.png"> <img src="https://hackmd.io/_uploads/ryIy3JRg6.png"/></a> *Support with deep tech knowledge* ## How does it work? The project uses a modern Java stack with some configuration and only little custom implementation: * [Spring Boot 3](https://spring.io/projects/spring-boot) - Create stand-alone, production-grade Spring based applications * [langchain4j](https://github.com/langchain4j/langchain4j) -- Integration of AI/LLM capabilities into Java application * [Maven](https://maven.apache.org/) - Software project and build management ![](https://hackmd.io/_uploads/r1GwW06eT.png) Spring Boot offers a very simple to configure HTTP/REST API access and the underlying Spring Framework helps with automated composition of the different components (OpenAI Agent Service, HTTP interface, Configuration) with Dependency Injection and Inversion of Control. langchain4j is a more recent project which supports Spring Boot by implementing a Spring Boot Starter adapter. This makes using frameworks with Spring Boot a matter of configuration, without having to dig through dependency trees. Just include *one* dependency in your Maven or Gradle project descriptions and use the framework in your own code. ### The HTTP interface This simple endpoint allows the UI to post the user message together with the user name to help GPT to differentiate the different users and their opinions. ```java @PostMapping("/addMessage") public ResponseEntity<Void> addMessage( @RequestParam String username, @RequestParam String message) { if (username == null || message == null) { return ResponseEntity.badRequest().build(); } messages.append(("%s: %s" + MESSAGE_SEPERATOR).formatted(username, message)); String polymindraResponse = agentConversationService .passUserMessageToPolymindraAndReturnAnswer(username, message); messages.append(polymindraResponse).append(MESSAGE_SEPERATOR); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } ``` The agent is configured with a specific system message to customize the GPT LLM. ```java @SystemMessage({ """ You are Polymindra, an AI mediator well-versed in deep tech. Currently participating in a group chat of developers and architects, each user's message is prefixed by a unique user id. Provide a concise summary of the ongoing discussion, incorporating your own tech knowledge and actively contribute arguments and questions, ensuring fairness to all participants. """ }) String chat(String userMessage); ``` In the configuration of this agent, we are using the langchain4j `MessageWindowChatMemory`, which stores the last 20 messages to always provide the context of the group chat. ```java @Bean PolymindraAgent polymindraAgent(ChatLanguageModel chatLanguageModel) { return AiServices.builder(PolymindraAgent.class) .chatLanguageModel(chatLanguageModel) .chatMemory(MessageWindowChatMemory.withMaxMessages(20)) .build(); } ``` That's it. Besides the UI JS part, there is no more implementation necessary to use the functionality of a context-aware chat bot, like ChatGPT. ## How can I use it? All instructions are in the README of the [Polymindra repository](https://github.com/ice09/polymindra). *You can use [Localtunnel](https://localtunnel.github.io/www/) to make it easy for others to access a locally or on-site running web application.*