Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
fix(cli): fix reset cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
KeJunMao committed Feb 18, 2023
1 parent d4a70f0 commit 44987aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ChatHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WebSocket } from "ws";
import { DELIMITER } from "./constant";
import { createRequest } from "./request";
import { Conversation } from "./types";
import { appendIdentifier, createHeaders, logger } from "./utils";
import { appendIdentifier, createHeaders } from "./utils";
import TypedEmitter from "typed-emitter";

type ChatHubEvents = {
Expand Down
13 changes: 6 additions & 7 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { EdgeGPTConfig } from "../types";

import prompts, { Choice } from "prompts";
import { ChatBot } from "../ChatBot";
import { logger } from "../utils";
import chalk from "chalk";

export const run = async (options: Partial<EdgeGPTConfig>) => {
Expand Down Expand Up @@ -43,8 +42,8 @@ export const run = async (options: Partial<EdgeGPTConfig>) => {
break;
}
if (cmd.prompt === "!reset") {
chatBot.reset();
break;
await chatBot.reset();
continue;
}
let wrote = 0;
let response: any;
Expand All @@ -64,13 +63,13 @@ export const run = async (options: Partial<EdgeGPTConfig>) => {
);
}
try {
choices = response["item"]["messages"][1]["suggestedResponses"].map(
(v: any) => {
choices = response["item"]["messages"][1]["suggestedResponses"]
.map((v: any) => {
return {
title: v.text,
};
}
);
})
.filter((v: Choice) => typeof v.title === "string");
} catch (error) {}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { v4 as uuidv4 } from "uuid";
import _ from "lodash";
import { DELIMITER } from "./constant";
import { Cookie } from "./types";
import { createWriteStream } from "fs";

export const logger = consola.create({
defaults: {
Expand Down Expand Up @@ -50,3 +51,5 @@ export const stringifyCookie = (cookie: Cookie) =>
pre += `${cur.name}=${cur.value};`;
return pre;
}, "");

export const loggerFile = createWriteStream("./edgegpt.log");

0 comments on commit 44987aa

Please sign in to comment.