Use the inner get/post method
This commit is contained in:
parent
6386cc4231
commit
feb34588ab
@ -21,12 +21,10 @@ export async function getWorkflowCommandList(
|
|||||||
|
|
||||||
// All workflows registered in DevChat
|
// All workflows registered in DevChat
|
||||||
const workflows = await dcClient.getWorkflowList();
|
const workflows = await dcClient.getWorkflowList();
|
||||||
logger.channel()?.debug(`\n\n----- workflows: ${JSON.stringify(workflows)}`);
|
|
||||||
|
|
||||||
// Get recommends from config
|
// Get recommends from config
|
||||||
const workflowsConfig = await dcClient.getWorkflowConfig();
|
const workflowsConfig = await dcClient.getWorkflowConfig();
|
||||||
const recommends = workflowsConfig.recommend?.workflows || [];
|
const recommends = workflowsConfig.recommend?.workflows || [];
|
||||||
logger.channel()?.debug(`\n\n----- recommends: ${JSON.stringify(recommends)}`);
|
|
||||||
|
|
||||||
// Filter active workflows and add recommend info
|
// Filter active workflows and add recommend info
|
||||||
const commandList = workflows
|
const commandList = workflows
|
||||||
|
@ -117,7 +117,7 @@ export class DevChatClient {
|
|||||||
|
|
||||||
private _cancelMessageToken: CancelTokenSource | null = null;
|
private _cancelMessageToken: CancelTokenSource | null = null;
|
||||||
|
|
||||||
static readonly logRawDataSizeLimit = 10; //4 * 1024;
|
static readonly logRawDataSizeLimit = 4 * 1024;
|
||||||
|
|
||||||
// TODO: init devchat client with a port number
|
// TODO: init devchat client with a port number
|
||||||
// TODO: the default 22222 is for dev only, should not be used in production
|
// TODO: the default 22222 is for dev only, should not be used in production
|
||||||
@ -125,10 +125,10 @@ export class DevChatClient {
|
|||||||
this.baseURL = `http://localhost:${port}`;
|
this.baseURL = `http://localhost:${port}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _get(path: string): Promise<AxiosResponse> {
|
async _get(path: string, config?: any): Promise<AxiosResponse> {
|
||||||
try {
|
try {
|
||||||
logger.channel()?.debug(`GET request to ${this.baseURL}${path}`);
|
logger.channel()?.debug(`GET request to ${this.baseURL}${path}`);
|
||||||
const response = await axios.get(`${this.baseURL}${path}`);
|
const response = await axios.get(`${this.baseURL}${path}`, config);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@ -137,6 +137,7 @@ export class DevChatClient {
|
|||||||
}
|
}
|
||||||
async _post(path: string, data: any = undefined): Promise<AxiosResponse> {
|
async _post(path: string, data: any = undefined): Promise<AxiosResponse> {
|
||||||
try {
|
try {
|
||||||
|
logger.channel()?.debug(`POST request to ${this.baseURL}${path}`);
|
||||||
const response = await axios.post(`${this.baseURL}${path}`, data);
|
const response = await axios.post(`${this.baseURL}${path}`, data);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -246,11 +247,11 @@ export class DevChatClient {
|
|||||||
|
|
||||||
response.data.on("error", (error) => {
|
response.data.on("error", (error) => {
|
||||||
logger.channel()?.error("Streaming error:", error);
|
logger.channel()?.error("Streaming error:", error);
|
||||||
// TODO: handle error
|
// TODO: handle error?
|
||||||
reject(error); // Reject the promise on error
|
reject(error); // Reject the promise on error
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// TODO: handle error
|
// TODO: handle error?
|
||||||
reject(error); // Reject the promise if the request fails
|
reject(error); // Reject the promise if the request fails
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -351,8 +352,8 @@ export class DevChatClient {
|
|||||||
offset: offset,
|
offset: offset,
|
||||||
workspace: UiUtilWrapper.workspaceFoldersFirstPath(),
|
workspace: UiUtilWrapper.workspaceFoldersFirstPath(),
|
||||||
};
|
};
|
||||||
const response = await axios.get(
|
const response = await this._get(
|
||||||
`${this.baseURL}/topics/${topicRootHash}/logs`,
|
`/topics/${topicRootHash}/logs`,
|
||||||
{
|
{
|
||||||
params: data,
|
params: data,
|
||||||
}
|
}
|
||||||
@ -375,7 +376,7 @@ export class DevChatClient {
|
|||||||
offset: offset,
|
offset: offset,
|
||||||
workspace: UiUtilWrapper.workspaceFoldersFirstPath(),
|
workspace: UiUtilWrapper.workspaceFoldersFirstPath(),
|
||||||
};
|
};
|
||||||
const response = await axios.get(`${this.baseURL}/topics`, {
|
const response = await this._get(`/topics`, {
|
||||||
params: data,
|
params: data,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user