File size: 844 Bytes
8d93ff7
 
 
 
 
 
 
 
 
 
 
73148ac
 
8d93ff7
 
adae8d3
dbdcb6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Agent Course Test
emoji: 🦀
colorFrom: green
colorTo: yellow
sdk: gradio
sdk_version: 5.29.1
app_file: app.py
pinned: false
license: mit
short_description: Agent model to obtain huggingface agent course cert
hf_oauth: true
hf_oauth_expiration_minutes: 480
---


Script to setting up tables and vector search
 "CREATE EXTENSION IF NOT EXISTS vector;"
 """
CREATE TABLE IF NOT EXISTS documents2 (
    id BIGINT PRIMARY KEY,
    content TEXT,
    metadata JSONB,
    embedding VECTOR(1536)
);
"""

create or replace function match_documents_2(
  query_embedding vector(1536),
  match_count int default 5
)
returns table (
  id bigint,
  content text,
  metadata jsonb,
  embedding vector
)
language sql
as $$
  select id, content, metadata, embedding
  from documents2
  order by embedding <#> query_embedding
  limit match_count;
$$;