Wednesday, 22 July 2026

Spring AI with LLama

 Spring AI : 


Step 1 : Add Spring AI dependency 

<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-starter-model-ollama</artifactId>
</dependency>

Step 2 : Add the properties 

spring.ai.ollama.chat.model=gemma4:12b
spring.ai.ollama.base-url=http://localhost:11434

Step 3 : Using ChatClient we can call the any type of LLM 

Step 4 : Using ChatMemoryRepository we can maintain the data like sesssion and store the memory. 
But this will store in the running server RAM, so we need to introduce the RedisChatMemory to Store into InMemory 

Step 4 : By changing the application properties we can connect different types of LLM's.
Need to pass the required keys to connect the LLM's. 

Step 5 : Using @Tool we can make any type of business logic into a tool and provide the old services 


No comments:

Post a Comment

Spring AI with LLama

 Spring AI :  Step 1 : Add Spring AI dependency  <dependency> <groupId>org.springframework.ai</groupId> <artifactId...