diff --git a/src/main/java/ai/devchat/devchat/handler/AddContextNotifyHandler.java b/src/main/java/ai/devchat/devchat/handler/AddContextNotifyHandler.java index 1b70a2a..035c344 100644 --- a/src/main/java/ai/devchat/devchat/handler/AddContextNotifyHandler.java +++ b/src/main/java/ai/devchat/devchat/handler/AddContextNotifyHandler.java @@ -11,7 +11,7 @@ public class AddContextNotifyHandler implements ActionHandler { private JSONObject payload; private final DevChatActionHandler devChatActionHandler; - public final String RESPONSE_FUNC = "AddContextFromEditor"; + public final String RESPONSE_FUNC = "IdeaToJSMessage"; public AddContextNotifyHandler(DevChatActionHandler devChatActionHandler) { this.devChatActionHandler = devChatActionHandler; diff --git a/src/main/java/ai/devchat/devchat/handler/ListModelsRequestHandler.java b/src/main/java/ai/devchat/devchat/handler/ListModelsRequestHandler.java index 1fc6385..eecbc23 100644 --- a/src/main/java/ai/devchat/devchat/handler/ListModelsRequestHandler.java +++ b/src/main/java/ai/devchat/devchat/handler/ListModelsRequestHandler.java @@ -29,7 +29,7 @@ public void executeAction() { modelList.add("gpt-3.5-turbo"); modelList.add("gpt-4"); - devChatActionHandler.sendResponse(DevChatActions.LIST_CONTEXTS_RESPONSE, callbackFunc, (metadata, payload) -> { + devChatActionHandler.sendResponse(DevChatActions.LIST_MODELS_RESPONSE, callbackFunc, (metadata, payload) -> { metadata.put("status", "success"); metadata.put("error", ""); diff --git a/src/main/java/ai/devchat/devchat/handler/SendMessageRequestHandler.java b/src/main/java/ai/devchat/devchat/handler/SendMessageRequestHandler.java index 335fd7e..790e29d 100644 --- a/src/main/java/ai/devchat/devchat/handler/SendMessageRequestHandler.java +++ b/src/main/java/ai/devchat/devchat/handler/SendMessageRequestHandler.java @@ -48,28 +48,29 @@ public void executeAction() { Map flags = new HashMap<>(); JSONArray contextArray = payload.getJSONArray("contexts"); - List contextFilePaths = new ArrayList<>(); - for (int i = 0; i < contextArray.size(); i++) { - JSONObject context = contextArray.getJSONObject(i); - String contextType = context.getString("type"); - String contextPath = null; - - if ("code".equals(contextType)) { - String path = context.getString("path"); - String filename = path.substring(path.lastIndexOf("/") + 1, path.length()); - contextPath = createTempFileFromContext(context, filename); - } else if ("command".equals(contextType)) { - contextPath = createTempFileFromContext(context, "custom.txt"); - } - - if (contextPath != null) { - contextFilePaths.add(contextPath); - Log.info("Context file path: " + contextPath); + if (contextArray != null) { + List contextFilePaths = new ArrayList<>(); + for (int i = 0; i < contextArray.size(); i++) { + JSONObject context = contextArray.getJSONObject(i); + String contextType = context.getString("type"); + String contextPath = null; + + if ("code".equals(contextType)) { + String path = context.getString("path"); + String filename = path.substring(path.lastIndexOf("/") + 1, path.length()); + contextPath = createTempFileFromContext(context, filename); + } else if ("command".equals(contextType)) { + contextPath = createTempFileFromContext(context, "custom.txt"); + } + + if (contextPath != null) { + contextFilePaths.add(contextPath); + Log.info("Context file path: " + contextPath); + } } + flags.put("context", String.join(",", contextFilePaths)); } - flags.put("context", String.join(",", contextFilePaths)); - if (parent != null && !parent.isEmpty()) { flags.put("parent", parent); }