0.1.1 • Published 6 months ago

@re-ai/volc-knowledge v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

@re-ai/volc-knowledge

火山引擎知识库接口接入SDK

安装

npm install @re-ai/volc-knowledge

环境变量

  • REAI_VOLC_ACCESS_KEY_ID=xxxxxx // 火山引擎AK
  • REAI_VOLC_SECRET_KEY=xxxx // 火山引擎SK
  • REAI_VOLC_REGION=cn-beijing // 火山引擎地域

功能特性

  • 知识库管理(创建/更新/删除/查询/检索/聊天)
  • 文档管理(添加/更新/删除/查询/元数据更新)
  • 切片管理(添加/更新/删除/查询/重排)
  • 重排功能(基于模型的搜索结果优化)

快速开始

import { ReAIVolcKnowledge } from '@re-ai/volc-knowledge';

// 知识库API示例
const knowledgeInfo = await ReAIVolcKnowledge.doRequest<InfoKnowledgeResponse>({
  endpoint: '/api/knowledge/collection/info',
  method: 'POST',
  body: {
    name: 'reai_test'
  }
});

// 文档API示例
const docList = await ReAIVolcKnowledge.doRequest<ListDocumentResponse>({
  endpoint: '/api/knowledge/doc/list',
  method: 'POST',
  body: {
    collection_name:'reai_test',
    project: '',
    offset: 0,
    limit: 100,
    return_token_usage: true
  }
});

// 切片API示例
const updatedSlice = await ReAIVolcKnowledge.doRequest<any>({
  endpoint: '/api/knowledge/point/update',
  method: 'POST',
  body: {
    collection_name: 'reai_test',
    project: '',
    point_id: 'reai_123456-0',
    content: 'test content'
  }
});

// 搜索API示例
const searchResults = await ReAIVolcKnowledge.doRequest<SearchKnowledgeResponse>({
  endpoint: '/api/knowledge/collection/search_knowledge',
  method: 'POST',
  body: {
    name: 'reai_test',
    project: '',
    query: '问题'
  }
});

参考文档

开发

# 安装依赖
npm install

# 构建
npm run build

# 运行测试
npm test

贡献

欢迎提交Pull Request。请确保遵循以下规范:

  • 代码风格符合项目规范
  • 提交信息遵循Conventional Commits
  • 新增功能需包含单元测试

许可证

MIT

0.1.1

6 months ago

0.1.0

6 months ago

0.0.1

6 months ago