Skip to content

Commit dd2e29a

Browse files
authored
Merge pull request #1274 from yileicn/master
InstructCompletion add file_urls state
2 parents 7895fc7 + 6fe12f8 commit dd2e29a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Infrastructure/BotSharp.Abstraction/Files/Models/InstructFileModel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,17 @@ public class InstructFileModel : FileBase
2222
[JsonPropertyName("content_type")]
2323
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
2424
public string? ContentType { get; set; }
25+
26+
public override string ToString()
27+
{
28+
if (!string.IsNullOrEmpty(FileUrl))
29+
{
30+
return FileUrl;
31+
}
32+
else if (!string.IsNullOrEmpty(FileData))
33+
{
34+
return FileData.SubstringMax(20);
35+
}
36+
return string.Empty;
37+
}
2538
}

src/Infrastructure/BotSharp.OpenAPI/Controllers/Instruct/InstructModeController.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public async Task<InstructResult> InstructCompletion([FromRoute] string agentId,
2424
{
2525
var state = _services.GetRequiredService<IConversationStateService>();
2626
input.States.ForEach(x => state.SetState(x.Key, x.Value, activeRounds: x.ActiveRounds, source: StateSource.External));
27+
2728
state.SetState("provider", input.Provider, source: StateSource.External)
2829
.SetState("model", input.Model, source: StateSource.External)
2930
.SetState("model_id", input.ModelId, source: StateSource.External)
@@ -33,7 +34,8 @@ public async Task<InstructResult> InstructCompletion([FromRoute] string agentId,
3334
.SetState("channel", input.Channel, source: StateSource.External)
3435
.SetState("code_options", input.CodeOptions, source: StateSource.External)
3536
.SetState("file_options", input.FileOptions, source: StateSource.External)
36-
.SetState("file_count", !input.Files.IsNullOrEmpty() ? input.Files.Count : (int?)null, source: StateSource.External);
37+
.SetState("file_count", input.Files?.Count, source: StateSource.External)
38+
.SetState("file_urls", input.Files?.Select(p => p.ToString()), source: StateSource.External);
3739

3840
var instructor = _services.GetRequiredService<IInstructService>();
3941
var result = await instructor.Execute(agentId,

0 commit comments

Comments
 (0)