Skip to content

Commit

Permalink
Fix: command without message error & default model logic
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Hu <[email protected]>
  • Loading branch information
daniel-hutao committed Nov 22, 2023
1 parent 40dd7ae commit 8bf9648
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/ai/devchat/cli/DevChatWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private void readOutputByLine(InputStream inputStream, Consumer<String> callback

public void runPromptCommand(Map<String, List<String>> flags, String message, Consumer<String> callback) {
try {
flags.put("model", Collections.singletonList(currentModel));
List<String> commands = prepareCommand("prompt", flags, message);
execCommand(commands, callback);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ private String handleCommandAndInstruct(String message, Map<String, List<String>
// Loop through the command names and check if message starts with it
for (String command : commandNamesList) {
if (message.startsWith("/" + command + " ")) {
message = message.substring(command.length() + 2); // +2 to take into account the '/' and the space ' '
if (message.length() > command.length() + 2) {
message = message.substring(command.length() + 2); // +2 to take into account the '/' and the space ' '
}
runResult = devchatWrapper.runRunCommand(command, null);
break;
}
Expand Down

0 comments on commit 8bf9648

Please sign in to comment.