Support turbo edits (pro) (#166)
This commit is contained in:
@@ -215,17 +215,16 @@ export function registerChatStreamHandlers() {
|
||||
} else {
|
||||
// Normal AI processing for non-test prompts
|
||||
const settings = readSettings();
|
||||
const { modelClient, backupModelClients } = await getModelClient(
|
||||
settings.selectedModel,
|
||||
settings,
|
||||
);
|
||||
|
||||
// Extract codebase information if app is associated with the chat
|
||||
let codebaseInfo = "";
|
||||
let files: { path: string; content: string }[] = [];
|
||||
if (updatedChat.app) {
|
||||
const appPath = getDyadAppPath(updatedChat.app.path);
|
||||
try {
|
||||
codebaseInfo = await extractCodebase(appPath);
|
||||
const out = await extractCodebase(appPath);
|
||||
codebaseInfo = out.formattedOutput;
|
||||
files = out.files;
|
||||
logger.log(`Extracted codebase information from ${appPath}`);
|
||||
} catch (error) {
|
||||
logger.error("Error extracting codebase:", error);
|
||||
@@ -237,6 +236,11 @@ export function registerChatStreamHandlers() {
|
||||
"estimated tokens",
|
||||
codebaseInfo.length / 4,
|
||||
);
|
||||
const { modelClient, backupModelClients } = await getModelClient(
|
||||
settings.selectedModel,
|
||||
settings,
|
||||
files,
|
||||
);
|
||||
|
||||
// Prepare message history for the AI
|
||||
const messageHistory = updatedChat.messages.map((message) => ({
|
||||
|
||||
@@ -140,7 +140,7 @@ export function registerDebugHandlers() {
|
||||
|
||||
// Extract codebase
|
||||
const appPath = getDyadAppPath(app.path);
|
||||
const codebase = await extractCodebase(appPath);
|
||||
const codebase = (await extractCodebase(appPath)).formattedOutput;
|
||||
|
||||
return {
|
||||
debugInfo,
|
||||
|
||||
@@ -92,7 +92,8 @@ async function getCodebaseTokenCount(
|
||||
|
||||
// Calculate and cache the token count
|
||||
logger.log(`Calculating codebase token count for chatId: ${chatId}`);
|
||||
const codebase = await extractCodebase(getDyadAppPath(appPath));
|
||||
const codebase = (await extractCodebase(getDyadAppPath(appPath)))
|
||||
.formattedOutput;
|
||||
const tokenCount = estimateTokens(codebase);
|
||||
|
||||
// Store in cache
|
||||
|
||||
@@ -68,7 +68,7 @@ export function registerTokenCountHandlers() {
|
||||
|
||||
if (chat.app) {
|
||||
const appPath = getDyadAppPath(chat.app.path);
|
||||
codebaseInfo = await extractCodebase(appPath);
|
||||
codebaseInfo = (await extractCodebase(appPath)).formattedOutput;
|
||||
codebaseTokens = estimateTokens(codebaseInfo);
|
||||
logger.log(
|
||||
`Extracted codebase information from ${appPath}, tokens: ${codebaseTokens}`,
|
||||
|
||||
Reference in New Issue
Block a user