Skip to content

Commit

Permalink
Fixes to webhook and document_search
Browse files Browse the repository at this point in the history
  • Loading branch information
michalwarda committed Feb 24, 2024
1 parent 6f09ce9 commit 236230f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
14 changes: 12 additions & 2 deletions apps/api/lib/buildel/blocks/document_search.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,16 @@ defmodule Buildel.Blocks.DocumentSearch do
|> Enum.map(fn
%{
"document" => document,
"metadata" => %{"file_name" => filename, "memory_id" => memory_id}
"metadata" => %{
"file_name" => filename,
"memory_id" => memory_id,
"chunk_id" => chunk_id
}
} ->
%{
document_id: memory_id,
document_name: filename,
chunk_id: chunk_id,
chunk: document |> String.trim()
}
end)
Expand Down Expand Up @@ -180,11 +185,16 @@ defmodule Buildel.Blocks.DocumentSearch do
|> Enum.map(fn
%{
"document" => document,
"metadata" => %{"file_name" => filename, "memory_id" => memory_id}
"metadata" => %{
"file_name" => filename,
"memory_id" => memory_id,
"chunk_id" => chunk_id
}
} ->
%{
document_id: memory_id,
document_name: filename,
chunk_id: chunk_id,
chunk: document |> String.trim()
}
end)
Expand Down
4 changes: 2 additions & 2 deletions apps/api/lib/buildel/blocks/utils/input_queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ defmodule Buildel.Blocks.Utils.InputQueue do
end

def pop(%__MODULE__{queue: [_item | [item | rest]], process_item: process_item}) do
IO.puts("removing another item from queue")
IO.puts("removing another item from queue with #{rest |> Enum.count()} items left")
process_item.(item)

%__MODULE__{queue: rest, process_item: process_item}
%__MODULE__{queue: [item | rest], process_item: process_item}
end
end
3 changes: 2 additions & 1 deletion apps/api/lib/buildel/clients/webhook.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ defmodule Buildel.Clients.Webhook do
def send_content(url, payload, headers \\ []) do
headers = [{"Accept", "application/json"}, {"Content-Type", "application/json"}] ++ headers

with {:ok, response} <- HTTPoison.post(url, payload, headers) do
with {:ok, response} <-
HTTPoison.post(url, payload, headers, timeout: 60_000, recv_timeout: 60_000) do
Logger.debug("Webhook response: #{inspect(response)}")
else
{:error, %HTTPoison.Error{reason: _reason} = error} ->
Expand Down
6 changes: 4 additions & 2 deletions apps/api/lib/buildel/vector_db.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ defmodule Buildel.VectorDB.EctoAdapter do
|> Enum.map(fn chunk ->
%{
"document" => chunk.document,
"metadata" => chunk.metadata
"metadata" => chunk.metadata,
"chunk_id" => chunk.id
}
end)
end
Expand Down Expand Up @@ -288,7 +289,8 @@ defmodule Buildel.VectorDB.EctoAdapter do
|> Enum.map(fn chunk ->
%{
"document" => chunk.document,
"metadata" => chunk.metadata
"metadata" => chunk.metadata,
"chunk_id" => chunk.id
}
end)

Expand Down

0 comments on commit 236230f

Please sign in to comment.