Skip to content
Open
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
6 changes: 0 additions & 6 deletions lib/chatbot/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ defmodule Chatbot.Application do
@impl true
def start(_type, _args) do
children = [
{Nx.Serving,
[
serving: Chatbot.Rag.Serving.build_llm_serving(),
name: Rag.LLMServing,
batch_timeout: 100
]},
{Nx.Serving,
[
serving: Chatbot.Rag.Serving.build_embedding_serving(),
Expand Down
2 changes: 1 addition & 1 deletion lib/chatbot/rag.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Ecto.Query
import Pgvector.Ecto.Query

@provider Ai.Nx.new(%{embeddings_serving: Rag.EmbeddingServing, text_serving: Rag.LLMServing})
@provider Ai.Nx.new(%{embeddings_serving: Rag.EmbeddingServing})

def ingest(path) do
path
Expand Down Expand Up @@ -46,9 +46,9 @@
Enum.map(chunks, &Map.put(ingestion, :chunk, &1.text))
end

def query(query) do

Check warning on line 49 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

no_return

Function query/1 has no local return.
generation =
Generation.new(query)

Check warning on line 51 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

call

The function call generate_embedding will not succeed.
|> Embedding.generate_embedding(@provider)
|> Retrieval.retrieve(:fulltext_results, fn generation -> query_fulltext(generation) end)
|> Retrieval.retrieve(:semantic_results, fn generation ->
Expand Down Expand Up @@ -85,7 +85,7 @@
|> Map.put_new(:updated_at, now)
end

defp query_with_pgvector(%{query_embedding: query_embedding}, limit \\ 3) do

Check warning on line 88 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

unused_fun

Function query_with_pgvector/1 will never be called.

Check warning on line 88 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

unused_fun

Function query_with_pgvector/2 will never be called.
{:ok,
Repo.all(
from(c in Chatbot.Rag.Chunk,
Expand All @@ -95,7 +95,7 @@
)}
end

defp query_fulltext(%{query: query}, limit \\ 3) do

Check warning on line 98 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

unused_fun

Function query_fulltext/1 will never be called.

Check warning on line 98 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

unused_fun

Function query_fulltext/2 will never be called.
query = query |> String.trim() |> String.replace(" ", " & ")

{:ok,
Expand All @@ -107,7 +107,7 @@
)}
end

defp smollm_prompt(query, context) do

Check warning on line 110 in lib/chatbot/rag.ex

View workflow job for this annotation

GitHub Actions / Build and test (27.0.1, 1.17.2-otp-27)

unused_fun

Function smollm_prompt/2 will never be called.
"""
<|im_start|>system
You are a helpful assistant.<|im_end|>
Expand Down
Loading