Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing package-info to core packages #1295

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.core.io.ClassPathResource;
import org.springframework.lang.Nullable;

public class KnuddelsRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
hints.resources().registerResource(new ClassPathResource("/com/knuddels/jtokkit/cl100k_base.tiktoken"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.core.io.ClassPathResource;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.ReflectionUtils;

Expand All @@ -39,7 +38,7 @@
public class SpringAiCoreRuntimeHints implements RuntimeHintsRegistrar {

@Override
public void registerHints(@NonNull RuntimeHints hints, @Nullable ClassLoader classLoader) {
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {

var chatTypes = Set.of(AbstractMessage.class, AssistantMessage.class, ToolResponseMessage.class, Message.class,
MessageType.class, UserMessage.class, SystemMessage.class, FunctionCallbackContext.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Package for AOT runtime hints.
*/
@NonNullApi
@NonNullFields
package org.springframework.ai.aot;

import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 - 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.audio.transcription;

import org.springframework.ai.model.ModelResult;
Expand All @@ -25,12 +26,14 @@
*
* @author Michael Lavelle
* @author Piotr Olaszewski
* @author Soby Chacko
* @since 0.8.1
*/
public class AudioTranscription implements ModelResult<String> {

private final String text;

@Nullable
private AudioTranscriptionMetadata transcriptionMetadata;

public AudioTranscription(String text) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 - 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.audio.transcription;

import org.springframework.ai.model.ResultMetadata;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 - 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.audio.transcription;

import org.springframework.ai.model.ModelOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 - 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.audio.transcription;

import org.springframework.ai.model.ModelRequest;
import org.springframework.core.io.Resource;
import org.springframework.lang.Nullable;

/**
* Represents an audio transcription prompt for an AI model. It implements the
Expand All @@ -25,12 +27,14 @@
*
* @author Michael Lavelle
* @author Piotr Olaszewski
* @author Soby Chacko
* @since 0.8.1
*/
public class AudioTranscriptionPrompt implements ModelRequest<Resource> {

private final Resource audioResource;

@Nullable
private AudioTranscriptionOptions modelOptions;

/**
Expand All @@ -50,7 +54,7 @@ public AudioTranscriptionPrompt(Resource audioResource) {
* @param audioResource resource of the audio file.
* @param modelOptions
*/
public AudioTranscriptionPrompt(Resource audioResource, AudioTranscriptionOptions modelOptions) {
public AudioTranscriptionPrompt(Resource audioResource, @Nullable AudioTranscriptionOptions modelOptions) {
this.audioResource = audioResource;
this.modelOptions = modelOptions;
}
Expand All @@ -61,8 +65,9 @@ public Resource getInstructions() {
}

@Override
@Nullable
public AudioTranscriptionOptions getOptions() {
return modelOptions;
return this.modelOptions;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 - 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.audio.transcription;

import org.springframework.ai.model.ModelResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 - 2024 the original author or authors.
* Copyright 2023-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.audio.transcription;

import org.springframework.ai.model.MutableResponseMetadata;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Package for audio transcription components.
*/
@NonNullApi
@NonNullFields
package org.springframework.ai.audio.transcription;

import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024-2024 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.chat.client.advisor;

import java.util.Map;
Expand All @@ -37,13 +38,9 @@ public class SimpleLoggerAdvisor implements RequestResponseAdvisor {

private static final Logger logger = LoggerFactory.getLogger(SimpleLoggerAdvisor.class);

public static final Function<AdvisedRequest, String> DEFAULT_REQUEST_TO_STRING = (request) -> {
return request.toString();
};
public static final Function<AdvisedRequest, String> DEFAULT_REQUEST_TO_STRING = Record::toString;

public static final Function<ChatResponse, String> DEFAULT_RESPONSE_TO_STRING = (response) -> {
return ModelOptionsUtils.toJsonString(response);
};
public static final Function<ChatResponse, String> DEFAULT_RESPONSE_TO_STRING = ModelOptionsUtils::toJsonString;

private final Function<AdvisedRequest, String> requestToString;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 - 2024 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,19 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.chat.client.advisor.observation;

import java.util.Map;

import org.springframework.ai.chat.client.AdvisedRequest;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;

import io.micrometer.observation.Observation;

/**
* @author Christian Tzolov
* @author Soby Chacko
* @since 1.0.0
*/

Expand All @@ -37,36 +40,43 @@ public enum Type {

}

@Nullable
private String advisorName;

@Nullable
private Type advisorType;

/**
* The {@link AdvisedRequest} data to be advised. Represents the row
* {@link ChatClient.ChatClientRequestSpec} data before sealed into a {@link Prompt}.
*/
@Nullable
private AdvisedRequest advisorRequest;

/**
* The shared data between the advisors in the chain. It is shared between all request
* and response advising points of all advisors in the chain.
*/
@Nullable
private Map<String, Object> advisorRequestContext;

/**
* the shared data between the advisors in the chain. It is shared between all request
* and response advising points of all advisors in the chain.
*/
@Nullable
private Map<String, Object> advisorResponseContext;

public void setAdvisorName(String advisorName) {
this.advisorName = advisorName;
}

@Nullable
public String getAdvisorName() {
return this.advisorName;
}

@Nullable
public Type getAdvisorType() {
return this.advisorType;
}
Expand All @@ -75,6 +85,7 @@ public void setAdvisorType(Type type) {
this.advisorType = type;
}

@Nullable
public AdvisedRequest getAdvisedRequest() {
return this.advisorRequest;
}
Expand All @@ -83,6 +94,7 @@ public void setAdvisedRequest(AdvisedRequest advisedRequest) {
this.advisorRequest = advisedRequest;
}

@Nullable
public Map<String, Object> getAdvisorRequestContext() {
return this.advisorRequestContext;
}
Expand All @@ -91,6 +103,7 @@ public void setAdvisorRequestContext(Map<String, Object> advisorRequestContext)
this.advisorRequestContext = advisorRequestContext;
}

@Nullable
public Map<String, Object> getAdvisorResponseContext() {
return this.advisorResponseContext;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 - 2024 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.chat.client.advisor.observation;

import io.micrometer.common.docs.KeyName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public KeyValues getHighCardinalityKeyValues(AdvisorObservationContext context)
return KeyValues.of(advisorName(context));
}

protected KeyValue advisorName(AdvisorObservationContext context) {
if (context.getAdvisorType() != null) {
protected KeyValue advisorName(@Nullable AdvisorObservationContext context) {
if (context != null && context.getAdvisorType() != null) {
return KeyValue.of(HighCardinalityKeyNames.ADVISOR_NAME, context.getAdvisorName());
}
return ADVISOR_NAME_NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ObservableRequestResponseAdvisor implements RequestResponseAdvisor

private final ObservationRegistry observationRegistry;

@Nullable
private final AdvisorObservationConvention customObservationConvention;

public ObservableRequestResponseAdvisor(RequestResponseAdvisor targetAdvisor,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Package for chat client advisor observability components.
*/
@NonNullApi
@NonNullFields
package org.springframework.ai.chat.client.advisor.observation;

import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Package containing chat client advisor components.
*/
@NonNullApi
@NonNullFields
package org.springframework.ai.chat.client.advisor;

import org.springframework.lang.NonNullApi;
import org.springframework.lang.NonNullFields;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.ai.chat.client.observation;

import java.util.stream.Collectors;
Expand Down
Loading