Release 0.31.0 (#1151)

This commit is contained in:
LangChain4j 2024-05-23 17:40:52 +02:00 committed by GitHub
parent 358f63c0fa
commit d9cb1e9b81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
65 changed files with 122 additions and 117 deletions

View File

@ -35,7 +35,7 @@ jobs:
token: ${{ secrets.TC_CLOUD_TOKEN }}
- name: release
run: mvn -B -U --fail-at-end -DskipTests -DskipAnthropicITs -DskipLocalAiITs -DskipMilvusITs -DskipMongoDbAtlasITs -DskipOllamaITs -DskipVearchITs -DskipVertexAiGeminiITs -pl !langchain4j-core,!langchain4j-parent -Psign clean deploy
run: mvn -B -U --fail-at-end -DskipTests -DskipITs -DskipAnthropicITs -DskipLocalAiITs -DskipMilvusITs -DskipMongoDbAtlasITs -DskipOllamaITs -DskipVearchITs -DskipVertexAiGeminiITs -pl !langchain4j-core,!langchain4j-parent -Psign clean deploy
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
@ -50,6 +50,7 @@ jobs:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_VERTEXAI_ENDPOINT: ${{ secrets.GCP_VERTEXAI_ENDPOINT }}
HF_API_KEY: ${{ secrets.HF_API_KEY }}
JINA_API_KEY: ${{ secrets.JINA_API_KEY }}
MILVUS_API_KEY: ${{ secrets.MILVUS_API_KEY }}
MILVUS_URI: ${{ secrets.MILVUS_URI }}
MISTRAL_AI_API_KEY: ${{ secrets.MISTRAL_AI_API_KEY }}
@ -60,6 +61,7 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_BASE_URL: ${{ secrets.OPENAI_BASE_URL }}
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }}
WEAVIATE_API_KEY: ${{ secrets.WEAVIATE_API_KEY }}
WEAVIATE_HOST: ${{ secrets.WEAVIATE_HOST }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}

View File

