Skip to content

Commit

Permalink
Qianfan: run ITs when API key is available
Browse files Browse the repository at this point in the history
  • Loading branch information
langchain4j committed Jan 26, 2024
1 parent 9ab9b1e commit 25ebc67
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import dev.langchain4j.model.output.Response;
import dev.langchain4j.model.output.TokenUsage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import java.util.List;
import static dev.langchain4j.agent.tool.JsonSchemaProperty.INTEGER;
import static dev.langchain4j.data.message.ToolExecutionResultMessage.from;
Expand All @@ -18,12 +20,12 @@
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;

@EnabledIfEnvironmentVariable(named = "QIANFAN_API_KEY", matches = ".+")
class QianfanChatModelIT {

//see your api key and secret key here: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application
private String apiKey ="your api key";
private String secretKey ="your secret key";

private String apiKey = System.getenv("QIANFAN_API_KEY");
private String secretKey = System.getenv("QIANFAN_SECRET_KEY");

QianfanChatModel model = QianfanChatModel.builder().modelName("ERNIE-Bot 4.0").temperature(0.7).topP(1.0).maxRetries(1)
.apiKey(apiKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
import dev.langchain4j.model.output.Response;
import dev.langchain4j.model.output.TokenUsage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import java.util.ArrayList;
import java.util.List;

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

@EnabledIfEnvironmentVariable(named = "QIANFAN_API_KEY", matches = ".+")
class QianfanEmbeddingModelIT {

//see your api key and secret key here: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application
private String apiKey ="your api key";
private String secretKey ="your secret key";
private String apiKey = System.getenv("QIANFAN_API_KEY");
private String secretKey = System.getenv("QIANFAN_SECRET_KEY");

QianfanEmbeddingModel model = QianfanEmbeddingModel.builder().user("111").apiKey(apiKey)
.secretKey(secretKey).endpoint("embedding-v1").build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import dev.langchain4j.model.output.Response;
import dev.langchain4j.model.output.TokenUsage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

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

@EnabledIfEnvironmentVariable(named = "QIANFAN_API_KEY", matches = ".+")
class QianfanLanguageModelIT {

//see your api key and secret key here: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application
private String apiKey ="your api key";
private String secretKey ="your secret key";
private String apiKey = System.getenv("QIANFAN_API_KEY");
private String secretKey = System.getenv("QIANFAN_SECRET_KEY");

QianfanLanguageModel model = QianfanLanguageModel.builder().endpoint("codellama_7b_instruct").topP(1.0).maxRetries(1)
.apiKey(apiKey)
.secretKey(secretKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import dev.langchain4j.model.output.Response;
import dev.langchain4j.model.output.TokenUsage;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import java.util.List;
import static dev.langchain4j.agent.tool.JsonSchemaProperty.INTEGER;
import static dev.langchain4j.data.message.ToolExecutionResultMessage.from;
Expand All @@ -20,12 +22,13 @@
import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;


@EnabledIfEnvironmentVariable(named = "QIANFAN_API_KEY", matches = ".+")
class QianfanStreamingChatModelIT {

//see your api key and secret key here: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application
private String apiKey ="your api key";
private String secretKey ="your secret key";
private String apiKey = System.getenv("QIANFAN_API_KEY");
private String secretKey = System.getenv("QIANFAN_SECRET_KEY");

QianfanStreamingChatModel model = QianfanStreamingChatModel.builder().modelName("ERNIE-Bot 4.0").temperature(0.7).topP(1.0)
.apiKey(apiKey)
.secretKey(secretKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
import dev.langchain4j.model.chat.TestStreamingResponseHandler;
import dev.langchain4j.model.output.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

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

@EnabledIfEnvironmentVariable(named = "QIANFAN_API_KEY", matches = ".+")
class QianfanStreamingLanguageModelIT {

//see your api key and secret key here: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application
private String apiKey ="your api key";
private String secretKey ="your secret key";
private String apiKey = System.getenv("QIANFAN_API_KEY");
private String secretKey = System.getenv("QIANFAN_SECRET_KEY");

QianfanStreamingLanguageModel model = QianfanStreamingLanguageModel.builder().endpoint("sqlcoder_7b").topP(1.0).maxRetries(1)
.apiKey(apiKey)
.secretKey(secretKey)
Expand Down

0 comments on commit 25ebc67

Please sign in to comment.