Skip to content

Commit

Permalink
Fix some bugs
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 17, 2023
1 parent ee7b30b commit 0a75c71
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", "");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,29 @@ public void executeAction() {
Map<String, String> flags = new HashMap<>();

JSONArray contextArray = payload.getJSONArray("contexts");
List<String> 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<String> 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);
}
Expand Down

0 comments on commit 0a75c71

Please sign in to comment.