A Python library for the ClueAI API
Project description
使NLP成为每个开发者的工具
*Read this in other languages: English
Python 软件包
该软件包提供了开发的功能,以简化在python3中与clueai API的接口。
安装
可以使用 pip
命令安装:
pip install --upgrade clueai
也可以通过源码:
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=["今天天气很好", "我不喜欢这个产品"],
examples=[Example("基本都是欺骗", "消极"),
Example("基本都是惊喜", "积极")],
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": ["消极", "积极"]
}'
|
更大模型更好效果
在用更大模型之前,你需要有个API key, 并且在创建clueai.Client
对象时需要指定这个API key. API key 可以通过这个平台获得,下面是有关分类和生成任务的一个基本的示例
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='情感分析',
inputs=["世界充满了欺骗", "世界和平"],
examples=[Example("基本都是欺骗", "消极"),
Example("基本都是惊喜", "积极")],
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": ["消极", "积极"]
}'
|
模型介绍
当您调用clueai的API时,我们为您的用例指定默认模型。 默认模型非常适合您开始使用,但是在生产环境中,我们建议您通过model_name
参数自己指定特定模型。
返回结果
对于不同的任务返回相对应的clueai对象(例如,对于分类,将是“Classification”)。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clueai-0.0.0.3.tar.gz
(7.8 kB
view hashes)