@@ -66,13 +66,19 @@ public static async Task AuthenticateWithApiKeyAsync(string apiKey, string model
6666 await SetModelAsync ( model ) . ConfigureAwait ( false ) ;
6767 }
6868
69- public static async Task < IChatClient > GetChatModelAsync ( CancellationToken cancellationToken = default )
69+ public static async Task < IChatClient > GetChatModelAsync ( string ? model = null , bool debug = false , CancellationToken cancellationToken = default )
7070 {
7171 var settingsFolder = GetSettingsFolder ( ) ;
7272
7373 var provider = await File . ReadAllTextAsync ( Path . Combine ( settingsFolder , "provider.txt" ) , cancellationToken )
7474 . ConfigureAwait ( false ) ;
75- var modelId = await File . ReadAllTextAsync ( Path . Combine ( settingsFolder , "model.txt" ) , cancellationToken ) . ConfigureAwait ( false ) ;
75+ var modelId = model ?? await File . ReadAllTextAsync ( Path . Combine ( settingsFolder , "model.txt" ) , cancellationToken ) . ConfigureAwait ( false ) ;
76+ if ( debug )
77+ {
78+ Console . WriteLine ( "Using provider: " + provider ) ;
79+ Console . WriteLine ( "Using model: " + modelId ) ;
80+ }
81+
7682 IChatClient chatClient ;
7783 Uri ? endpoint = provider switch
7884 {
@@ -81,7 +87,7 @@ public static async Task<IChatClient> GetChatModelAsync(CancellationToken cancel
8187 } ;
8288 modelId = modelId switch
8389 {
84- "latest-fast" => tryAGI . OpenAI . CreateChatCompletionRequestModelExtensions . ToValueString ( tryAGI . OpenAI . ChatClient . LatestFastModel ) ,
90+ "latest-fast" => "o3-mini" ,
8591 "latest-smart" => tryAGI . OpenAI . CreateChatCompletionRequestModelExtensions . ToValueString ( tryAGI . OpenAI . ChatClient . LatestSmartModel ) ,
8692 _ => modelId ,
8793 } ;
@@ -104,7 +110,16 @@ public static async Task<IChatClient> GetChatModelAsync(CancellationToken cancel
104110 }
105111
106112 using var factory = LoggerFactory . Create ( builder =>
107- builder . AddDebug ( ) . SetMinimumLevel ( LogLevel . Trace ) ) ;
113+ {
114+ if ( debug )
115+ {
116+ builder . AddConsole ( ) . SetMinimumLevel ( LogLevel . Trace ) ;
117+ }
118+ else
119+ {
120+ builder . AddDebug ( ) . SetMinimumLevel ( LogLevel . Trace ) ;
121+ }
122+ } ) ;
108123 var client = new ChatClientBuilder ( chatClient )
109124 // 👇🏼 Add logging to the chat client, wrapping the function invocation client
110125 . UseLogging ( factory )
@@ -115,9 +130,9 @@ public static async Task<IChatClient> GetChatModelAsync(CancellationToken cancel
115130 return client ;
116131 }
117132
118- public static async Task < string > GenerateUsingAuthenticatedModelAsync ( string prompt , CancellationToken cancellationToken = default )
133+ public static async Task < string > GenerateUsingAuthenticatedModelAsync ( string prompt , bool debug = false , CancellationToken cancellationToken = default )
119134 {
120- IChatClient model = await GetChatModelAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
135+ IChatClient model = await GetChatModelAsync ( null , debug , cancellationToken ) . ConfigureAwait ( false ) ;
121136
122137 var response = await model . GetResponseAsync ( prompt , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
123138
0 commit comments