Skip to content

Commit

Permalink
Hotfix NPE risks.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaopengjun committed Dec 1, 2023
1 parent 5fb2f5c commit db1dbb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public String getName() {

public static ModelServiceEnum fromName(String name) {
if (name == null) {
return null;
return OPENAI;
}
for (ModelServiceEnum type : ModelServiceEnum.values()) {
if (type.getName().equals(name)) {
return type;
}
}
return null;
return OPENAI;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/zhongan/devpilot/enums/ModelTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public String getName() {

public static ModelTypeEnum fromName(String name) {
if (name == null) {
return null;
return GPT3_5;
}
for (ModelTypeEnum type : ModelTypeEnum.values()) {
if (type.getName().equals(name)) {
return type;
}
}
return null;
return GPT3_5;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/zhongan/devpilot/enums/SessionTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public String getDesc() {

public static SessionTypeEnum getEnumByCode(Integer code) {
if (Objects.isNull(code)) {
return null;
return MULTI_TURN;
}
for (SessionTypeEnum type : SessionTypeEnum.values()) {
if (type.getCode().equals(code)) {
return type;
}
}
return null;
return MULTI_TURN;
}
}

0 comments on commit db1dbb7

Please sign in to comment.