-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daniel Hu <[email protected]>
- Loading branch information
1 parent
7df12ae
commit 0cc3309
Showing
5 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ | |
}, | ||
"payload": { | ||
"setting": { | ||
"currentModel": "gpt-3.5" | ||
"currentModel": "gpt-3.5-turbo" | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/ai/devchat/devchat/handler/UpdateSettingRequestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package ai.devchat.devchat.handler; | ||
|
||
import ai.devchat.devchat.ActionHandler; | ||
import ai.devchat.devchat.DevChatActionHandler; | ||
import ai.devchat.devchat.DevChatActions; | ||
import ai.devchat.idea.setting.DevChatSettingsState; | ||
import com.alibaba.fastjson.JSONObject; | ||
|
||
public class UpdateSettingRequestHandler implements ActionHandler { | ||
private JSONObject metadata; | ||
private JSONObject payload; | ||
private final DevChatActionHandler devChatActionHandler; | ||
|
||
public UpdateSettingRequestHandler(DevChatActionHandler devChatActionHandler) { | ||
this.devChatActionHandler = devChatActionHandler; | ||
} | ||
|
||
@Override | ||
public void executeAction() { | ||
String callbackFunc = metadata.getString("callback"); | ||
JSONObject setting = payload.getJSONObject("setting"); | ||
|
||
try { | ||
DevChatSettingsState settings = DevChatSettingsState.getInstance(); | ||
if (setting.containsKey("currentModel")) { | ||
settings.defaultModel = setting.getString("currentModel"); | ||
} | ||
|
||
devChatActionHandler.sendResponse(DevChatActions.UPDATE_SETTING_RESPONSE, callbackFunc, (metadata, payload) -> { | ||
metadata.put("status", "success"); | ||
metadata.put("error", ""); | ||
}); | ||
} catch (Exception e) { | ||
devChatActionHandler.sendResponse(DevChatActions.UPDATE_SETTING_RESPONSE, callbackFunc, (metadata, payload) -> { | ||
metadata.put("status", "Failed"); | ||
metadata.put("error", "Failed to update setting." + e.getMessage()); | ||
}); | ||
} | ||
} | ||
|
||
@Override | ||
public void setMetadata(JSONObject metadata) { | ||
this.metadata = metadata; | ||
} | ||
|
||
@Override | ||
public void setPayload(JSONObject payload) { | ||
this.payload = payload; | ||
} | ||
} |