postllm
postllm:在 PostgreSQL 内原生调用 OpenAI 兼容及本地大语言模型运行时
postllm · postllm:在 PostgreSQL 内原生调用 OpenAI 兼容及本地大语言模型运行时
概览
PostgreSQL · 13, 14, 15, 16, 17, 18
用法
来源:
- Official extension control file
- Official upstream documentation
- Official API reference
- Official configuration guide
postllm 0.1.0 让 PostgreSQL SQL 能调用托管或本地 LLM 工作流。它涵盖聊天与补全、嵌入、分块、检索和重排,以及配置档、密钥、角色权限、模型别名与出站主机策略。推理会同步运行在数据库后端中。
核心流程
提供服务前先调用 postllm.runtime_discover() 与 postllm.runtime_ready()。postllm.settings() 和 postllm.capabilities() 描述当前环境。API 参考按类别列出消息构造器、生成函数、结构化输出与工具、嵌入、postllm.ingest_document、重排、混合排序和 RAG 辅助函数。
治理与运维
应使用 postllm.profile*、postllm.secret*、postllm.permission* 和 postllm.model_alias* 函数组,而不是把配置散落在应用 SQL 中。限制 http_allowed_hosts 和 http_allowed_providers。模型调用可能把提示、数据行、文档和图像发送到 PostgreSQL 外部,并在等待网络或本地推理时占用后端;投入生产前必须考虑隐私、授权、超时、重试、费用、供应商保留策略与事务时长。