docs: add Supabase setup instructions to README
Browse files
README.md
CHANGED
|
@@ -12,4 +12,114 @@ hf_oauth: true
|
|
| 12 |
hf_oauth_expiration_minutes: 480
|
| 13 |
---
|
| 14 |
|
| 15 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
hf_oauth_expiration_minutes: 480
|
| 13 |
---
|
| 14 |
|
| 15 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 16 |
+
|
| 17 |
+
## π Quick Start
|
| 18 |
+
|
| 19 |
+
1. Clone the repository:
|
| 20 |
+
```bash
|
| 21 |
+
git clone https://huggingface.co/spaces/Lucas-C-R/Agents
|
| 22 |
+
cd Agents
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
2. Create and activate a virtual environment:
|
| 26 |
+
1. Linux:
|
| 27 |
+
```bash
|
| 28 |
+
python3 -m venv .venv
|
| 29 |
+
source .venv/bin/activate
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
2. Windows:
|
| 33 |
+
```bash
|
| 34 |
+
python -m venv .venv
|
| 35 |
+
.venv\Scripts\activate
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
3. Install dependencies:
|
| 39 |
+
```bash
|
| 40 |
+
pip install -r requirements.txt
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
4. Configure environment variables:
|
| 44 |
+
```bash
|
| 45 |
+
# API Keys
|
| 46 |
+
export OPENAI_API_KEY="sk-proj-..." # Your OpenAI API key
|
| 47 |
+
export TAVILY_API_KEY="tvly-dev-..." # Your Tavily API key
|
| 48 |
+
export GROQ_API_KEY="gsk_..." # Your Groq API key
|
| 49 |
+
export HF_TOKEN="hf_..." # Your Hugging Face token
|
| 50 |
+
|
| 51 |
+
# Space Configuration
|
| 52 |
+
export SPACE_ID="<your user>/<space name>" # Your Hugging Face space ID
|
| 53 |
+
|
| 54 |
+
# Supabase Configuration
|
| 55 |
+
export SUPABASE_URL="your_supabase_url" # Your Supabase project URL
|
| 56 |
+
export SUPABASE_KEY="your_supabase_key" # Your Supabase API key
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
5. Run the application:
|
| 60 |
+
```bash
|
| 61 |
+
python app.py
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
## π§ Detailed Configuration
|
| 65 |
+
|
| 66 |
+
### 1. Supabase Setup
|
| 67 |
+
|
| 68 |
+
1. Create an organization on [Supabase](https://supabase.com/)
|
| 69 |
+
2. Create a new project
|
| 70 |
+
3. Set up a password and select the nearest region
|
| 71 |
+
4. In the "Project Overview" tab, locate the "Project API" section
|
| 72 |
+
5. Copy the Project URL to the `SUPABASE_URL` environment variable
|
| 73 |
+
6. Copy the API Key to the `SUPABASE_KEY` environment variable
|
| 74 |
+
|
| 75 |
+
### 2. Database Configuration
|
| 76 |
+
|
| 77 |
+
Execute the following SQL in the Supabase SQL editor:
|
| 78 |
+
|
| 79 |
+
```sql
|
| 80 |
+
create extension if not exists vector;
|
| 81 |
+
create table if not exists documents (
|
| 82 |
+
id uuid primary key default gen_random_uuid(),
|
| 83 |
+
content text,
|
| 84 |
+
metadata jsonb,
|
| 85 |
+
embedding vector(768)
|
| 86 |
+
);
|
| 87 |
+
|
| 88 |
+
DROP FUNCTION IF EXISTS match_documents_langchain(vector, integer);
|
| 89 |
+
|
| 90 |
+
create or replace function match_documents_langchain(
|
| 91 |
+
query_embedding vector(768),
|
| 92 |
+
match_count int default 5
|
| 93 |
+
)
|
| 94 |
+
returns table (
|
| 95 |
+
id uuid,
|
| 96 |
+
content text,
|
| 97 |
+
metadata jsonb,
|
| 98 |
+
similarity float
|
| 99 |
+
)
|
| 100 |
+
as $$
|
| 101 |
+
begin
|
| 102 |
+
return query
|
| 103 |
+
select
|
| 104 |
+
documents.id,
|
| 105 |
+
documents.content,
|
| 106 |
+
documents.metadata,
|
| 107 |
+
1 - (documents.embedding <=> query_embedding) as similarity
|
| 108 |
+
from documents
|
| 109 |
+
order by documents.embedding <=> query_embedding
|
| 110 |
+
limit match_count;
|
| 111 |
+
end;
|
| 112 |
+
$$ language plpgsql;
|
| 113 |
+
```
|
| 114 |
+
|
| 115 |
+
### 3. Data Import
|
| 116 |
+
|
| 117 |
+
1. Access the "Table Editor" tab in Supabase
|
| 118 |
+
2. Select the "documents" table
|
| 119 |
+
3. Click on "Import data from CSV"
|
| 120 |
+
4. Select the `supabase_docs.csv` file from the project directory
|
| 121 |
+
5. Click "Import data" and wait for completion
|
| 122 |
+
|
| 123 |
+
## π License
|
| 124 |
+
|
| 125 |
+
This project is under the MIT License. See the LICENSE file for more details.
|