Skip to content

Commit

Permalink
offer default implement for base language model
Browse files Browse the repository at this point in the history
  • Loading branch information
lingjue@ubuntu committed Sep 11, 2023
1 parent 4153d69 commit c54a9a7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public interface BaseLanguageModel {
/**
* Predict text from text.
*/
String predict(String text);
default String predict(String text) {
return predict(text, null);
}

/**
* Predict text from text.
Expand All @@ -49,10 +51,14 @@ public interface BaseLanguageModel {
/**
* Predict message from messages.
*/
BaseMessage predictMessages(List<BaseMessage> messages);
default BaseMessage predictMessages(List<BaseMessage> messages) {
return predictMessages(messages, null);
}

/**
* Predict message from messages.
*/
BaseMessage predictMessages(List<BaseMessage> messages, List<String> stop);


}
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ public BaseMessage call(List<BaseMessage> messages, List<String> stop) {
}
}

@Override
public String predict(String text) {
return predict(text, null);
}

@Override
public String predict(String text, List<String> stop) {
List<String> copyStop = stop != null ? List.copyOf(stop) : null;
Expand All @@ -104,11 +99,6 @@ public String predict(String text, List<String> stop) {
return result.getContent();
}

@Override
public BaseMessage predictMessages(List<BaseMessage> messages) {
return predictMessages(messages, null);
}

@Override
public BaseMessage predictMessages(List<BaseMessage> messages, List<String> stop) {
List<String> copyStop = stop != null ? List.copyOf(stop) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,11 @@ public LLMResult generatePrompt(List<PromptValue> prompts, List<String> stop) {
return generate(promptStrings, stop);
}

@Override
public String predict(String text) {
return predict(text, null);
}

@Override
public String predict(String text, List<String> stop) {
return call(text, stop);
}

@Override
public BaseMessage predictMessages(List<BaseMessage> messages) {
return predictMessages(messages, null);
}

@Override
public BaseMessage predictMessages(List<BaseMessage> messages, List<String> stop) {
return null;
Expand Down

0 comments on commit c54a9a7

Please sign in to comment.