Skip to content

Commit 7e7b8da

Browse files
authored
Merge pull request #20 from brandonh-msft/feat/input-file-support
Input file support
2 parents 8a7431e + f50a04a commit 7e7b8da

File tree

1 file changed

+11
-1
lines changed
  • samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client

1 file changed

+11
-1
lines changed

samples/semantic-kernel/a2a-net.Samples.SemanticKernel.Client/Program.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,27 @@ void spinStopThen(Action runThis)
102102
continue;
103103
}
104104

105+
var filePath = AnsiConsole.Ask<string>("[blue]File path (optional, <enter> to skip)>[/]", string.Empty).TrimStart('"').TrimEnd('"');
106+
string? filename = !string.IsNullOrWhiteSpace(filePath) ? Path.GetFileName(filePath) : null;
107+
var fileBytes = !string.IsNullOrWhiteSpace(filePath) ? System.IO.File.ReadAllBytes(filePath) : null;
108+
105109
spinnerCts = new();
106110

107111
try
108112
{
113+
var parts = new List<Part>() { new TextPart(prompt) };
114+
if (!string.IsNullOrWhiteSpace(filePath))
115+
{
116+
parts.Add(new FilePart { File = new() { Bytes = Convert.ToBase64String(fileBytes!), Name = filename } });
117+
}
118+
109119
var taskParams = new TaskSendParameters
110120
{
111121
SessionId = session,
112122
Message = new()
113123
{
114124
Role = MessageRole.User,
115-
Parts = [new TextPart(prompt)]
125+
Parts = [.. parts]
116126
}
117127
};
118128

0 commit comments

Comments
 (0)