postgresml / korvus

Korvus is a search SDK that unifies the entire RAG pipeline in a single database query. Built on top of Postgres with bindings for Python, JavaScript, Rust and C.
https://postgresml.org
MIT License
1.27k stars 24 forks source link

Exception: error returned from database: function pgml.transform(task => jsonb, inputs => jsonb[], args => jsonb) does not exist #16

Open PragnakalpDev29 opened 2 months ago

PragnakalpDev29 commented 2 months ago

async def main(): collection = Collection("test_collection")

pipeline = Pipeline(
    "v3",
    {
        "text": {
            "splitter": {"model": "recursive_character"},
            "semantic_search": {
                "model": "mixedbread-ai/mxbai-embed-large-v1",
            },
            "full_text_search": {"configuration": "english"},
        }
    }
)

await collection.add_pipeline(pipeline)

documents = [
    {"id": "1", "text": "Korvus is incredibly fast and easy to use."},
    {"id": "2", "text": "Tomatoes are incredible on burgers."},
]
await collection.upsert_documents(documents)

results = await collection.rag(
    {
        "CONTEXT": {
            "vector_search": {
                "query": {
                    "fields": {
                        "text": {
                            "query": "Is Korvus fast?",
                            "parameters": {
                                "prompt": "Represent this sentence for searching relevant passages: "
                            },
                        }
                    },
                },
                "document": {"keys": ["id"]},
                "limit": 5,
            },
            "aggregate": {"join": "\n"},
        },
        "chat": {
            "model": "meta-llama/Meta-Llama-3-8B-Instruct",
            "messages": [
                {
                    "role": "system",
                    "content": "You are a friendly and helpful chatbot",
                },
                {
                    "role": "user",
                    "content": "Given the context\n:{CONTEXT}\nAnswer the question: Is Korvus fast?",
                },
            ],
            "max_tokens": 100,
        },
    },
    pipeline,
)

print(results)

Run the asynchronous function

asyncio.run(main()) print("DONE!")

with this code I got Added Pipeline v3, Now Syncing... Done Syncing v3 Upserting Documents... Done Upserting Documents [00:00:01] ████████████████████████████████████████ 2/2 Traceback (most recent call last): File "/media/pkl43150324/Projects/test/Projects/korvus_test/test2.py", line 219, in asyncio.run(main()) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/media/pkl43150324/Projects/test/Projects/korvus_test/test2.py", line 179, in main results = await collection.rag( Exception: error returned from database: function pgml.transform(task => jsonb, inputs => jsonb[], args => jsonb) does not exist

SilasMarvin commented 1 month ago

What version of pgml are you using? Can you run \dx in your database and share the output?