Skip to content

Commit

Permalink
Merge branch 'main' into feature/model-client-deepseek
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsl-gr committed May 21, 2024
2 parents cba666c + 2abf10d commit 41505f6
Show file tree
Hide file tree
Showing 276 changed files with 13,844 additions and 1,539 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/source-code-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Source Code Format

on:
pull_request:
branches:
- main

jobs:
build:
name: Build branch
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

- name: Source code formatting check
run: |
./mvnw spring-javaformat:validate
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ Let's make your `@Beans` intelligent!

For further information go to our [Spring AI reference documentation](https://docs.spring.io/spring-ai/reference/).

### Breaking changes
(15.05.2024)
On our march to release 1.0 M1 we have made several breaking changes. Apologies, it is for the best!

Renamed POM artifact names:
- spring-ai-qdrant -> spring-ai-qdrant-store
- spring-ai-cassandra -> spring-ai-cassandra-store
- spring-ai-pinecone -> spring-ai-pinecone-store
- spring-ai-redis -> spring-ai-redis-store
- spring-ai-qdrant -> spring-ai-qdrant-store
- spring-ai-gemfire -> spring-ai-gemfire-store
- spring-ai-azure-vector-store-spring-boot-starter -> spring-ai-azure-store-spring-boot-starter
- spring-ai-redis-spring-boot-starter -> spring-ai-redis-store-spring-boot-starter

## Project Links

* [Documentation](https://docs.spring.io/spring-ai/reference/)
Expand Down Expand Up @@ -94,6 +108,7 @@ Spring AI supports many AI models. For an overview see here. Specific models c
* Transformers (ONNX)
* Anthropic Claude3
* DeepSeek
* MiniMax


**Prompts:** Central to AI model interaction is the Prompt, which provides specific instructions for the AI to act upon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,11 @@ protected boolean isToolFunctionCall(ResponseEntity<ChatCompletion> response) {
return response.getBody().content().stream().anyMatch(content -> content.type() == MediaContent.Type.TOOL_USE);
}

@Override
protected Flux<ResponseEntity<ChatCompletion>> doChatCompletionStream(ChatCompletionRequest request) {
// https://docs.anthropic.com/en/docs/tool-use
throw new UnsupportedOperationException(
"Streaming (stream=true) is not yet supported. We plan to add streaming support in a future beta version.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.ai.model.ModelOptionsUtils;
import org.springframework.ai.retry.RetryUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -100,7 +101,13 @@ public AnthropicApi(String baseUrl, String anthropicApiKey, String anthropicVers
.defaultStatusHandler(responseErrorHandler)
.build();

this.webClient = WebClient.builder().baseUrl(baseUrl).defaultHeaders(jsonContentHeaders).build();
this.webClient = WebClient.builder()
.baseUrl(baseUrl)
.defaultHeaders(jsonContentHeaders)
.defaultStatusHandler(HttpStatusCode::isError,
resp -> Mono.just(new RuntimeException("Response exception, Status: [" + resp.statusCode()
+ "], Body:[" + resp.bodyToMono(java.lang.String.class) + "]")))
.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ void beanStreamOutputConverterRecords() {
@Test
void multiModalityTest() throws IOException {

byte[] imageData = new ClassPathResource("/test.png").getContentAsByteArray();
var imageData = new ClassPathResource("/test.png");

var userMessage = new UserMessage("Explain what do you see on this picture?",
List.of(new Media(MimeTypeUtils.IMAGE_PNG, imageData)));

ChatResponse response = chatClient.call(new Prompt(List.of(userMessage)));
var response = chatClient.call(new Prompt(List.of(userMessage)));

logger.info(response.getResult().getOutput().getContent());
assertThat(response.getResult().getOutput().getContent()).contains("bananas", "apple", "basket");
Expand All @@ -205,15 +205,15 @@ void functionCallTest() {
.withModel(AnthropicApi.ChatModel.CLAUDE_3_OPUS.getValue())
.withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService())
.withName("getCurrentWeather")
.withDescription("Get the weather in location")
.withDescription("Get the weather in location. Return temperature in 36°F or 36°C format.")
.build()))
.build();

ChatResponse response = chatClient.call(new Prompt(messages, promptOptions));

logger.info("Response: {}", response);

Generation generation = response.getResults().get(0);
Generation generation = response.getResult();
assertThat(generation.getOutput().getContent()).containsAnyOf("30.0", "30");
assertThat(generation.getOutput().getContent()).containsAnyOf("10.0", "10");
assertThat(generation.getOutput().getContent()).containsAnyOf("15.0", "15");
Expand Down
Loading

0 comments on commit 41505f6

Please sign in to comment.