Update
This commit is contained in:
22
Program.cs
22
Program.cs
@@ -96,10 +96,16 @@ var openAiClient = new OpenAIClient(new ApiKeyCredential(apiKey), new OpenAIClie
|
||||
IChatClient innerClient = openAiClient.GetChatClient(model).AsIChatClient();
|
||||
|
||||
// ── Tool call logging via Spectre ───────────────────────────────────────
|
||||
static void ToolLog(string message)
|
||||
object consoleLock = new object();
|
||||
|
||||
void ToolLog(string message)
|
||||
{
|
||||
lock (consoleLock)
|
||||
{
|
||||
Console.Write("\r" + new string(' ', 40) + "\r");
|
||||
AnsiConsole.MarkupLine($"[dim grey] ● {Markup.Escape(message)}[/]");
|
||||
}
|
||||
}
|
||||
|
||||
CommandTool.Log =
|
||||
DirTools.Log =
|
||||
@@ -243,13 +249,19 @@ while (true)
|
||||
bool showSpinner = true;
|
||||
|
||||
CommandTool.PauseSpinner = () =>
|
||||
{
|
||||
lock (consoleLock)
|
||||
{
|
||||
showSpinner = false;
|
||||
Console.Write("\r" + new string(' ', 40) + "\r");
|
||||
}
|
||||
};
|
||||
CommandTool.ResumeSpinner = () =>
|
||||
{
|
||||
lock (consoleLock)
|
||||
{
|
||||
showSpinner = true;
|
||||
}
|
||||
};
|
||||
|
||||
var spinnerTask = Task.Run(async () =>
|
||||
@@ -264,22 +276,28 @@ while (true)
|
||||
{
|
||||
while (!spinnerCts.Token.IsCancellationRequested)
|
||||
{
|
||||
if (showSpinner)
|
||||
lock (consoleLock)
|
||||
{
|
||||
if (showSpinner && !spinnerCts.Token.IsCancellationRequested)
|
||||
{
|
||||
var frame = frames[i % frames.Count];
|
||||
Console.Write($"\r\x1b[38;5;69m{frame}\x1b[0m Thinking...");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
try { await Task.Delay(interval, spinnerCts.Token); } catch { }
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Clear the spinner line and show cursor
|
||||
lock (consoleLock)
|
||||
{
|
||||
if (showSpinner)
|
||||
Console.Write("\r" + new string(' ', 40) + "\r");
|
||||
Console.Write("\x1b[?25h");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user