Skip to content

Commit

Permalink
feat(backend): add pgvector-python
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbloxhub committed Jan 28, 2025
1 parent 3b63851 commit 17272e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ authors = [
]
dependencies = [
"psycopg[binary]>=3.2.3",
"pgvector>=0.3.6",
"numpy>=2.1.3",
"chonkie[semantic]>=0.4.0",
"fastapi[standard]>=0.115.5",
Expand Down
4 changes: 4 additions & 0 deletions src/aigis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from fastapi import Depends, Request
from openai import AsyncOpenAI
from pgvector.psycopg import ( # pyright: ignore [reportMissingTypeStubs]
register_vector_async, # pyright: ignore [reportUnknownVariableType]
)
from psycopg import AsyncConnection

from supabase import AsyncClient, AsyncClientOptions, create_async_client
Expand Down Expand Up @@ -59,6 +62,7 @@ async def openai_client(_request: Request) -> AsyncGenerator[AsyncOpenAI]:
@asynccontextmanager
async def postgres_client(_request: Request) -> AsyncGenerator[AsyncConnection]:
conn = await AsyncConnection.connect(postgres_url)
await register_vector_async(conn)
try:
yield conn
finally:
Expand Down
14 changes: 14 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17272e7

Please sign in to comment.