Spaces:
Sleeping
Sleeping
File size: 1,969 Bytes
8743b94 af9a32a 8743b94 af9a32a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
---
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
```
|