Skip to content

Commit 3c5d973

Browse files
committed
tune search & ask
1 parent cf31223 commit 3c5d973

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

core/lib/canary/index/trieve/client.ex

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule Canary.Index.Trieve.Actual do
4444
if(not is_nil(dataset), do: {"TR-Dataset", dataset}, else: nil)
4545
]
4646
|> Enum.reject(&is_nil/1),
47-
receive_timeout: 2 * 15_000
47+
receive_timeout: 4_000
4848
)
4949
end
5050

@@ -207,16 +207,11 @@ defmodule Canary.Index.Trieve.Actual do
207207
tags = Keyword.get(opts, :tags, nil)
208208
source_ids = Keyword.get(opts, :source_ids, nil)
209209

210-
search_type = if(rag? or question?(query), do: :hybrid, else: :fulltext)
210+
search_type = if(rag? or question?(query), do: :fulltext, else: :fulltext)
211211
remove_stop_words = not (rag? or question?(query))
212212
group_size = if(rag?, do: 5, else: 3)
213-
page_size = 8
214-
215-
score_threshold =
216-
case search_type do
217-
:fulltext -> 1
218-
_ -> 0.3
219-
end
213+
page_size = if(rag?, do: 12, else: 8)
214+
score_threshold = 0.3
220215

221216
highlight_options =
222217
cond do
@@ -281,7 +276,7 @@ defmodule Canary.Index.Trieve.Actual do
281276
})
282277
end)
283278
end)
284-
|> Task.await_many(2_500)
279+
|> Task.await_many(5_000)
285280

286281
if Enum.all?(result, &match?({:error, _}, &1)) do
287282
{:error, result}
@@ -329,7 +324,6 @@ defmodule Canary.Index.Trieve.Actual do
329324
# https://docs.trieve.ai/api-reference/chunk-group/search-over-groups
330325
case client
331326
|> Req.post(
332-
receive_timeout: 2_000,
333327
url: "/chunk_group/group_oriented_search",
334328
json: data
335329
) do
@@ -370,7 +364,7 @@ defmodule Canary.Index.Trieve.Actual do
370364
end
371365
end)
372366
end)
373-
|> Task.await_many(3_000)
367+
|> Task.await_many(5_000)
374368

375369
if Enum.all?(result, &match?({:error, _}, &1)) do
376370
{:error, result}

core/lib/canary/interface/ask.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule Canary.Interface.Ask.Default do
2121

2222
results =
2323
groups
24-
|> Enum.take(6)
24+
|> Enum.take(8)
2525
|> Enum.map(fn %{"chunks" => chunks, "group" => %{"tracking_id" => group_id}} ->
2626
Task.async(fn ->
2727
chunk_indices =

core/lib/canary/sources/document_create.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ defmodule Canary.Sources.Document.Create do
110110
title:
111111
if(index == 0, do: item.title, else: data.root.title <> "\n" <> data.root.content),
112112
created_at: item.created_at,
113-
weight: 1 + clamp(0, 3, item.num_reactions / 2) / 10,
113+
weight: 1 + clamp(0, 3, floor(item.num_reactions / 3)) / 10,
114114
meta: %{index: index}
115115
}
116116
end)
@@ -153,7 +153,7 @@ defmodule Canary.Sources.Document.Create do
153153
title:
154154
if(index == 0, do: item.title, else: data.root.title <> "\n" <> data.root.content),
155155
created_at: item.created_at,
156-
weight: 1 + clamp(0, 3, item.num_reactions / 2) / 10,
156+
weight: 1 + clamp(0, 3, floor(item.num_reactions / 3)) / 10,
157157
meta: %{index: index}
158158
}
159159
end)

0 commit comments

Comments
 (0)