Delete log via client
This commit is contained in:
parent
2be88bd9ad
commit
84ef68c500
@ -1,4 +1,3 @@
|
|||||||
// import DevChat, { ChatOptions, ChatResponse } from '../toolwrapper/devchat';
|
|
||||||
import { logger } from '../util/logger';
|
import { logger } from '../util/logger';
|
||||||
import { assertValue } from '../util/check';
|
import { assertValue } from '../util/check';
|
||||||
import { DevChatClient, ChatRequest, ChatResponse, buildRoleContextsFromFiles, LogData } from '../toolwrapper/devchatClient';
|
import { DevChatClient, ChatRequest, ChatResponse, buildRoleContextsFromFiles, LogData } from '../toolwrapper/devchatClient';
|
||||||
@ -191,9 +190,9 @@ export async function sendMessageBase(message: any, handlePartialData: (data: {
|
|||||||
if (chatResponse.finish_reason === "should_run_workflow") {
|
if (chatResponse.finish_reason === "should_run_workflow") {
|
||||||
// invoke workflow via cli
|
// invoke workflow via cli
|
||||||
workflowRes = await dcCLI.runWorkflow(
|
workflowRes = await dcCLI.runWorkflow(
|
||||||
parsedMessage.text,
|
parsedMessage.text,
|
||||||
chatOptions,
|
chatOptions,
|
||||||
(partialResponse: ChatResponse) => {
|
(partialResponse: ChatResponse) => {
|
||||||
const partialDataText = partialResponse.response;
|
const partialDataText = partialResponse.response;
|
||||||
handlePartialData({
|
handlePartialData({
|
||||||
command: "receiveMessagePartial",
|
command: "receiveMessagePartial",
|
||||||
@ -280,9 +279,10 @@ export async function deleteChatMessageBase(message:{'hash': string}): Promise<b
|
|||||||
try {
|
try {
|
||||||
assertValue(!message.hash, 'Message hash is required');
|
assertValue(!message.hash, 'Message hash is required');
|
||||||
|
|
||||||
// delete the message by devchat
|
// delete the message by devchatClient
|
||||||
const bSuccess = await devChat.delete(message.hash);
|
const res = await dcClient.deleteLog(message.hash);
|
||||||
assertValue(!bSuccess, "Failed to delete message from devchat");
|
assertValue(!res.success, res.error || "Failed to delete message from devchat client");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
logger.channel()?.error(`Error: ${error.message}`);
|
logger.channel()?.error(`Error: ${error.message}`);
|
||||||
@ -300,5 +300,5 @@ export async function deleteChatMessageBase(message:{'hash': string}): Promise<b
|
|||||||
*/
|
*/
|
||||||
export async function sendTextToDevChat(text: string): Promise<void> {
|
export async function sendTextToDevChat(text: string): Promise<void> {
|
||||||
dcCLI.input(text);
|
dcCLI.input(text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -71,6 +71,23 @@ export interface LogInsertRes {
|
|||||||
error?: string;
|
error?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LogDeleteRes {
|
||||||
|
success?: boolean;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShortLog {
|
||||||
|
hash: string;
|
||||||
|
parent: string | null;
|
||||||
|
user: string;
|
||||||
|
date: string;
|
||||||
|
request: string;
|
||||||
|
responses: string[];
|
||||||
|
context: Array<{
|
||||||
|
content: string;
|
||||||
|
role: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
export async function buildRoleContextsFromFiles(
|
export async function buildRoleContextsFromFiles(
|
||||||
files: string[] | undefined
|
files: string[] | undefined
|
||||||
@ -249,6 +266,29 @@ export class DevChatClient {
|
|||||||
};
|
};
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@timeThis
|
||||||
|
async deleteLog(logHash: string): Promise<LogDeleteRes> {
|
||||||
|
const data = {
|
||||||
|
workspace: UiUtilWrapper.workspaceFoldersFirstPath(),
|
||||||
|
hash: logHash,
|
||||||
|
};
|
||||||
|
const response = await this._post("/logs/delete", data);
|
||||||
|
logger
|
||||||
|
.channel()
|
||||||
|
?.debug(
|
||||||
|
`deleteLog response data: ${JSON.stringify(
|
||||||
|
response.data
|
||||||
|
)}, ${typeof response.data}}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const res: LogDeleteRes = {
|
||||||
|
success: response.data["success"],
|
||||||
|
error: response.data["error"],
|
||||||
|
};
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
stopAllRequest(): void {
|
stopAllRequest(): void {
|
||||||
this.cancelMessage();
|
this.cancelMessage();
|
||||||
// add other requests here if needed
|
// add other requests here if needed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user