Pgvector column names

how do you specify column names for pgvector ? It keeps lookin for name column

import os
from dotenv import load_dotenv
import logging

from agno.agent import Agent, AgentKnowledge
from agno.models.openai import OpenAIChat
from agno.vectordb.pgvector import PgVector, SearchType
from agno.embedder.openai import OpenAIEmbedder
from agno.tools.sql import SQLTools  # Import SQL Tools
from pydantic import BaseModel
from typing import List, Any

# Load environment variables from .env file
load_dotenv()

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Define the database URL using the value from the .env file.
db_url = os.getenv("DATABASE_URL")

# Fetch OpenAI API key from environment variables.
openai_api_key = os.getenv("OPENAI_API_KEY")

# Initialize PgVector instance for the 'articles' table.
vector_db = PgVector(
    db_url=db_url,
    table_name="articles",  # This is the table that holds your articles.
    schema="public",  # Specify the correct schema (public) so the query uses public.articles.
    embedder=OpenAIEmbedder(api_key=openai_api_key),  # Using the OpenAI embedder with API key from .env.
    search_type=SearchType.hybrid,  # Hybrid search mixes vector and keyword matching.
)

class ArticleSearchResult(BaseModel):
    articles: List[dict] = []  # Provide a default value so 'articles' is not treated as required

## Wrap PgVector with AgentKnowledge for proper search handling.
knowledge_base = AgentKnowledge(vector_db=vector_db)

# Instantiate SQL tool for retrieving table schema information.
sql_tool = SQLTools(db_url=db_url, schema="public", describe_table=True)

# Create the Agno agent with the integrated knowledge base.
agent = Agent(
    model=OpenAIChat(id="gpt-4o", structured_outputs=False),  # Disable structured outputs.
    knowledge=knowledge_base,  # Use AgentKnowledge for proper handling of search parameters.
    search_knowledge=True,     # Enable the search tool for the knowledge base.
    tools=[sql_tool],          # Add SQL tool so that the agent can query for the schema details.
    description="Agent that answers questions using relevant articles from the database.",
    instructions=(
        "Whenever a question is provided, the agent will retrieve the top 4 most "
        "related articles from the database using PgVector as its knowledge base, "
        "and these results are then used to form the answer. "
        "Note: The 'articles' table schema is as follows - created_at: timestamp, "
        "title: text, embedding: vector, content: text, published_date: date, "
        "authors: text, id: uuid. If you need further details about the table columns, "
        "you can use the SQL tool's 'describe_table' function. "
        "Refer to the [SQL Toolkits docs](https://docs.agno.com/tools/toolkits/sql) for guidance."
    ),
    markdown=True,
    debug_mode=True,
    show_tool_calls=True,
)

Hi @jeremy_of_course
Thanks for reaching out and for using Agno! I’ve looped in the right engineers to help with your question. We usually respond within 24 hours, but if this is urgent, just let us know, and we’ll do our best to prioritize it.
Appreciate your patience—we’ll get back to you soon! :smile:

Hey @jeremy_of_course

It sounds like PgVector might be defaulting to looking for a column named "name", likely because it doesn’t know which column contains the vector embeddings.

Try explicitly specifying the column name in your PgVector initialization like this:

vector_db = PgVector(
    db_url=db_url,
    table_name="articles",
    schema="public",
    column_name="embedding",  # Explicitly tell PgVector which column to use
    embedder=OpenAIEmbedder(api_key=openai_api_key),
    search_type=SearchType.hybrid,
)

This will confirm if the embedding column exists as expected.

Let me know if that helps!