Making NLP part of every developer's toolkit.
This package provides functionality developed to simplify interfacing with the ClueAI API in Python 3.
The package can be installed with pip
:
pip install --upgrade clueai
Install from source:
python setup.py install
python 🔐 | curl 🔐⚡⚡ |
import clueai
from clueai.classify import Example
cl = clueai.Client("", check_api_key=False)
response = cl.classify(
model_name='clueai-base',
task_name='产品分类',
inputs=["强大图片处理器,展现自然美丽的你,,修复部分小错误,提升整体稳定性。", "求闲置买卖,精品购物,上畅易无忧闲置商城,安全可信,优质商品有保障"],
labels = ["美颜", "二手", "外卖", "办公", "求职"])
print('prediction: {}'.format(response.classifications)) |
curl --location --request POST 'https://www.modelfun.cn/modelfun/api/serving_api' \
--header 'Content-Type: application/json' \
--header 'Model-name: clueai-base' \
--data '{
"task_type": "classify",
"task_name": "产品分类",
"input_data": ["强大图片处理器,展现自然美丽的你,,修复部分小错误,提升整体稳定性。", "求闲置买卖,精品购物,上畅易无忧闲置商城,安全可信,优质商品有保障"],
"labels": ["美颜", "二手", "外卖", "办公", "求职"]
}' |
To use bigger model, you must have an API key and specify it as a string when creating the clueai.Client
object. API keys can be created through the platform. This is a basic example of the creating the client and using the generate
endpoint.
python 🔐 | curl 🔐⚡⚡ |
import clueai
from clueai.classify import Example
# initialize the Clueai Client with an API Key
cl = clueai.Client('YOUR_API_KEY')
response = cl.classify(
model_name='clueai-large',
task_name='情感分析',
task_name='产品分类',
inputs=["强大图片处理器,展现自然美丽的你,,修复部分小错误,提升整体稳定性。", "求闲置买卖,精品购物,上畅易无忧闲置商城,安全可信,优质商品有保障"],
labels = ["美颜", "二手", "外卖", "办公", "求职"])
print('prediction: {}'.format(response.classifications)) |
curl --location --request POST 'https://www.modelfun.cn/modelfun/api/serving_api' \
--header 'Content-Type: application/json' \
--header 'Model-name: clueai-large' \
--header 'Api-Key: BEARER {api_key}' \
--data '{
"task_type": "classify",
"task_name": "产品分类",
"input_data": ["强大图片处理器,展现自然美丽的你,,修复部分小错误,提升整体稳定性。", "求闲置买卖,精品购物,上畅易无忧闲置商城,安全可信,优质商品有保障"],
"labels": ["美颜", "二手", "外卖", "办公", "求职"]
}' |
When you call Clueai's APIs we decide on a good default model for your use-case behind the scenes. The default model is great to get you started, but in production environments we recommend that you specify the model size yourself via the model_name
parameter.
All of the endpoint functions will return a Clueai object corresponding to the endpoint (e.g. for classify, it would be Classify
). The responses can be found as instance variables of the object (e.g. classify would be Classify.prediction
). Printing the Clueai response object itself will display an organized view of the instance variables.