openai / chatgpt-retrieval-plugin

The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to create table documents on postgres

RiverFerry opened this issue · comments

env

export DATASTORE=postgres
export PG_HOST=localhost
export PG_PORT=5432
export PG_USER=river
export PG_DB=postgres
export PG_PASSWORD=a123456

problem

I encountered an issue while running a plugin on my local Mac. The problem arises when I try to post to an upsert API using FastAPI.

image

Below is the error that the plugin prints:

2024-01-26 17:28:53.704 | INFO | services.date:to_unix_timestamp:23 - Invalid date format: string
begin upsert pgsql.
2024-01-26 17:28:53.708 | ERROR | server.main:upsert:86 - current transaction is aborted, commands ignored until end of transaction block

This error occurs when the code executes this block: self.client.commit().
Here is the SQL query:

INSERT INTO documents (id, content, embedding, document_id, source, source_id, url, author, created_at) VALUES ('1234_0', 'fdfgvdfbfgnghnhgnghnghngh', '[-0.00477524 -0.01822915 0.00531684 ... -0.01504565 -0.01974824 -0.00251642]', '1234', 'email', 'string', 'string', 'string', '(datetime.datetime(2024, 1, 26, 17, 14, 58),)') ON CONFLICT (id) DO UPDATE SET content = 'fdfgvdfbfgnghnhgnghnghngh', embedding = '[-0.00477524 -0.01822915 0.00531684 ... -0.01504565 -0.01974824 -0.00251642]', document_id = '1234', source = 'email', source_id = 'string', url = 'string', author = 'string', created_at = '(datetime.datetime(2024, 1, 26, 17, 14, 58),)'

When I run this query in pgAdmin, it appears that the documents table does not exist.
image

I found a _create_table function in other database providers, but I couldn't find a similar function for PostgreSQL.

Could someone please help me identify the reason for this issue?

Thank you!

postgre

CREATE TABLE IF NOT EXISTS documents (
    id TEXT PRIMARY KEY,
    source TEXT,
    source_id TEXT,
    content TEXT,
    document_id TEXT,
    author TEXT,
    url TEXT,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    embedding vector
);

i use this create sql, and now i can upsert successful.
but i don not know whether it is strict correct.