Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : convert from openai to ollama model #24

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions llm-rag-with-springai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
Expand All @@ -45,10 +45,6 @@
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-pdf-document-reader</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
Expand Down Expand Up @@ -84,6 +80,11 @@
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>ollama</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
13 changes: 7 additions & 6 deletions llm-rag-with-springai/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ spring.application.name=llm-rag-with-springai
spring.threads.virtual.enabled=true
spring.mvc.problemdetails.enabled=true

spring.ai.openai.api-key=demo
spring.ai.openai.base-url=http://langchain4j.dev/demo/openai
spring.ai.openai.chat.options.model=gpt-3.5-turbo
spring.ai.openai.chat.options.temperature=0.7
spring.ai.openai.chat.options.responseFormat=json_object
spring.ai.ollama.chat.options.model=llama2
spring.ai.ollama.chat.options.responseFormat=json_object

#spring.ai.openai.image.model=dall-e-3
spring.ai.ollama.embedding.options.model=llama2

spring.ai.vectorstore.pgvector.dimensions=4096
## As dimensions are more than 2000 both available indexes cannot be applied
spring.ai.vectorstore.pgvector.indexType=NONE
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.ollama.OllamaContainer;
import org.testcontainers.utility.DockerImageName;

@TestConfiguration(proxyBeanMethods = false)
public class TestLlmRagWithSpringAiApplication {

@Bean
OllamaContainer ollama(DynamicPropertyRegistry properties) {
OllamaContainer ollama = new OllamaContainer(
DockerImageName.parse("ghcr.io/thomasvitale/ollama-llama2").asCompatibleSubstituteFor("ollama/ollama"));
properties.add("spring.ai.ollama.base-url", ollama::getEndpoint);
return ollama;
}

@Bean
@ServiceConnection
PostgreSQLContainer<?> pgvectorContainer() {
Expand Down
Loading