npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@re-ai/vector

v1.0.5

Published

ReAI 向量处理

Downloads

94

Readme

Vector Data Management Package

这是一个用于管理和操作向量数据的 Node.js 包,特别适用于在 PostgreSQL 数据库中存储和检索向量数据。本包提供了强大的功能,以支持向量数据的添加、更新和查询,适用于需要处理大量向量数据的应用。

更新

  • 24.05.04 添加ollama部署的向量模型支持

特点

  • 简单易用的 API。
  • 支持 PostgreSQL 数据库。
  • 提供向量数据的存储、更新和查询功能。

安装

您可以通过 npm 来安装这个包:

npm install @re-ai/vector

快速开始

以下是如何在您的项目中使用这个包的基本示例:

设置

首先,确保您的环境已正确配置 PostgreSQL 数据库连接。

使用

import { VectorModel, VectorService } from '@re-ai/vector';

// 初始化服务
const vectorService = new VectorService('your_vector_table');

// 添加向量数据
vectorService.addTextWithEmbedding('示例文本').then(() => {
  console.log('文本和对应的向量已添加到数据库。');
});

// 查询最近的向量数据
vectorService.findNearestByText('查询文本', 5).then(results => {
  console.log('查询到的最近的向量数据:', results);
});

API 文档

VectorService

  • addTextWithEmbedding(text: string): Promise<{id: number}> 添加文本及其对应的向量到数据库。

  • updateTextWithEmbedding(id: number, newText: string): Promise<{id: number}> 更新文本及对应的向量

  • findNearestByText(queryText: string, limit: number): Promise<VectorModel[]> 查找与给定文本向量最接近的向量数据。

  • delete(id: number): Promise 删除文本及对应的向量

配置

请在环境变量中配置以下信息,以便包能正确连接到 PostgreSQL 数据库:

  • POSTGRES_HOST - 数据库的主机地址(*必填)。
  • POSTGRES_USER - 数据库用户名(默认:reai_user)。
  • POSTGRES_PASSWORD - 数据库密码(默认:reai_password)。
  • POSTGRES_DB - 数据库名称(默认:reai_db)。
  • POSTGRES_PORT - 数据库端口(默认: 5432)。

添加embedding接口参数

  • EMBEDDING_API_URL - embedding接口地址(示例: http://192.168.31.218:4080/v1/embeddings)。
  • EMBEDDING_API_KEY - embedding接口key (示例: sk-xxxxxx)。