Skip to content

Commit 317da26

Browse files
committed
hotfix
1 parent 8395dc9 commit 317da26

2 files changed

Lines changed: 8 additions & 32 deletions

File tree

src/MapperAI.Core/Clients/GeminiClientAI.cs

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,41 +53,17 @@ public async Task<ClientResponse> SendAsync(string prompt, CancellationToken can
5353
.GetString();
5454

5555
if (text == null) throw new Exception("Error");
56-
var textSanitized = SanitizeJson(text);
57-
return new ClientResponse { Value = textSanitized};
56+
var cleanedJson = text
57+
.Replace("```json", string.Empty)
58+
.Replace("```", string.Empty)
59+
.Replace("\n", string.Empty)
60+
.Trim();
61+
// var textSanitized = SanitizeJson(text);
62+
return new ClientResponse { Value = cleanedJson};
5863
}
5964
catch (Exception ex)
6065
{
6166
throw new ConverterIAException($"An error occurred during processing: {ex.Message}");
6267
}
6368
}
64-
65-
private string SanitizeJson(string rawText)
66-
{
67-
if (string.IsNullOrWhiteSpace(rawText))
68-
return string.Empty;
69-
70-
rawText = rawText.Trim();
71-
72-
if (rawText.StartsWith("```"))
73-
{
74-
int start = rawText.IndexOf("[");
75-
int end = rawText.LastIndexOf("]");
76-
if (start >= 0 && end > start)
77-
{
78-
rawText = rawText.Substring(start, end - start + 1);
79-
}
80-
else
81-
{
82-
start = rawText.IndexOf("{");
83-
end = rawText.LastIndexOf("}");
84-
if (start >= 0 && end > start)
85-
{
86-
rawText = rawText.Substring(start, end - start + 1);
87-
}
88-
}
89-
}
90-
91-
return rawText.Trim();
92-
}
9369
}

src/MapperAI.Core/MapperAI.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Title>MapperAI-Alpha</Title>
88
<Authors>Dridev</Authors>
99
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10-
<Version>0.0.2-alpha</Version>
10+
<Version>0.0.3-alpha</Version>
1111
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1212
<RepositoryUrl>https://github.com/01Dri/MapperAI</RepositoryUrl>
1313
<RootNamespace>MapperAI.Core</RootNamespace>

0 commit comments

Comments
 (0)