Skip to content

Commit

Permalink
Use local Ollama instead of OpenAI
Browse files Browse the repository at this point in the history
  • Loading branch information
samie committed May 21, 2024
1 parent f4d6e1d commit 53fb60e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
# Minimal Chat application using Spring AI

This project is a Spring Boot application that integrates a Chat UI powered by OpenAI using Vaadin. It provides a responsive interface for interacting with OpenAI's conversational models.
This project is a Java application that integrates a Chat UI powered by Ollama using Vaadin UI. It provides a responsive interface for interacting with Ollama's conversational models.

<img width="504" alt="vaadin-spring-ai-open-ai-chat" src="https://github.com/samie/spring-ai-chat/assets/991105/d7216455-f28e-4d34-8cd0-f7f1074f6087">

## Features
- Full-stack application with Vaadin frontend and Spring Boot backend.
- Real-time chatting capability using OpenAI.
- Real-time chatting capability using local Ollama in Docker container.
- Dynamic message streaming and display of Markdown.

## Prerequisites
- Docker container for running ollama models
- JDK 17 or later
- Maven 3.6 or later

## Running the Application

Install and run ollama in localhost:11434
```
OPENAI_API_KEY=<your api key here> mvn spring-boot:run
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
```

Install ollama 'mistral' model (used by the web app by default)
```
docker exec ollama ollama pull mistral
```

Optional: check that everything works using curl:
```
curl http://localhost:11434/api/chat -d '{"model": "mistral", "messages": [{"role": "user", "content": "is black darker than white?"}], "stream":false}'
```


Run the web application in [localhost:8080](http://localhost:8080/):
```
mvn spring-boot:run
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</dependency>
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
Expand Down

0 comments on commit 53fb60e

Please sign in to comment.