33using System . Text ;
44using System . Threading ;
55using System . Threading . Tasks ;
6- using Azure . AI . OpenAI ;
7- using OpenAI ;
86using OpenAI . Chat ;
97
108namespace SourceGit . AI
@@ -18,21 +16,16 @@ public Agent(Service service)
1816
1917 public async Task GenerateCommitMessageAsync ( string repo , string changeList , Action < string > onUpdate , CancellationToken cancellation )
2018 {
21- var endPoint = new Uri ( _service . Server ) ;
22- var client = _service . Server . Contains ( "openai.azure.com/" , StringComparison . Ordinal )
23- ? new AzureOpenAIClient ( endPoint , _service . Credential )
24- : new OpenAIClient ( _service . Credential , new ( ) { Endpoint = endPoint } ) ;
25-
26- var chatClient = client . GetChatClient ( _service . Model ) ;
19+ var chatClient = _service . GetChatClient ( ) ;
2720 var options = new ChatCompletionOptions ( ) { Tools = { ChatTools . GetDetailChangesInFile } } ;
2821
2922 var userMessageBuilder = new StringBuilder ( ) ;
3023 userMessageBuilder
3124 . AppendLine ( "Generate a commit message (follow the rule of conventional commit message) for given git repository." )
3225 . AppendLine ( "- Read all given changed files before generating. Only binary files (such as images, audios ...) can be skipped." )
3326 . AppendLine ( "- Output the conventional commit message (with detail changes in list) directly. Do not explain your output nor introduce your answer." )
34- . AppendLine ( string . IsNullOrEmpty ( _service . AdditionalPrompt ) ? string . Empty : _service . AdditionalPrompt )
35- . Append ( "Reposiory path: " ) . AppendLine ( repo . Quoted ( ) )
27+ . AppendLine ( _service . AdditionalPrompt )
28+ . Append ( "Repository path: " ) . AppendLine ( repo . Quoted ( ) )
3629 . AppendLine ( "Changed files ('A' means added, 'M' means modified, 'D' means deleted, 'T' means type changed, 'R' means renamed, 'C' means copied): " )
3730 . Append ( changeList ) ;
3831
@@ -65,15 +58,15 @@ public async Task GenerateCommitMessageAsync(string repo, string changeList, Act
6558
6659 foreach ( var call in completion . ToolCalls )
6760 {
68- var result = await ChatTools . Process ( call , onUpdate ) ;
61+ var result = await ChatTools . ProcessAsync ( call , onUpdate ) ;
6962 messages . Add ( result ) ;
7063 }
7164
7265 inProgress = true ;
7366 break ;
7467 }
7568 case ChatFinishReason . ContentFilter :
76- throw new Exception ( "Ommitted content due to a content filter flag" ) ;
69+ throw new Exception ( "Omitted content due to a content filter flag" ) ;
7770 default :
7871 break ;
7972 }
0 commit comments