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

Simplify the implementation of ChatClient-based interfaces #1663

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jxblum
Copy link
Contributor

@jxblum jxblum commented Nov 4, 2024

Provide sensible defaults for overloaded methods in PromptUserSpec, PromptSystemSpec, AdvisorSpec, CallResponseSpec, ChatClientRequestSpec, and Builder interfaces.

Provide sensible defaults for overloaded methods in PromptUserSpec, PromptSystemSpec, AdvisorSpec, CallResponseSpec, ChatClientRequestSpec, and Builder interfaces.

Closes spring-projects#1663
@markpollack
Copy link
Member

markpollack commented Nov 6, 2024

I'd like to keep the interfaces without any defaults as in WebClient and other spring projects. This PR also introduces a conflict in that the single implementation of the existing spec classes have different behavior it seems at first glance. I took a look at PromptUserSpec for example.

@Override
public PromptUserSpec text(String text) {
	Assert.hasText(text, "text cannot be null or empty");
	this.text = text;
	return this;
}

vs.

default PromptUserSpec text(String text) {
	Charset defaultCharset = Charset.defaultCharset();
	return text(new ByteArrayResource(text.getBytes(defaultCharset)), defaultCharset);
}

What is wrong with using the string as supplied i the current impl?

In anycase, these impls are used in one place, so if there are changes to make in the impl, i'd do it there and not default method interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants