Code Monkey home page Code Monkey logo

cmer-knowledge-base's Introduction

Cmer-knowledge-base PHP SDK

此包包含知识库相关的CURD操作,以及文件导入知识库
文档地址:https://apihub.cmer.com/docs/knowledge-base.html

安装

composer require hbb/cmer-knowledge-base

使用

<?php

require_once 'vendor/autoload.php';

$apikey="xxxxxxxxxx";  # 授权码
$cmer = new \Hbb\CmerKnowledgeBase\CmerClient($apikey);

# 知识库索引
$index_name = "hbb-gpts";

# 新增知识库
$model = new \Hbb\CmerKnowledgeBase\models\CreateEmbeddingModel($index_name, "Q:你是谁?\n A:我是一个聊天机器人。");
$model->tag = "chatbot";
# 扩展字段
$model->meta = [
    "cate" => "退款"
];
$response = $cmer->crud_create($model);
print_r($response->getBody()->getContents());

# 通过ES召回知识库
$model = new \Hbb\CmerKnowledgeBase\models\SelectEmbeddingEsModel($index_name, "你是谁");
$response = $cmer->crud_select_es($model);
$esdoc = json_decode($response->getBody()->getContents(), true);
print_r($esdoc);

# 通过向量召回知识库
$model = new \Hbb\CmerKnowledgeBase\models\SelectEmbeddingModel($index_name, "你是谁");
$response = $cmer->crud_select_vector($model);
$doc = json_decode($response->getBody()->getContents(), true);
print_r($doc);


# 修改知识库
$model = new \Hbb\CmerKnowledgeBase\models\UpdateEmbeddingModel($index_name, "Q:你是谁?\n A:我是一个聊天机器人。你呢?", $doc[0]["uuid"]);
$model->tag = '测试';
$model->meta = [
    "cate" => "退款测试"
];
$response = $cmer->crud_update($model);
print_r($response->getBody()->getContents());

cmer-knowledge-base's People

Contributors

haizibinbin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.