Final_Assignment / README.md
cuizhanming
Update README.md
8743b94
---
title: Template Final Assignment
emoji: πŸ•΅πŸ»β€β™‚οΈ
colorFrom: indigo
colorTo: indigo
sdk: gradio
sdk_version: 5.25.2
app_file: app.py
pinned: false
hf_oauth: true
# optional, default duration is 8 hours/480 minutes. Max duration is 30 days/43200 minutes.
hf_oauth_expiration_minutes: 480
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
## 1. Setup Supabase for Vector Store, following [run this SQL Editor](https://supabase.com/dashboard/project/upkfycxsetvrlochkrti/sql/c412918f-ec41-4030-9261-80bc415e247e)
- enable `vector` extension;
- create `documents` table;
- create `match_documents_langchain` function.
```
-- Enable the pgvector extension to work with embedding vectors
create extension vector;
-- 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 works for OpenAI embeddings, change if needed
);
-- Create a function to search for documents
create function match_documents_langchain (
query_embedding vector,
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;
$$;
```
## 2. Setup Supabase API Key
```shell
export SUPABASE_URL=https://upkfycxsetvrlochkrti.supabase.co
export SUPABASE_SERVICE_KEY=
```
## 3. Setup Google Gemini API Key, or Groq Cloud
```shell
# Google Gemini
export GOOGLE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxx_xxxxxxxx
# Groq Cloud
export GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```