Please go to MODELFUN to try examples
Eliminate the bottleneck of handmade marks and release AI potential.
Modelfun Python SDK
This package provides functionality developed to simplify interfacing with the [MODELFUN API] in Python 3.
Installation
The package can be installed with pip:
pip install --upgrade modelfun
Install from source:
python setup.py install
Requirements
- Python 3.6+
Quick Start
To use this library, you must have an API key and specify it as a string when creating the modelfun.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.
Generate
import modelfun
# initialize the Modelfun Client with an API Key
mo = modelfun.Client('YOUR_API_KEY')
prompt= '''
摘要:
本文总结了十个可穿戴产品的设计原则,而这些原则,同样也是笔者认为是这个行业最吸引人的地方:1.为人们解决重复性问题;2.从人开始,而不是从机器开始;3.要引起注意,但不要刻意;4.提升用户能力,而不是取代人
答案:
'''
# generate a prediction for a prompt
prediction = mo.generate(
model_name='modelfun',
prompt=prompt)
# print the predicted text
print('prediction: {}'.format(prediction.generations[0].text))
Classify
import modelfun
from modelfun.classify import Example
# initialize the Modelfun Client with an API Key
mo = modelfun.Client('YOUR_API_KEY')
response = mo.classify(model_name='modelfun',
task_name='情感分析',
inputs=["世界充满了欺骗", "世界和平"],
examples=[Example("基本都是欺骗", "消极"), Example("基本都是惊喜", "积极")],
labels = ["消极", "积极"])
print('prediction: {}'.format(
response.classifications))
Versioning
To use the SDK with a specific API version, you can specify it when creating the Modelfun Client:
import modelfun
mo = modelfun.Client('YOUR_API_KEY', '2022-08-08')
Endpoints
| Modelfun Endpoint | Function |
|---|---|
| /generate | mo.generate() |
| /classify | mo.classify() |
Models
When you call Modelfun'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 parameter.
Responses
All of the endpoint functions will return a Modelfun object corresponding to the endpoint (e.g. for generation, it would be Generation). The responses can be found as instance variables of the object (e.g. generation would be Generation.text). Printing the Modelfun response object itself will display an organized view of the instance variables.
Metadata
Release files for modelfun 0.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 |
|---|---|---|---|---|
| modelfun-0.0.1.4.tar.gz | 7.3 kB | Without provenance | Details for modelfun-0.0.1.4.tar.gz |
Release files / modelfun-0.0.1.4.tar.gz
| Download URL | modelfun-0.0.1.4.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd238848c3d7dbeb0301e7cfc414e6f13d5a61bca34c94fbdf26e2235404bb66
|
|
BLAKE2b-256 checksum How to use checksums |
54c585e1ce1147c3fe33aafa2892a9db0258c36bb9192fd3308bd074797eedb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.12
|
Security for modelfun 0.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.