@ -150,12 +150,12 @@ See example [here](https://github.com/langchain4j/langchain4j-examples/blob/main
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```
- Gradle:
```groovy
implementation 'dev.langchain4j:langchain4j-open-ai:0.30.0'
implementation 'dev.langchain4j:langchain4j-open-ai:0.31.0'
```
2. Import your OpenAI API key:

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -24,7 +24,7 @@ In this case, we should add the OpenAI dependency:
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```
If you want to use more of the Langchain4j non-integration specific classes, such as Services, you will also need to add
@ -34,13 +34,13 @@ the base library:
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```
- For Gradle in `build.gradle`:
```groovy
implementation 'dev.langchain4j:langchain4j-open-ai:0.30.0'
implementation 'dev.langchain4j:langchain4j-open-ai:0.31.0'
```
Then, import your OpenAI API key.

View File

@ -13,7 +13,7 @@ sidebar_position: 2
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-anthropic</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```
@ -90,7 +90,7 @@ Import Spring Boot starter for Anthropic:
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-anthropic-spring-boot-starter</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```

View File

@ -16,7 +16,7 @@ sidebar_position: 12
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```

View File

@ -20,7 +20,7 @@ It looks beyond the surface-level matching of terms to consider the deeper inter
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-jina</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```

View File

@ -96,7 +96,7 @@ adjusting and customizing more and more aspects.
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-easy-rag</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```

View File

@ -14,7 +14,7 @@ To use one of the Spring Boot starters, first import the corresponding dependenc
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai-spring-boot-starter</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```
@ -48,7 +48,7 @@ import `langchain4j-spring-boot-starter`:
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-spring-boot-starter</artifactId>
<version>0.30.0</version>
<version>0.31.0</version>
</dependency>
```

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>
@ -33,6 +33,11 @@
<artifactId>converter-jackson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -10,7 +10,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -12,7 +12,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -4,7 +4,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -5,7 +5,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -17,7 +17,6 @@ import java.util.List;
import static dev.langchain4j.agent.tool.JsonSchemaProperty.STRING;
import static dev.langchain4j.data.message.UserMessage.userMessage;
import static dev.langchain4j.model.output.FinishReason.*;
import static dev.langchain4j.model.output.FinishReason.TOOL_EXECUTION;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
@ -66,7 +65,7 @@ class MistralAiChatModelIT {
assertThat(response.content().text()).contains("Lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(15);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -93,8 +92,8 @@ class MistralAiChatModelIT {
assertThat(response.content().text()).isNotBlank();
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(15);
assertThat(tokenUsage.outputTokenCount()).isEqualTo(4);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -108,6 +107,7 @@ class MistralAiChatModelIT {
ChatLanguageModel model = MistralAiChatModel.builder()
.apiKey(System.getenv("MISTRAL_AI_API_KEY"))
.safePrompt(true)
.temperature(0.0)
.build();
// given
@ -119,16 +119,14 @@ class MistralAiChatModelIT {
// then
AiMessage aiMessage = response.content();
assertThat(aiMessage.text()).contains("respect");
assertThat(aiMessage.text()).contains("truth");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(50);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
assertThat(response.finishReason()).isEqualTo(STOP);
}
@Test
@ -148,7 +146,7 @@ class MistralAiChatModelIT {
assertThat(response.content().text()).contains("Ottawa");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(11 + 11 + 11);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -177,7 +175,7 @@ class MistralAiChatModelIT {
assertThat(response.content().text()).contains("Lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(18);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -206,7 +204,7 @@ class MistralAiChatModelIT {
assertThat(response.content().text()).contains("Lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(19);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -235,8 +233,8 @@ class MistralAiChatModelIT {
assertThat(response.content().text()).contains("Lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(15);
assertThat(tokenUsage.outputTokenCount()).isEqualTo(10);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -244,7 +242,7 @@ class MistralAiChatModelIT {
}
@Test
void should_execute_tool_using_model_open8x22B_and_return_finishReason_tool_execution(){
void should_execute_tool_using_model_open8x22B_and_return_finishReason_tool_execution() {
// given
UserMessage userMessage = userMessage("What is the status of transaction T123?");
@ -263,8 +261,8 @@ class MistralAiChatModelIT {
assertThat(toolExecutionRequest.arguments()).isEqualToIgnoringWhitespace("{\"transactionId\":\"T123\"}");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(78);
assertThat(tokenUsage.outputTokenCount()).isEqualTo(28);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -272,7 +270,7 @@ class MistralAiChatModelIT {
}
@Test
void should_execute_tool_using_model_open8x22B_when_toolChoice_is_auto_and_answer(){
void should_execute_tool_using_model_open8x22B_when_toolChoice_is_auto_and_answer() {
// given
ToolSpecification retrievePaymentDate = ToolSpecification.builder()
.name("retrieve-payment-date")
@ -284,7 +282,7 @@ class MistralAiChatModelIT {
UserMessage userMessage = userMessage("What is the status of transaction T123?");
chatMessages.add(userMessage);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus,retrievePaymentDate);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus, retrievePaymentDate);
// when
Response<AiMessage> response = openMixtral8x22BModel.generate(chatMessages, toolSpecifications);
@ -316,7 +314,7 @@ class MistralAiChatModelIT {
assertThat(aiMessage2.toolExecutionRequests()).isNull();
TokenUsage tokenUsage2 = response2.tokenUsage();
assertThat(tokenUsage2.inputTokenCount()).isEqualTo(74);
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.totalTokenCount())
.isEqualTo(tokenUsage2.inputTokenCount() + tokenUsage2.outputTokenCount());
@ -350,7 +348,7 @@ class MistralAiChatModelIT {
assertThat(toolExecutionRequest.arguments()).isEqualToIgnoringWhitespace("{\"transactionId\":\"T123\"}");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(79);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -372,7 +370,7 @@ class MistralAiChatModelIT {
assertThat(aiMessage2.toolExecutionRequests()).isNull();
TokenUsage tokenUsage2 = response2.tokenUsage();
assertThat(tokenUsage2.inputTokenCount()).isEqualTo(83);
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.totalTokenCount())
.isEqualTo(tokenUsage2.inputTokenCount() + tokenUsage2.outputTokenCount());
@ -381,7 +379,7 @@ class MistralAiChatModelIT {
}
@Test
void should_return_valid_json_object_using_model_large(){
void should_return_valid_json_object_using_model_large() {
// given
String userMessage = "Return JSON with two fields: transactionId and status with the values T123 and paid.";
@ -405,7 +403,7 @@ class MistralAiChatModelIT {
}
@Test
void should_execute_multiple_tools_using_model_open8x22B_then_answer(){
void should_execute_multiple_tools_using_model_open8x22B_then_answer() {
// given
ToolSpecification retrievePaymentDate = ToolSpecification.builder()
.name("retrieve-payment-date")
@ -417,7 +415,7 @@ class MistralAiChatModelIT {
UserMessage userMessage = userMessage("What is the status and the payment date of transaction T123?");
chatMessages.add(userMessage);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus,retrievePaymentDate);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus, retrievePaymentDate);
// when
Response<AiMessage> response = mistralLargeModel.generate(chatMessages, toolSpecifications);
@ -456,7 +454,7 @@ class MistralAiChatModelIT {
assertThat(aiMessage2.toolExecutionRequests()).isNull();
TokenUsage tokenUsage2 = response2.tokenUsage();
assertThat(tokenUsage2.inputTokenCount()).isEqualTo(132);
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.totalTokenCount())
.isEqualTo(tokenUsage2.inputTokenCount() + tokenUsage2.outputTokenCount());

View File

@ -18,7 +18,6 @@ import java.util.List;
import static dev.langchain4j.agent.tool.JsonSchemaProperty.STRING;
import static dev.langchain4j.data.message.UserMessage.userMessage;
import static dev.langchain4j.model.output.FinishReason.*;
import static dev.langchain4j.model.output.FinishReason.TOOL_EXECUTION;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
@ -70,7 +69,7 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("Lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(15);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -99,8 +98,8 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("Lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(15);
assertThat(tokenUsage.outputTokenCount()).isEqualTo(10);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -115,6 +114,7 @@ class MistralAiStreamingChatModelIT {
StreamingChatLanguageModel model = MistralAiStreamingChatModel.builder()
.apiKey(System.getenv("MISTRAL_AI_API_KEY"))
.safePrompt(true)
.temperature(0.0)
.build();
// given
@ -129,7 +129,7 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("respect");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(50);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -156,7 +156,7 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("ottawa");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(11 + 11 + 11);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -185,8 +185,8 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(13);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(1);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -214,8 +214,8 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(14);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(1);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -243,8 +243,8 @@ class MistralAiStreamingChatModelIT {
assertThat(response.content().text()).containsIgnoringCase("lima");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(15);
assertThat(tokenUsage.outputTokenCount()).isEqualTo(10);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -252,7 +252,7 @@ class MistralAiStreamingChatModelIT {
}
@Test
void should_execute_tool_using_model_open8x22B_and_return_finishReason_tool_execution(){
void should_execute_tool_using_model_open8x22B_and_return_finishReason_tool_execution() {
// given
UserMessage userMessage = userMessage("What is the status of transaction T123?");
@ -260,7 +260,7 @@ class MistralAiStreamingChatModelIT {
// when
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
openMixtral8x22BModel.generate(singletonList(userMessage), toolSpecifications,handler);
openMixtral8x22BModel.generate(singletonList(userMessage), toolSpecifications, handler);
Response<AiMessage> response = handler.get();
@ -274,8 +274,8 @@ class MistralAiStreamingChatModelIT {
assertThat(toolExecutionRequest.arguments()).isEqualToIgnoringWhitespace("{\"transactionId\":\"T123\"}");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(78);
assertThat(tokenUsage.outputTokenCount()).isEqualTo(28);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -283,7 +283,7 @@ class MistralAiStreamingChatModelIT {
}
@Test
void should_execute_tool_using_model_open8x22B_when_toolChoice_is_auto_and_answer(){
void should_execute_tool_using_model_open8x22B_when_toolChoice_is_auto_and_answer() {
// given
ToolSpecification retrievePaymentDate = ToolSpecification.builder()
.name("retrieve-payment-date")
@ -295,7 +295,7 @@ class MistralAiStreamingChatModelIT {
UserMessage userMessage = userMessage("What is the status of transaction T123?");
chatMessages.add(userMessage);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus,retrievePaymentDate);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus, retrievePaymentDate);
// when
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
@ -331,7 +331,7 @@ class MistralAiStreamingChatModelIT {
assertThat(aiMessage2.toolExecutionRequests()).isNull();
TokenUsage tokenUsage2 = response2.tokenUsage();
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(70);
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.totalTokenCount())
.isEqualTo(tokenUsage2.inputTokenCount() + tokenUsage2.outputTokenCount());
@ -367,7 +367,7 @@ class MistralAiStreamingChatModelIT {
assertThat(toolExecutionRequest.arguments()).isEqualToIgnoringWhitespace("{\"transactionId\":\"T123\"}");
TokenUsage tokenUsage = response.tokenUsage();
assertThat(tokenUsage.inputTokenCount()).isEqualTo(79);
assertThat(tokenUsage.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage.totalTokenCount())
.isEqualTo(tokenUsage.inputTokenCount() + tokenUsage.outputTokenCount());
@ -391,7 +391,7 @@ class MistralAiStreamingChatModelIT {
assertThat(aiMessage2.toolExecutionRequests()).isNull();
TokenUsage tokenUsage2 = response2.tokenUsage();
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(80);
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.totalTokenCount())
.isEqualTo(tokenUsage2.inputTokenCount() + tokenUsage2.outputTokenCount());
@ -400,7 +400,7 @@ class MistralAiStreamingChatModelIT {
}
@Test
void should_execute_multiple_tools_using_model_large_then_answer(){
void should_execute_multiple_tools_using_model_large_then_answer() {
// given
ToolSpecification retrievePaymentDate = ToolSpecification.builder()
.name("retrieve-payment-date")
@ -412,7 +412,7 @@ class MistralAiStreamingChatModelIT {
UserMessage userMessage = userMessage("What is the status and the payment date of transaction T123?");
chatMessages.add(userMessage);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus,retrievePaymentDate);
List<ToolSpecification> toolSpecifications = asList(retrievePaymentStatus, retrievePaymentDate);
// when
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
@ -455,7 +455,7 @@ class MistralAiStreamingChatModelIT {
assertThat(aiMessage2.toolExecutionRequests()).isNull();
TokenUsage tokenUsage2 = response2.tokenUsage();
assertThat(tokenUsage2.inputTokenCount()).isEqualTo(132);
assertThat(tokenUsage2.inputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.outputTokenCount()).isGreaterThan(0);
assertThat(tokenUsage2.totalTokenCount())
.isEqualTo(tokenUsage2.inputTokenCount() + tokenUsage2.outputTokenCount());
@ -464,7 +464,7 @@ class MistralAiStreamingChatModelIT {
}
@Test
void should_return_valid_json_object_using_model_large(){
void should_return_valid_json_object_using_model_large() {
// given
String userMessage = "Return JSON with two fields: transactionId and status with the values T123 and paid.";

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -82,6 +82,6 @@ class MongoDbEmbeddingStoreCloudIT extends EmbeddingStoreIT {
@Override
@SneakyThrows
protected void awaitUntilPersisted() {
Thread.sleep(2000);
Thread.sleep(3000);
}
}

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<packaging>pom</packaging>
<name>LangChain4j :: Parent POM</name>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -6,7 +6,7 @@
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-aggregator</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<packaging>pom</packaging>
<name>LangChain4j :: Aggregator</name>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-parent</artifactId>
<version>0.31.0-SNAPSHOT</version>
<version>0.31.0</version>
<relativePath>../../langchain4j-parent/pom.xml</relativePath>
</parent>