mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
scram-sha-256
This commit is contained in:
parent
e6c0cfd1f8
commit
2020ca495c
@ -13,7 +13,8 @@ spec:
|
||||
pg_stat_statements.max: '10000'
|
||||
pg_stat_statements.track: all
|
||||
pg_hba:
|
||||
- host prole all all md5
|
||||
- host all all all scram-sha-256
|
||||
- hostssl prole prole-db all scram-sha-256
|
||||
|
||||
bootstrap:
|
||||
initdb:
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
create table if not exists documents
|
||||
(
|
||||
id text primary key default gen_random_uuid()::text,
|
||||
source text,
|
||||
source_id text,
|
||||
content text,
|
||||
document_id text,
|
||||
author text,
|
||||
url text,
|
||||
created_at timestamptz default now(),
|
||||
embedding vector(1536)
|
||||
);
|
||||
|
||||
|
||||
create or replace function match_page_sections(
|
||||
in_embedding vector(1536),
|
||||
in_match_count int default 3,
|
||||
in_document_id text default '%%',
|
||||
in_source_id text default '%%',
|
||||
in_source text default '%%',
|
||||
in_author text default '%%',
|
||||
in_start_date timestamptz default '-infinity',
|
||||
in_end_date timestamptz default 'infinity'
|
||||
)
|
||||
returns table
|
||||
(
|
||||
id text,
|
||||
source text,
|
||||
source_id text,
|
||||
document_id text,
|
||||
url text,
|
||||
created_at timestamptz,
|
||||
author text,
|
||||
content text,
|
||||
embedding vector(1536),
|
||||
similarity float
|
||||
)
|
||||
language plpgsql
|
||||
as
|
||||
$$
|
||||
# variable_conflict use_variable
|
||||
begin
|
||||
return query
|
||||
select documents.id,
|
||||
documents.source,
|
||||
documents.source_id,
|
||||
documents.document_id,
|
||||
documents.url,
|
||||
documents.created_at,
|
||||
documents.author,
|
||||
documents.content,
|
||||
documents.embedding,
|
||||
(documents.embedding <#> in_embedding) * -1 as similarity
|
||||
from documents
|
||||
where in_start_date <= documents.created_at
|
||||
and documents.created_at <= in_end_date
|
||||
and (documents.source_id like in_source_id or documents.source_id is null)
|
||||
and (documents.source like in_source or documents.source is null)
|
||||
and (documents.author like in_author or documents.author is null)
|
||||
and (documents.document_id like in_document_id or documents.document_id is null)
|
||||
order by documents.embedding <#> in_embedding
|
||||
limit in_match_count;
|
||||
end;
|
||||
$$;
|
||||
Loading…
Reference in New Issue
Block a user