Skip to content

Conversation

@yangs16
Copy link
Contributor

@yangs16 yangs16 commented Dec 9, 2025

A Cloudberry/PostgreSQL extension that provides AI-powered functions using various LLM providers (OpenAI, Anthropic, Google Gemini, AWS Bedrock).

Features

  • Multiple AI Providers: Support for OpenAI, Anthropic, Google Gemini, and AWS Bedrock
  • User Isolation: Each user manages their own API keys and providers
  • Row Level Security: PostgreSQL RLS ensures users can only access their own configurations
  • AI Functions: Ask questions, generate embeddings, classify text, extract structured data, summarize, translate, and more
  • Simple Setup: No complex encryption keys, users directly manage their API keys

Provide a set of AI functions powered by LLM/VLM
Copy link

@xtangcode xtangcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tuhaihe
Copy link
Member

tuhaihe commented Dec 23, 2025

More comments:

  1. License Compliance

The contrib/aifun/requirements.txt file introduces new Python dependencies, but cannot be added the standard Apache license header. So need to add it to pom.xml for license compliance checking exclusion.

  1. Build Integration

I noticed that aifun is not added to contrib/Makefile's SUBDIRS list. Should this extension be built automatically with Cloudberry, or is it expected to be built separately by users who need it?

Personally, I would prefer the former, as it helps make the new extension more visible and easier for users to discover.

BTW, the current Makefile runs pip install during make install, which auto-pulls Python dependencies and requires network access. This could be problematic for production/offline builds.

@tuhaihe
Copy link
Member

tuhaihe commented Dec 23, 2025

Errors return when running make install:

[gpadmin@cdw aifun]$ make install
/usr/bin/mkdir -p '/usr/local/cloudberry-db/share/postgresql/extension'
/usr/bin/mkdir -p '/usr/local/cloudberry-db/share/postgresql/extension'
Installing Python handler files to /usr/local/cloudberry-db/lib/python/aifun
mkdir -p '/usr/local/cloudberry-db/lib/python/aifun'
cp -a .//aifun/*.py '/usr/local/cloudberry-db/lib/python/aifun/'
cp -a .//aifun/providers '/usr/local/cloudberry-db/lib/python/aifun/'
cp .//requirements.txt '/usr/local/cloudberry-db/lib/python/aifun/'
/usr/bin/python3 -m pip install --user --upgrade -r '/usr/local/cloudberry-db/lib/python/aifun/requirements.txt'
Collecting requests==2.32.5
  Downloading requests-2.32.5-py3-none-any.whl (64 kB)
     |████████████████████████████████| 64 kB 1.2 MB/s             
Collecting boto3==1.40.72
  Downloading boto3-1.40.72-py3-none-any.whl (139 kB)
     |████████████████████████████████| 139 kB 2.3 MB/s            
Collecting PyPDF2==3.0.1
  Downloading pypdf2-3.0.1-py3-none-any.whl (232 kB)
     |████████████████████████████████| 232 kB 12.1 MB/s            
Collecting python-pptx==1.0.2
  Downloading python_pptx-1.0.2-py3-none-any.whl (472 kB)
     |████████████████████████████████| 472 kB 26.7 MB/s            
Collecting python-docx==1.2.0
  Downloading python_docx-1.2.0-py3-none-any.whl (252 kB)
     |████████████████████████████████| 252 kB 64.9 MB/s            
Collecting pypdfium2==5.0.0
  Downloading pypdfium2-5.0.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB)
     |████████████████████████████████| 3.0 MB 96.2 MB/s            
ERROR: Could not find a version that satisfies the requirement pillow==12.0.0 (from versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 2.0.0, 2.1.0, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4.0, 2.5.0, 2.5.1, 2.5.2, 2.5.3, 2.6.0, 2.6.1, 2.6.2, 2.7.0, 2.8.0, 2.8.1, 2.8.2, 2.9.0, 3.0.0, 3.1.0rc1, 3.1.0, 3.1.1, 3.1.2, 3.2.0, 3.3.0, 3.3.1, 3.3.2, 3.3.3, 3.4.0, 3.4.1, 3.4.2, 4.0.0, 4.1.0, 4.1.1, 4.2.0, 4.2.1, 4.3.0, 5.0.0, 5.1.0, 5.2.0, 5.3.0, 5.4.0, 5.4.1, 6.0.0, 6.1.0, 6.2.0, 6.2.1, 6.2.2, 7.0.0, 7.1.0, 7.1.1, 7.1.2, 7.2.0, 8.0.0, 8.0.1, 8.1.0, 8.1.1, 8.1.2, 8.2.0, 8.3.0, 8.3.1, 8.3.2, 8.4.0, 9.0.0, 9.0.1, 9.1.0, 9.1.1, 9.2.0, 9.3.0, 9.4.0, 9.5.0, 10.0.0, 10.0.1, 10.1.0, 10.2.0, 10.3.0, 10.4.0, 11.0.0, 11.1.0, 11.2.1, 11.3.0)
ERROR: No matching distribution found for pillow==12.0.0
make: *** [Makefile:28: python-install] Error 1

@tuhaihe
Copy link
Member

tuhaihe commented Dec 23, 2025

postgres=# CREATE EXTENSION aifun;
ERROR:  required extension "plpython3u" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.

postgres=# create extension plpython3u;
CREATE EXTENSION

postgres=# CREATE EXTENSION aifun;
ERROR:  required extension "vector" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.

postgres=# create extension vector;
ERROR:  could not open extension control file "/usr/local/cloudberry-db/share/postgresql/extension/vector.control": No such file or directory

Does the aifun need the pgvector as a required dependency too?

@yangs16
Copy link
Contributor Author

yangs16 commented Dec 23, 2025

/usr/bin/python3 -m pip install --user --upgrade -r '/usr/local/cloudberry-db/lib/python/aifun/requirements.txt'

It seems that the Python3 environment is not what provided by Cloudberry. Please verify that you are using the correct environment.

@yangs16
Copy link
Contributor Author

yangs16 commented Dec 23, 2025

postgres=# CREATE EXTENSION aifun;
ERROR:  required extension "plpython3u" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.

postgres=# create extension plpython3u;
CREATE EXTENSION

postgres=# CREATE EXTENSION aifun;
ERROR:  required extension "vector" is not installed
HINT:  Use CREATE EXTENSION ... CASCADE to install required extensions too.

postgres=# create extension vector;
ERROR:  could not open extension control file "/usr/local/cloudberry-db/share/postgresql/extension/vector.control": No such file or directory

Does the aifun need the pgvector as a required dependency too?

You can try with:

CREATE EXTENSION aifun CASCADE;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants