# qqai
提供[腾讯AI](https://ai.qq.com/)简单易用的python接口。
## 安装
```bash
pip install qqai
```
## 用法
当前包含以下接口:
- [聊天机器人](#聊天机器人)
- [文本翻译](#文本翻译)
- [图片转文字](#图片转文字)
- [人脸检测](#人脸检测)
### 聊天机器人
```py
from qqai import TextChat
siri = TextChat(your_app_id, your_app_key)
# 单句对话
answer = siri.ask('你是谁')
print(answer)
# >>> 我是你的小助手啊
# 连续聊天
siri.chat()
# < 有啥想跟我说的?
# > 你是谁啊?
# < 我是你的小助手啊
# > 你能干嘛呀
# < 呵呵,我能干的事情多的数不清。
```
### 文本翻译
可用语言见[官方文档](https://ai.qq.com/doc/nlptrans.shtml#5-%E6%94%AF%E6%8C%81%E8%AF%AD%E8%A8%80%E5%AE%9A%E4%B9%89)
```py
from qqai import NLPTrans
robot = NLPTrans(you_app_id, you_app_key)
result = robot.run('愿原力与你同在')
print(result)
# {'ret': 0, 'msg': 'ok', 'data': {'source_text': '愿原力与你同在', 'target_text': 'May the Force be with you'}}
# 默认为中英翻译,若需要其他语种翻译,请按一下格式实例化:
# source为源语言,target为目标语言,
robot = NLPTrans(you_app_id, you_app_key, source='en', target='es')
result = robot.run('May the force be with you.')
print(result)
# {'ret': 0, 'msg': 'ok', 'data': {'source_text': 'May the force be with you.', 'target_text': 'Que la fuerza esté contigo.'}}
```
### 图片转文字
```py
from qqai import ImgToText
robot = ImgToText(your_app_id, your_app_key)
# 识别图片URL
result = robot.run('https://yyb.gtimg.com/aiplat/ai/assets/ai-demo/express-6.jpg')
print(result)
# {'ret': 0, 'msg': 'ok', 'data': {'text': '一位男士在海边骑自行车的照片'}}
# 识别打开的本地图片
with open('/my/img.jpeg', 'rb') as image_file:
result = robot.run(image_file)
print(result)
# {'ret': 0, 'msg': 'ok', 'data': {'text': '一艘飞船'}}
```
### 人脸检测
```py
from qqai import Detectface
robot = Detectface(your_app_id, your_app_key)
# 调用方法与图片转文字相同
```
Metadata
Release files for qqai 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qqai-0.1.4.tar.gz | 4.8 kB | Without provenance | Details for qqai-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qqai-0.1.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for qqai-0.1.4-py2.py3-none-any.whl |
Total release size: 8.8 kB
Release files / qqai-0.1.4.tar.gz
| Download URL | qqai-0.1.4.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
916bb5f7e09557e3cd2a9d9a0a1c86f7ecd1e1de3007b153ea6a9f2ed3b9e314
|
|
BLAKE2b-256 checksum How to use checksums |
61e6b661af2bcc83610ea061542f9dd22e1ec6bdac102300ef893add8dda92ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.10.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/3.6.5
|
Release files / qqai-0.1.4-py2.py3-none-any.whl
| Download URL | qqai-0.1.4-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
afcff8ed7dd5a8ec14c5f1e0096baedc6d8fddf6942621bff509ddc1d274bf86
|
|
BLAKE2b-256 checksum How to use checksums |
34765f1e07f6434aa05840c977ac2f505d843b7e52dc08f81f81777e9836e0fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.10.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.19.6 CPython/3.6.5
|
Security for qqai 0.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.