Skip to content

Commit 3c64821

Browse files
committed
Use OpenAI's built-in support for score threshold
Rather than unnecessarily removing the nodes ourselves. See https://platform.openai.com/docs/guides/retrieval#ranking
1 parent 97bfed0 commit 3c64821

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/dotnet-openai/Vectors/SearchCommand.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public override async Task<int> ExecuteAsync(CommandContext context, SearchSetti
4444
var content = new Dictionary<string, object>
4545
{
4646
["query"] = settings.Query,
47+
["ranking_options"] = new { score_threshold = settings.Score }
4748
};
4849

4950
if (settings.Rewrite)
@@ -96,12 +97,6 @@ public override async Task<int> ExecuteAsync(CommandContext context, SearchSetti
9697
return -1;
9798
}
9899

99-
foreach (var result in data.ToList())
100-
{
101-
if (result!["score"]!.GetValue<double>() < settings.Score)
102-
data.Remove(result);
103-
}
104-
105100
if (settings.Json)
106101
return console.RenderJson(node, settings, cts.Token);
107102

0 commit comments

Comments
 (0)