@@ -8,8 +8,8 @@ namespace SourceGit.AI
88{
99 public static class ChatTools
1010 {
11- public static readonly ChatTool Tool_GetDetailChangesInFile = ChatTool . CreateFunctionTool (
12- nameof ( GetDetailChangesInFile ) ,
11+ public static readonly ChatTool GetDetailChangesInFile = ChatTool . CreateFunctionTool (
12+ " GetDetailChangesInFile" ,
1313 "Get the detailed changes in the specified file in the specified repository." ,
1414 BinaryData . FromBytes ( Encoding . UTF8 . GetBytes ( """
1515 {
@@ -36,7 +36,7 @@ public static async Task<ToolChatMessage> Process(ChatToolCall call, Action<stri
3636 {
3737 using var doc = JsonDocument . Parse ( call . FunctionArguments ) ;
3838
39- if ( call . FunctionName . Equals ( Tool_GetDetailChangesInFile . FunctionName ) )
39+ if ( call . FunctionName . Equals ( GetDetailChangesInFile . FunctionName ) )
4040 {
4141 var hasRepo = doc . RootElement . TryGetProperty ( "repo" , out var repoPath ) ;
4242 var hasFile = doc . RootElement . TryGetProperty ( "file" , out var filePath ) ;
@@ -48,20 +48,13 @@ public static async Task<ToolChatMessage> Process(ChatToolCall call, Action<stri
4848
4949 output ? . Invoke ( $ "Read changes in file: { filePath . GetString ( ) } ") ;
5050
51- var toolResult = await ChatTools . GetDetailChangesInFile (
52- repoPath . GetString ( ) ,
53- filePath . GetString ( ) ,
54- hasOriginalFile ? originalFilePath . GetString ( ) : string . Empty ) ;
55- return new ToolChatMessage ( call . Id , toolResult ) ;
51+ var orgFilePath = hasOriginalFile ? originalFilePath . GetString ( ) : string . Empty ;
52+ var rs = await new Commands . GetFileChangeForAI ( repoPath . GetString ( ) , filePath . GetString ( ) , orgFilePath ) . ReadAsync ( ) ;
53+ var message = rs . IsSuccess ? rs . StdOut : string . Empty ;
54+ return new ToolChatMessage ( call . Id , message ) ;
5655 }
5756
5857 throw new NotSupportedException ( $ "The tool { call . FunctionName } is not supported") ;
5958 }
60-
61- private static async Task < string > GetDetailChangesInFile ( string repo , string file , string originalFile )
62- {
63- var rs = await new Commands . GetFileChangeForAI ( repo , file , originalFile ) . ReadAsync ( ) ;
64- return rs . IsSuccess ? rs . StdOut : string . Empty ;
65- }
6659 }
6760}
0 commit comments