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' } )
} )