This is a module for MobAI.API.
Project description
ShanHeUniversity
使用方法
使用流程总览
1.申请密钥(apply)
2.新建记录(CreateNewAPI)
3.循环聊天(ChatAPI)
申请密钥
准备工作
1.Python3.*
2.pip install shanheuniversity
示例代码
from ShanHeuniversity import api
api.apply(email='demo@shu.edu')
参数总览
参数名 | 参数类型 | 是否必填 | 默认值 | 示例 |
---|---|---|---|---|
String | 是 | 无 | sb@xxx.com |
新建记录
准备工作
1.Python3.*
2.pip install shanheuniversity
示例代码
from ShanHeuniversity import api
import sys
import os
function = lambda data: sys.stdout.write(str(data))
api._api_key = os.getenv('MOBAI_API_KEY')
function(
api.CreateNewAPI(model='MobAI')
)
参数总览
参数名 | 参数类型 | 是否必填 | 默认值 | 示例 |
---|---|---|---|---|
api_key | String | 是 | 无 | sk-demo |
model | String | 是 | 无 | 天马行空 |
循环聊天
准备工作
1.Python3.*
2.pip install shanheuniversity
示例代码
import sys
import os
from ShanHeuniversity import api
function = lambda data: sys.stdout.write(
'MobAI:' + data.data.reply + '
'
if data.state == 'success'
else 'ERROR:' + data.data.error + '
'
)
ask = input
api._api_key = os.getenv('MOBAI_API_KEY')
while True:
function(
api.ChatAPI(
_id='id',
password='password',
question=ask('User:')
)
)
参数总览
参数名 | 参数类型 | 是否必填 | 默认值 | 示例 |
---|---|---|---|---|
api_key | String | 是 | 无 | sk-demo |
_id | String | 是 | 无 | 0000-0000-0000-0000 |
password | String | 是 | 无 | password-1234 |
question | String | 是 | 无 | Hello! |
可参考示例
以下代码可直接运行,但不建议,因为这只是一个最基本的示例。
import sys
from ShanHeuniversity import api
ask = input
function = lambda data: sys.stdout.write(
'MobAI:' + str(data.get('data').get('reply')) + '
'
if data.get('state') == 'success'
else 'ERROR:' + data.get('data').get('error') + '
'
)
api.apply(email=ask('Mail:'))
api._api_key = ask('Key:')
ai = api.CreateNewAPI(model=ask('Model:'))
while True:
function(
api.ChatAPI(
_id=ai.data.id,
password=ai.data.password,
question=ask('User:')
)
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ShanHeuniversity-0.1.1.tar.gz
.
File metadata
- Download URL: ShanHeuniversity-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc53ca790bae978c24207fb07c3693978c99f4182e39a238ae82971ad61b3b50 |
|
MD5 | 1d78559c97b93fae860d1f93d5edd232 |
|
BLAKE2b-256 | 22097e5a57a1a55beadbbd3bc51f9b7bcb1a1052748ef91f6558780a85af2f0c |
File details
Details for the file ShanHeuniversity-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: ShanHeuniversity-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5b243f2585ffd0004525ea6049f1880a3d11f846fb3601dd8f5f1c1b52d8c43 |
|
MD5 | fd5613822f154a542b063de54ef1051c |
|
BLAKE2b-256 | 80a906946c3cc21497f17524640e4716f21f084d95e6d8b038ecca4e008b7207 |