Skip to content

Commit

Permalink
Update tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasVitale committed Jan 20, 2024
1 parent 2d825ee commit f76ad94
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 22 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/commit-stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Commit Stage
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Compile and test
run: ./gradlew build
9 changes: 9 additions & 0 deletions 01-chat-models/chat-models-ollama/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Chat Models: Ollama

```shell
./gradlew bootTestRun
```

```shell
http :8080/ai/chat
```
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
package com.thomasvitale.ai.spring;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.test.web.reactive.server.WebTestClient;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Import(TestChatModelsOllamaApplication.class)
@AutoConfigureWebTestClient(timeout = "30s")
@SpringBootTest
class ChatModelsOllamaApplicationTests {

@Autowired
WebTestClient webTestClient;

@Test
void chat() {
webTestClient
.get()
.uri("/ai/chat")
.exchange()
.expectStatus().isOk()
.expectBody(String.class).value(response -> {
assertThat(response).contains("You shall not pass");
});
void contextLoads() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ GenericContainer<?> ollama(DynamicPropertyRegistry properties) {
.withExposedPorts(11434);
properties.add("spring.ai.ollama.base-url",
() -> "http://%s:%s".formatted(ollama.getHost(), ollama.getMappedPort(11434)));
properties.add("spring.ai.ollama.chat.model", () -> "llama2");
return ollama;
}

Expand Down
9 changes: 9 additions & 0 deletions 01-chat-models/chat-models-openai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Chat Models: OpenAI

```shell
./gradlew bootRun
```

```shell
http :8080/ai/chat
```

0 comments on commit f76ad94

Please sign in to comment.