Skip to content

Commit

Permalink
Merge pull request #496 from tryAGI/bot/auto-format_202501130520
Browse files Browse the repository at this point in the history
style:Run dotnet format
  • Loading branch information
github-actions[bot] authored Jan 13, 2025
2 parents 1d04ec1 + 06b4485 commit 67bfe42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Cli/src/Commands/DoCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ private static async Task HandleAsync(string input, string inputPath, string out
var llm = await Helpers.GetChatModelAsync().ConfigureAwait(false);
llm.RequestSent += (_, request) => Console.WriteLine($"RequestSent: {request.Messages.AsHistory()}");
llm.ResponseReceived += (_, response) => Console.WriteLine($"ResponseReceived: {response}");

var fileSystemService = new FileSystemService();
llm.AddGlobalTools(fileSystemService.AsTools(), fileSystemService.AsCalls());

var response = await llm.GenerateAsync(inputText);

await Helpers.WriteOutputAsync(response, outputPath).ConfigureAwait(false);
}
}
18 changes: 9 additions & 9 deletions src/Cli/src/Commands/FileSystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task<IList<string>> FindFilePathsByContentAsync(
CancellationToken cancellationToken = default)
{
var paths = new List<string>();

Console.WriteLine($"Searching for files in \"{directory}\" containing \"{content}\"...");

foreach (var path in Directory.EnumerateFiles(directory, "*.*", SearchOption.AllDirectories))
Expand All @@ -46,7 +46,7 @@ public async Task<IList<string>> FindFilePathsByContentAsync(
{
continue;
}

//FileInfo info = new FileInfo(path);
var text = await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);

Expand All @@ -62,7 +62,7 @@ public async Task<IList<string>> FindFilePathsByContentAsync(
// ignore
}
}

Console.WriteLine($"Found {paths.Count} files:");
foreach (var path in paths)
{
Expand All @@ -71,16 +71,16 @@ public async Task<IList<string>> FindFilePathsByContentAsync(

return paths;
}

public async Task<string> ReadContentAsync(
string path,
CancellationToken cancellationToken = default)
{
Console.WriteLine($"Reading file at path: {path}");

return await File.ReadAllTextAsync(path, cancellationToken).ConfigureAwait(false);
}

public async Task<string> WriteContentAsync(
string path,
string newContent,
Expand All @@ -101,11 +101,11 @@ public async Task<string> WriteContentAsync(
break;
}
}

await File.WriteAllTextAsync(path, newContent, cancellationToken).ConfigureAwait(false);

Console.WriteLine("File written.");

return "File written.";
}
}

0 comments on commit 67bfe42

Please sign in to comment.