A chatbot that utilizes the RAG technique can generate responses to user questions based on selected Loqseq notes.
- Chat with your notes.
- Answer sources citation with links to original note blocks.
- Contextualizing user question with chat history.
- Persistent vector storage on Supabase.
- Prompt tracing with Langsmith
-
Clone the repository
-
Make sure you have pnpm installed, install if necessary
-
Execute
pnpm install
andpnpm build
to build the plugin -
Enable developer-mode in Logseq, go to plugins, select "Load unpacked plugin"
-
Select the directory of your plugin (not the
/dist
-directory, but the directory which includes your package.json) -
Setup a Supabase project and execute following SQL in SQL Editor.
-- Enable the pgvector extension to work with embedding vectors create extension vector; -- Create a table to store page info create table pages( id bigint generated by default as identity, uuid uuid not null primary key, name character varying null, original_name character varying null, updated_at bigint not null, ); -- Create a table to store your documents create table documents ( id bigserial primary key, content text, -- corresponds to Document.pageContent metadata jsonb, -- corresponds to Document.metadata embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed ); -- Create a function to search for documents create function match_documents ( query_embedding vector(1536), match_count int default null, filter jsonb DEFAULT '{}' ) returns table ( id bigint, content text, metadata jsonb, similarity float ) language plpgsql as $$ #variable_conflict use_column begin return query select id, content, metadata, 1 - (documents.embedding <=> query_embedding) as similarity from documents where metadata @> filter order by documents.embedding <=> query_embedding limit match_count; end; $$;
-
Setup Supabase project url, service key, and OpenAI API key in Plugin Settings.
-
Start Chat with your notes.