Skip to content

Commit cc0eee8

Browse files
authored
Update the history file name and exclude the environment/managed-identity credentials from Azure authentication flow (#412)
1 parent 513147e commit cc0eee8

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

shell/AIShell.Kernel/Shell.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Text;
23
using AIShell.Abstraction;
34
using AIShell.Kernel.Commands;
45
using AIShell.Kernel.Mcp;
@@ -686,8 +687,24 @@ internal async Task RunREPLAsync()
686687
continue;
687688
}
688689

690+
StringBuilder sb = null;
691+
string message = ex.Message;
692+
string stackTrace = ex.StackTrace;
693+
694+
while (ex.InnerException is { })
695+
{
696+
sb ??= new(message, capacity: message.Length * 3);
697+
sb.Append($"\n Inner -> {ex.InnerException.Message}");
698+
ex = ex.InnerException;
699+
}
700+
701+
if (sb is not null)
702+
{
703+
message = sb.ToString();
704+
}
705+
689706
Host.WriteErrorLine()
690-
.WriteErrorLine($"Agent failed to generate a response: {ex.Message}\n{ex.StackTrace}")
707+
.WriteErrorLine($"Agent failed to generate a response: {message}\n\n{stackTrace}")
691708
.WriteErrorLine();
692709
}
693710
}

shell/ReadLine/Prediction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public PredictiveSuggestion(string suggestion, string toolTip)
8585

8686
public partial class PSConsoleReadLine
8787
{
88-
private const string DefaultName = "PSReadLine";
88+
private const string DefaultName = "AIShell";
8989
private readonly Prediction _prediction;
9090

9191
/// <summary>

shell/agents/AIShell.OpenAI.Agent/AIShell.OpenAI.Agent.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<ItemGroup>
2424
<PackageReference Include="Azure.AI.OpenAI" Version="2.2.0-beta.4" />
25-
<PackageReference Include="Azure.Identity" Version="1.14.0" />
25+
<PackageReference Include="Azure.Identity" Version="1.15.0" />
2626
<PackageReference Include="Microsoft.Extensions.AI" Version="9.6.0" />
2727
<PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.6.0-preview.1.25310.2" />
2828
</ItemGroup>

shell/agents/AIShell.OpenAI.Agent/Service.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@ private void RefreshOpenAIClient()
101101
}
102102
else
103103
{
104-
var credential = new DefaultAzureCredential(includeInteractiveCredentials: true);
104+
var credential = new DefaultAzureCredential(
105+
new DefaultAzureCredentialOptions
106+
{
107+
ExcludeInteractiveBrowserCredential = false,
108+
ExcludeEnvironmentCredential = true,
109+
ExcludeManagedIdentityCredential = true,
110+
}
111+
);
105112

106113
var aiClient = new AzureOpenAIClient(
107114
new Uri(_gptToUse.Endpoint),

0 commit comments

Comments
 (0)