← Open Source
gannonh

chatgpt-pgvector

ChatGTP (gpt3.5-turbo) starter app.

ApplicationsOtherTypeScript
Open on GitHub
Momentum
+0stars in 24 hours0.0%
937
Stars
125
Forks
+0
This week
3
Contributors
Created 2023-02-28 · Updated 2026-09-30 · #12522 today
Top developers
gannonhankaneoskarrough

gannonh/chatgpt-pgvector is ranked 12,522 with 937 stars.

Same-category comparison

gannonh/chatgpt-pgvector is ranked 12,522 among these 8 peers; investbrainapp/investbrain is ranked 12,523.

Same-category comparison
NameRankMetrics
felixchenfy/Realtime-Action-Recognition12,491
Language:
Python
Stars:
942
Forks:
260
Description:
Real-time multi-person action recognition from OpenPose skeleton sequences, with tracking, feature extraction, model training, and inference pipelines for research and prototyping.
JuliusBrussee/caveman-code12,498
Language:
TypeScript
Stars:
941
Forks:
108
priiyaanjaalii0611/ASL_to_English12,505
Language:
Jupyter Notebook
Stars:
940
Forks:
218
Description:
Reads your hand signs and translates them to English words using Tensorflow object detection API.
nexu-io/codex-slides12,516
Language:
TypeScript
Stars:
938
Forks:
80
investbrainapp/investbrain12,523
Language:
PHP
Stars:
937
Forks:
73
Description:
Smart LLM-enabled investment tracker that consolidates and monitors market performance across your different brokerages.
pgosar/ChatGDB12,525
Language:
Python
Stars:
937
Forks:
32
Description:
Harness the power of ChatGPT inside the GDB or LLDB debugger.
haltakov/natural-language-youtube-search12,531
Language:
Jupyter Notebook
Stars:
936
Forks:
70
Description:
Search inside YouTube videos using natural language.
777genius/claude-code-source-code12,532
Stars:
935
Forks:
1,082
Description:
Claude code source code.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguageTypeScript
CategoryApplications
SubcategoryOther
KeywordsRAG
Stars937
Forks125
Contributors3
Created date2023-02-28
Updated date2026-09-30
Stars in 1 day0
Stars in 7 days0
Rank12,522
Previous rank12,445
Rank change-77
7-day stars rank13,470
Previous 7-day stars rank13,480
7-day stars rank change10
Total stars rank11,709
Previous total stars rank11,692
Total stars rank change-17
CountryUSA
README summary

Domain-specific ChatGTP Starter App ChatGPT is great for casual, general-purpose question-answers but falls short when domain-specific knowledge is needed. Further, it makes up answers to fill its knowledge gaps and never cites its sources, so it can't really be trusted. This starter app uses embeddings coupled with vector search to solve this, or more specifically, to show how OpenAI's chat completions API can be used to create conversational interfaces to domain-specific knowledge. Embeddings, as represented

by vectors of floating-point numbers, measure the "relatedness" of text strings. These are super useful for ranking search results, clustering, classification, etc. Relatedness is measured by cosine similarity. If the cosine similarity between two vectors is close to 1, the vectors are highly similar and point in the same direction. In the case of text embeddings, a high cosine similarity between two embedding vectors indicates that the corresponding text strings are highly related. This starter app uses embeddings to

generate a vector representation of a document, and then uses vector search to find the most similar documents to the query. The results of the vector search are then used to construct a prompt. The response is then streamed to the user. Check out the Supabase blog posts on pgvector and OpenAI embeddings for more background. Technologies used: Nextjs (React framework) + Vercel hosting Supabase (using their pgvector implementation as the vector database) OpenAI API (for generating embeddings and chat completions

) TailwindCSS (for styling) Functional Overview Creating and storing the embeddings: Web pages are scraped, stripped to plain text and split into 1000-character documents OpenAI's embedding API is used to generate embeddings for each document using the "text-embedding-ada-002" model The embeddings are then stored in a Supabase postgres table using pgvector; the table has three columns: the document text, the source URL, and the embedding vectors returned from the OpenAI API. Responding to queries: A single embedding

is generated from the user prompt That embedding is used to perform a similarity search against the vector database The results of the similarity search are used to construct a prompt for GPT-3. 5/GPT-4 The GPT response is then streamed to the user. Getting Started The following set-up guide assumes at least basic familiarity developing web apps with React and Nextjs. Experience with OpenAI APIs and Supabase is helpful but not required to get things working

. Set-up Supabase Create a Supabase account and project at NOTE: Supabase support for pgvector is relatively new (02/2023), so it's important to create a new project if your project was created before then. First we'll enable the Vector extension. In Supabase, this can be done from the web portal through → . You can also do this in SQL by running: Next let's create a table to store our documents and their embeddings. Head over to the SQL Editor and

