athenadb
Add Workflow Deployment
Athenadb是一个简单,无服务器的分布式矢量数据库,可以用作API。它用Cloudflare工人AI,D1,矢量化编写。
wrangler login登录牧马人。 Athenadb需要每月5美元的工人来订阅职能。git clone https://github.com/TimeSurgeLabs/athenadb.git
cd athenadb
npm run create-vector
npm run create-db复制输出数据库ID并将其粘贴到database_id下的wrangler.toml中。然后,运行以下两个命令:
npm run init-db
npm run deploy您应该使用API URL获得输出。您现在可以使用API端点。
POST /:namespace/insert将文本数据插入数据库。文本使用CloudFlare AI转换为嵌入式,并与唯一的标识符一起存储。
input :一个字符串(最大1024个字符)。inputs :一系列字符串(每个最大1024个字符)。POST /:namespace/query查询数据库中的类似文本嵌入。指定URL中的?limit=number以指定要返回的结果数。默认值为5,最大值为20。
input :一个用于查询的字符串。 (最大1024个字符)inputs :批次查询的一系列字符串。 (每个最大1024个字符)GET /:namespace/:uuid使用其唯一标识符(UUID)从数据库中检索特定条目。添加查询参数?vector=true以与条目一起检索矢量。添加查询参数?db_id=true以便与条目一起检索SQL表ID。
GET /:namespace?limit=10&offset=0从给定的名称空间中检索所有条目。限制最多可以设置为100个条目。添加查询参数?vector=true以与条目一起检索向量。添加查询参数?db_id=true以与条目一起检索SQL表ID。
DELETE /:namespace/:uuid使用其唯一标识符(UUID)从数据库中删除特定条目。警告:此操作是不可逆转的。
DELETE /:namespace从给定的名称空间中删除所有条目。警告:此操作是不可逆转的。
POST /embeddings生成给定文本的嵌入,而无需将其存储在数据库中。
text :要生成嵌入的字符串。GET /返回“ Hello World!”的测试端点作为回应。
fetch ( 'https://athenadb.yourusername.workers.dev/your-namespace/insert' , {
method : 'POST' ,
headers : { 'Content-Type' : 'application/json' } ,
body : JSON . stringify ( { input : 'Your text here' } )
} ) fetch ( 'https://athenadb.yourusername.workers.dev/your-namespace/query' , {
method : 'POST' ,
headers : { 'Content-Type' : 'application/json' } ,
body : JSON . stringify ( { input : 'Query text' } )
} ) fetch ( 'https://athenadb.yourusername.workers.dev/your-namespace/your-uuid' , {
method : 'GET'
} ) fetch ( 'https://athenadb.yourusername.workers.dev/your-namespace/your-uuid' , {
method : 'DELETE'
} ) fetch ( 'https://athenadb.yourusername.workers.dev/embeddings' , {
method : 'POST' ,
headers : { 'Content-Type' : 'application/json' } ,
body : JSON . stringify ( { text : 'Your text here' } )
} )