Skip to content

Commit

Permalink
Marked obvious @Deprecated candidates forRemoval = true (langchai…
Browse files Browse the repository at this point in the history
…n4j#2028)

## Change
Marked obvious `@Deprecated` candidates `forRemoval = true`

## General checklist
- [X] There are no breaking changes
- [ ] I have added unit and integration tests for my change
- [ ] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
  • Loading branch information
dliubarskyi authored Nov 7, 2024
1 parent aa51ddb commit 76190c2
Show file tree
Hide file tree
Showing 44 changed files with 171 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ApacheTikaDocumentParser() {
* @param parseContext Tika parse context. Default: empty {@link ParseContext}
* @deprecated Use the constructor with suppliers for Tika components if you intend to use this parser for multiple files.
*/
@Deprecated
@Deprecated(forRemoval = true)
public ApacheTikaDocumentParser(Parser parser,
ContentHandler contentHandler,
Metadata metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ public AnthropicChatModelBuilder modelName(AnthropicChatModelName modelName) {
}

/**
* @deprecated use {@code builder()} instead and explicitly set the model name and, if required, other parameters.
* @deprecated Please use {@code builder()} instead, and explicitly set the model name and,
* if necessary, other parameters.
* <b>The default value for the model name will be removed in future releases!</b>
*/
@Deprecated
@Deprecated(forRemoval = true)
public static AnthropicChatModel withApiKey(String apiKey) {
return builder().apiKey(apiKey).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ public AnthropicStreamingChatModelBuilder modelName(AnthropicChatModelName model
}

/**
* @deprecated use {@code builder()} instead and explicitly set the model name and, if required, other parameters.
* @deprecated Please use {@code builder()} instead, and explicitly set the model name and,
* if necessary, other parameters.
* <b>The default value for the model name will be removed in future releases!</b>
*/
@Deprecated
@Deprecated(forRemoval = true)
public static AnthropicStreamingChatModel withApiKey(String apiKey) {
return builder().apiKey(apiKey).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @deprecated use {@link AzureOpenAiChatModelName}, {@link AzureOpenAiEmbeddingModelName}, {@link AzureOpenAiImageModelName} and {@link AzureOpenAiLanguageModelName}, instead.
*/
@Deprecated
@Deprecated(forRemoval = true)
public class AzureOpenAiModelName {

// Use with AzureOpenAiChatModel and AzureOpenAiStreamingChatModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public Builder logRequestsAndResponses(boolean logRequestsAndResponses) {
* @return builder with the useAsyncClient parameter set
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@Deprecated(forRemoval = true)
public Builder useAsyncClient(boolean useAsyncClient) {
this.useAsyncClient = useAsyncClient;
return this;
Expand All @@ -688,7 +688,7 @@ public Builder useAsyncClient(boolean useAsyncClient) {
* @return builder
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@Deprecated(forRemoval = true)
public Builder openAIClient(OpenAIClient openAIClient) {
this.openAIClient = openAIClient;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public CohereEmbeddingModel(String baseUrl,
}

/**
* @deprecated use {@code builder()} instead and explicitly set the model name and, if required, other parameters.
* @deprecated Please use {@code builder()} instead, and explicitly set the model name and,
* if necessary, other parameters.
*/
@Deprecated
@Deprecated(forRemoval = true)
public static CohereEmbeddingModel withApiKey(String apiKey) {
return builder().apiKey(apiKey).build();
}
Expand Down Expand Up @@ -114,4 +115,4 @@ private static Integer getTokenUsage(EmbedResponse response) {
}
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ public CohereScoringModel(
}

/**
* @deprecated use {@code builder()} instead and explicitly set the model name and, if required, other parameters.
* @deprecated Please use {@code builder()} instead, and explicitly set the model name and,
* if necessary, other parameters.
*/
@Deprecated
@Deprecated(forRemoval = true)
public static CohereScoringModel withApiKey(String apiKey) {
return builder().apiKey(apiKey).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,61 +24,61 @@
*
* @deprecated please use the new {@link JsonSchemaElement} API instead to define the schema for tool parameters
*/
@Deprecated
@Deprecated(forRemoval = true)
public class JsonSchemaProperty {

/**
* A property with key "type" and value "string".
*
* @deprecated please use {@link JsonStringSchema#JsonStringSchema()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty STRING = type("string");

/**
* A property with key "type" and value "integer".
*
* @deprecated please use {@link JsonIntegerSchema#JsonIntegerSchema()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty INTEGER = type("integer");

/**
* A property with key "type" and value "number".
*
* @deprecated please use {@link JsonNumberSchema#JsonNumberSchema()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty NUMBER = type("number");

/**
* A property with key "type" and value "object".
*
* @deprecated please use {@link JsonObjectSchema#builder} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty OBJECT = type("object");

/**
* A property with key "type" and value "array".
*
* @deprecated please use {@link JsonArraySchema#builder} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty ARRAY = type("array");

/**
* A property with key "type" and value "boolean".
*
* @deprecated please use {@link JsonBooleanSchema#JsonBooleanSchema()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty BOOLEAN = type("boolean");

/**
* A property with key "type" and value "null".
*/
@Deprecated
@Deprecated(forRemoval = true)
public static final JsonSchemaProperty NULL = type("null");

private final String key;
Expand All @@ -91,7 +91,7 @@ public class JsonSchemaProperty {
* @param value the value.
* @deprecated please use the new {@link JsonSchemaElement} API instead to define the schema for tool parameters
*/
@Deprecated
@Deprecated(forRemoval = true)
public JsonSchemaProperty(String key, Object value) {
this.key = key;
this.value = value;
Expand Down Expand Up @@ -166,7 +166,7 @@ public String toString() {
* @return a property with key and value.
* @deprecated please use the new {@link JsonSchemaElement} API instead to define the schema for tool parameters
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty from(String key, Object value) {
return new JsonSchemaProperty(key, value);
}
Expand All @@ -181,7 +181,7 @@ public static JsonSchemaProperty from(String key, Object value) {
* @return a property with key and value.
* @deprecated please use the new {@link JsonSchemaElement} API instead to define the schema for tool parameters
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty property(String key, Object value) {
return from(key, value);
}
Expand All @@ -195,7 +195,7 @@ public static JsonSchemaProperty property(String key, Object value) {
* @return a property with key and value.
* @deprecated please use the new {@link JsonSchemaElement} API instead to define the schema for tool parameters
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty type(String value) {
return from("type", value);
}
Expand All @@ -209,7 +209,7 @@ public static JsonSchemaProperty type(String value) {
* @return a property with key and value.
* @deprecated please use the new {@link JsonSchemaElement} API instead to define the schema for tool parameters
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty description(String value) {
return from("description", value);
}
Expand All @@ -221,7 +221,7 @@ public static JsonSchemaProperty description(String value) {
* @return a property with key "enum" and value enumValues
* @deprecated please use {@link JsonEnumSchema} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty enums(String... enumValues) {
return from("enum", enumValues);
}
Expand All @@ -235,7 +235,7 @@ public static JsonSchemaProperty enums(String... enumValues) {
* @return a property with key "enum" and value enumValues
* @deprecated please use {@link JsonEnumSchema} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty enums(Object... enumValues) {
List<String> enumNames = new ArrayList<>();
for (Object enumValue : enumValues) {
Expand All @@ -254,7 +254,7 @@ public static JsonSchemaProperty enums(Object... enumValues) {
* @return a property with key "enum" and values taken from enumClass
* @deprecated please use {@link JsonEnumSchema} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty enums(Class<?> enumClass) {
if (!enumClass.isEnum()) {
throw new RuntimeException("Class " + enumClass.getName() + " should be enum");
Expand All @@ -269,15 +269,15 @@ public static JsonSchemaProperty enums(Class<?> enumClass) {
* @return a property with key "items" and value type.
* @deprecated please use {@link JsonArraySchema} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty items(JsonSchemaProperty type) {
return from("items", singletonMap(type.key, type.value));
}

/**
* @deprecated please use {@link JsonObjectSchema} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static JsonSchemaProperty objectItems(JsonSchemaProperty type) {
Map<String, Object> map = new HashMap<>();
map.put("type", "object");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* .build();
* </pre>
*/
@Deprecated
@Deprecated(forRemoval = true)
public class ToolParameters {

private final String type;
Expand Down Expand Up @@ -115,7 +115,7 @@ public String toString() {
* @return a {@link Builder}.
* @deprecated please use {@link JsonObjectSchema#builder()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public static Builder builder() {
return new Builder();
}
Expand All @@ -141,7 +141,7 @@ private Builder() {
* @return the {@code Builder}.
* @deprecated please use {@link JsonObjectSchema#builder()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder type(String type) {
this.type = type;
return this;
Expand All @@ -154,7 +154,7 @@ public Builder type(String type) {
* @return the {@code Builder}.
* @deprecated please use {@link JsonObjectSchema.Builder#properties(Map)} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder properties(Map<String, Map<String, Object>> properties) {
this.properties = properties;
return this;
Expand All @@ -167,7 +167,7 @@ public Builder properties(Map<String, Map<String, Object>> properties) {
* @return the {@code Builder}.
* @deprecated please use {@link JsonObjectSchema.Builder#required(List)} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder required(List<String> required) {
this.required = required;
return this;
Expand All @@ -179,7 +179,7 @@ public Builder required(List<String> required) {
* @return a {@code ToolParameters} built with parameters of this {@code ToolParameters.Builder}
* @deprecated please use {@link JsonObjectSchema.Builder#build()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public ToolParameters build() {
return new ToolParameters(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ToolSpecification {
private final String name;
private final String description;
private final JsonObjectSchema parameters;
@Deprecated
@Deprecated(forRemoval = true)
private final ToolParameters toolParameters;

/**
Expand Down Expand Up @@ -68,7 +68,7 @@ public JsonObjectSchema parameters() {
/**
* @deprecated please use {@link #parameters()} instead
*/
@Deprecated
@Deprecated(forRemoval = true)
public ToolParameters toolParameters() {
return toolParameters;
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public static final class Builder {
private String name;
private String description;
private JsonObjectSchema parameters;
@Deprecated
@Deprecated(forRemoval = true)
private ToolParameters toolParameters;

/**
Expand Down Expand Up @@ -184,7 +184,7 @@ public Builder parameters(JsonObjectSchema parameters) {
* .build();
* </pre>
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder parameters(ToolParameters parameters) {
this.toolParameters = parameters;
return this;
Expand All @@ -209,7 +209,7 @@ public Builder parameters(ToolParameters parameters) {
* .build();
* </pre>
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder addParameter(String name, JsonSchemaProperty... jsonSchemaProperties) {
return addParameter(name, asList(jsonSchemaProperties));
}
Expand All @@ -233,7 +233,7 @@ public Builder addParameter(String name, JsonSchemaProperty... jsonSchemaPropert
* .build();
* </pre>
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder addParameter(String name, Iterable<JsonSchemaProperty> jsonSchemaProperties) {
addOptionalParameter(name, jsonSchemaProperties);
this.toolParameters.required().add(name);
Expand All @@ -259,7 +259,7 @@ public Builder addParameter(String name, Iterable<JsonSchemaProperty> jsonSchema
* .build();
* </pre>
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder addOptionalParameter(String name, JsonSchemaProperty... jsonSchemaProperties) {
return addOptionalParameter(name, asList(jsonSchemaProperties));
}
Expand All @@ -283,7 +283,7 @@ public Builder addOptionalParameter(String name, JsonSchemaProperty... jsonSchem
* .build();
* </pre>
*/
@Deprecated
@Deprecated(forRemoval = true)
public Builder addOptionalParameter(String name, Iterable<JsonSchemaProperty> jsonSchemaProperties) {
if (this.toolParameters == null) {
this.toolParameters = ToolParameters.builder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public Metadata metadata() {
* {@link Metadata#getInteger(String)}, {@link Metadata#getLong(String)}, {@link Metadata#getFloat(String)},
* {@link Metadata#getDouble(String)} instead.
*/
@Deprecated
@Deprecated(forRemoval = true)
public String metadata(String key) {
return metadata.get(key);
}
Expand Down
Loading

0 comments on commit 76190c2

Please sign in to comment.