Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,11 @@ public static string CleanStr(this string? str)
return str.Replace(" ", "").Replace("\t", "").Replace("\n", "").Replace("\r", "");
}

[GeneratedRegex(@"[^\u0000-\u007F]")]
private static partial Regex NonAsciiCharactersRegex();

public static string CleanJsonStr(this string? str)
{
if (string.IsNullOrWhiteSpace(str)) return string.Empty;

str = str.Replace("```json", string.Empty).Replace("```", string.Empty).Trim();

return NonAsciiCharactersRegex().Replace(str, "");
return str.Replace("```json", string.Empty).Replace("```", string.Empty).Trim();
}

public static T? Json<T>(this string text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private async Task<InstructResult> RunLlm(
result = await GetChatCompletion(chatCompleter, agent, instruction, prompt, message.MessageId, files);
}
// Repair JSON format if needed
responseFormat = responseFormat ?? agentService.GetTemplateResponseFormat(agent, templateName);
responseFormat ??= agentService.GetTemplateResponseFormat(agent, templateName);
if (responseFormat == ResponseFormatType.Json)
{
var jsonRepairService = _services.GetRequiredService<IJsonRepairService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public async Task InstructCompletionSse([FromRoute] string agentId, [FromBody] I
templateName: input.Template,
files: input.Files,
codeOptions: input.CodeOptions,
fileOptions: input.FileOptions);
fileOptions: input.FileOptions,
responseFormat: input.ResponseFormat);

result.States = state.GetStates();

Expand Down
Loading