Table of Contents
📝About
xxx
💻How to Build
Initial setup
Clone and install dependencies:
git clone https://github.com/vdutts7/chatBTC
cd chatBTC
npm i
Copy .env.example
and rename to .env
in root directory. Fill out API keys:
SUPABASE_ANON_KEY=""
NEXT_PUBLIC_SUPABASE_URL=""
OPENAI_API_KEY=""
#optional- leave blank if unused. DO NOT DELETE
OPENAI_PROXY=""
SPLASH_URL=""
Get API keys:
IMPORTANT: Verify that .gitignore
contains .env
in it.
Embeddings backend
Create a Supabase account and project at Supabase:
- Run this query Supabase's SQL editor:
create extension vector;
- Create a table to store embeddings with this query:
create table documents (
id bigserial primary key,
content text,
url text,
embedding vector (1536)
); - Add similarity search function with another query:
create or replace function match_documents (
query_embedding vector(1536),
similarity_threshold float,
match_count int
)
returns table (
id bigint,
content text,
url text,
similarity float
)
language plpgsql
as $$
begin
return query
select
documents.id,
documents.content,
documents.url,
1 - (documents.embedding <=> query_embedding) as similarity
from documents
where 1 - (documents.embedding <=> query_embedding) > similarity_threshold
order by documents.embedding <=> query_embedding
limit match_count;
end;
$$;
Chat frontend
- NextJs styled with Tailwind CSS
- Chats streamed using
OpenAIStream
. Seeutils/OpenAIStream.ts
for details
🚀Next Steps
- Live price tracker
- History of Satoshi and theories
- Connect more cryptocurrenciy whitepapers and update with latest software / framework developments.
- Regulation in different countries (changes month by month)