run the following query: Finally, we'll create a function that will be used to perform similarity searches. Head over to

Frequently asked questions

How many stars and forks are recorded?

gannonh/chatgpt-pgvector has 937 stars and 125 forks.

What is the repository rank?

gannonh/chatgpt-pgvector is ranked 12,522.

What language and category are recorded?

gannonh/chatgpt-pgvector has 937 stars, uses TypeScript and belongs to Applications.

Which repository is closest in rank?

gannonh/chatgpt-pgvector is compared with investbrainapp/investbrain, ranked 12,523 with 937 stars.

README

Domain-specific ChatGTP Starter App

ChatGPT is great for casual, general-purpose question-answers but falls short when domain-specific knowledge is needed. Further, it makes up answers to fill its knowledge gaps and never cites its sources, so it can't really be trusted. This starter app uses embeddings coupled with vector search to solve this, or more specifically, to show how OpenAI's chat completions API can be used to create conversational interfaces to domain-specific knowledge.

Embeddings, as represented by vectors of floating-point numbers, measure the "relatedness" of text strings. These are super useful for ranking search results, clustering, classification, etc. Relatedness is measured by cosine similarity. If the cosine similarity between two vectors is close to 1, the vectors are highly similar and point in the same direction. In the case of text embeddings, a high cosine similarity between two embedding vectors indicates that the corresponding text strings are highly related.

This starter app uses embeddings to generate a vector representation of a document, and then uses vector search to find the most similar documents to the query. The results of the vector search are then used to construct a prompt. The response is then streamed to the user. Check out the Supabase blog posts on pgvector and OpenAI embeddings for more background.

Technologies used:

  • Nextjs (React framework) + Vercel hosting
  • Supabase (using their pgvector implementation as the vector database)
  • OpenAI API (for generating embeddings and chat completions)
  • TailwindCSS (for styling)

Functional Overview

Creating and storing the embeddings:

  • Web pages are scraped, stripped to plain text and split into 1000-character documents
  • OpenAI's embedding API is used to generate embeddings for each document using the "text-embedding-ada-002" model
  • The embeddings are then stored in a Supabase postgres table using pgvector; the table has three columns: the document text, the source URL, and the embedding vectors returned from the OpenAI API.

Responding to queries:

  • A single embedding is generated from the user prompt
  • That embedding is used to perform a similarity search against the vector database
  • The results of the similarity search are used to construct a prompt for GPT-3.5/GPT-4
  • The GPT response is then streamed to the user.

Getting Started

The following set-up guide assumes at least basic familiarity developing web apps with React and Nextjs. Experience with OpenAI APIs and Supabase is helpful but not required to get things working.

Set-up Supabase

  • Create a Supabase account and project at https://app.supabase.com/sign-in. NOTE: Supabase support for pgvector is relatively new (02/2023), so it's important to create a new project if your project was created before then.
  • First we'll enable the Vector extension. In Supabase, this can be done from the web portal through Database → Extensions. You can also do this in SQL by running:
create extension vector;
  • Next let's create a table to store our documents and their embeddings. Head over to the SQL Editor and run the following query:
create table documents (
  id bigserial primary key,
  content text,
  url text,
  embedding vector (1536)
);
  • Finally, we'll create a function that will be used to perform similarity searches. Head over to the SQL Editor and run the following 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;
$$;

Set-up local environment

  • clone the repo: gh repo clone gannonh/chatgpt-pgvector
  • open in your favorite editor (the following assumes VS Code on a Mac)
cd chatgpt-pgvector
code .
  • install dependencies
npm install
  • create a .env.local file in the root directory to store environment variables:
cp .env.local.example .env.local
  • open the .env.local file and add your Supabase project URL and API key. You can find these in the Supabase web portal under Project → API. The API key should be stored in the SUPABASE_ANON_KEY variable and project URL should be stored under NEXT_PUBLIC_SUPABASE_URL.
  • Add your OPENAI API key to .env.local. You can find this in the OpenAI web portal under API Keys. The API key should be stored in the OPENAI_API_KEY variable.
  • [optional] environment variable OPEAI_PROXY be provide to enable your custom proxy of OPENAI api. Left it "" to call official API directly.
  • [optional] environment variable SPLASH_URL be provide to enable your splash (Splash is a javascript rendering service. It’s a lightweight web browser with an HTTP API, implemented in Python 3 using Twisted and QT5) api. Left it "" to fetch url direct.
  • Start the app
npm run dev
Nearby in the ranking
Similar items