Add the following TODOs
This commit is contained in:
parent
7551a55ce6
commit
f421bcae56
@ -31,6 +31,7 @@ async function getFullText(activeEditor: vscode.TextEditor): Promise<string> {
|
||||
return document.getText();
|
||||
}
|
||||
|
||||
// TODO: 这里还有用吗?如果没用,就把这里以及相关代码删除;如果有用就用DevChatClient替换这里对DevChat的使用
|
||||
async function getUndefinedSymbols(content: string): Promise<string[] | undefined> {
|
||||
// run devchat prompt command
|
||||
const devChat = new DevChat();
|
||||
|
@ -1,3 +1,6 @@
|
||||
|
||||
// TODO: 确认所有DevChat()实例被替换后(contextRefDefs.js里),删除此文件
|
||||
|
||||
import * as dotenv from 'dotenv';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
@ -107,6 +107,11 @@ export async function buildRoleContextsFromFiles(
|
||||
return contexts;
|
||||
}
|
||||
|
||||
// TODO: 在插件启动为每个vscode窗口启动一个devchat local service
|
||||
// 1. 分配单独的端口号,该窗口的所有请求都通过该端口号发送 (22222仅为作为开发默认端口号,不应用于生产)
|
||||
// 2. 启动local service时要配置多个worker,以便处理并发请求
|
||||
// TODO: 在插件关闭时,关闭其对应的devchat local service
|
||||
|
||||
export class DevChatClient {
|
||||
private baseURL: string;
|
||||
|
||||
@ -114,6 +119,10 @@ export class DevChatClient {
|
||||
|
||||
static readonly logRawDataSizeLimit = 10; //4 * 1024;
|
||||
|
||||
// TODO: init devchat client with a port number
|
||||
// TODO: the default 22222 is for dev only, should not be used in production
|
||||
constructor(port: number = 22222) {
|
||||
this.baseURL = `http://localhost:${port}`;
|
||||
}
|
||||
|
||||
async _get(path: string): Promise<AxiosResponse> {
|
||||
@ -217,33 +226,21 @@ export class DevChatClient {
|
||||
chatRes.date = chunkData["date"];
|
||||
}
|
||||
chatRes.finish_reason = chunkData["finish_reason"];
|
||||
// TODO: tmp string literal 临时字面量
|
||||
if (chatRes.finish_reason === "should_run_workflow") {
|
||||
chatRes.extra = chunkData["extra"];
|
||||
logger
|
||||
.channel()
|
||||
?.debug(
|
||||
"res on data: should_run_workflow. do nothing now."
|
||||
);
|
||||
logger
|
||||
.channel()
|
||||
?.debug(
|
||||
`chatRes.extra: ${JSON.stringify(
|
||||
chatRes.extra
|
||||
)}`
|
||||
);
|
||||
?.debug("should run workflow via cli.");
|
||||
return;
|
||||
}
|
||||
|
||||
chatRes.isError = chunkData["isError"];
|
||||
|
||||
chatRes.response += chunkData["content"];
|
||||
logger.channel()?.debug(`${chunkData["content"]}`);
|
||||
onData(chatRes);
|
||||
});
|
||||
|
||||
response.data.on("end", () => {
|
||||
logger.channel()?.debug("\nStreaming ended");
|
||||
resolve(chatRes); // Resolve the promise with chatRes when the stream ends
|
||||
});
|
||||
|
||||
@ -372,7 +369,7 @@ export class DevChatClient {
|
||||
}
|
||||
|
||||
@timeThis
|
||||
async getTopics(limit:number, offset:number): Promise<any[]> {
|
||||
async getTopics(limit: number, offset: number): Promise<any[]> {
|
||||
const data = {
|
||||
limit: limit,
|
||||
offset: offset,
|
||||
@ -393,7 +390,7 @@ export class DevChatClient {
|
||||
}
|
||||
|
||||
@timeThis
|
||||
async deleteTopic(topicRootHash:string): Promise<void> {
|
||||
async deleteTopic(topicRootHash: string): Promise<void> {
|
||||
const data = {
|
||||
topic_hash: topicRootHash,
|
||||
workspace: UiUtilWrapper.workspaceFoldersFirstPath(),
|
||||
@ -403,7 +400,9 @@ export class DevChatClient {
|
||||
|
||||
logger
|
||||
.channel()
|
||||
?.debug(`deleteTopic response data: ${JSON.stringify(response.data)}`);
|
||||
?.debug(
|
||||
`deleteTopic response data: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -412,4 +411,4 @@ export class DevChatClient {
|
||||
this.cancelMessage();
|
||||
// add other requests here if needed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ import { CommandRun } from '../../src/util/commonUtil';
|
||||
import { UiUtilWrapper } from '../../src/util/uiUtil';
|
||||
import { ApiKeyManager } from '../../src/util/apiKey';
|
||||
|
||||
|
||||
// TODO: 删除devchat.js时,删除此测试文件
|
||||
// TODO: 同时为 DevChatCLI & DevChatClient 添加测试
|
||||
describe('DevChat', () => {
|
||||
let devChat: DevChat;
|
||||
let spawnAsyncStub: sinon.SinonStub;
|
||||
|
Loading…
x
Reference in New Issue
Block a user