Skip to main content

SDK for byteplus rec

Project description

byteplus rec python sdk

Install the client library

pip install --upgrade byteplus-rec

Saas E-Commerce Example

from byteplus_rec.region.region import Region
from byteplus_rec.retail.retail_client import Client
from byteplus_rec.retail.retail_client_builder import ClientBuilder
from byteplus_rec_core.exception import BizException

log = logging.getLogger(__name__)

# A unique identity assigned by Bytedance.
PROJECT_ID = "***********"

# Unique id for this model.The saas model id that can be used to get rec results from predict api,
# which is need to fill in URL.
MODEL_ID = "***********"

# Required Param:
#       tenant_id
#       region
#       AK
#       SK
# Optional Param:
#       scheme
#       hosts
try:
    client: Client = ClientBuilder() \
        .account_id("***********") \
        .region(Region.SG) \
        .project_id(PROJECT_ID) \
        .auth_ak("***********") \
        .auth_sk("***********") \
        .build()
except BizException as clientE:
    log.error("fail to create byteplus rec client, msg:%s", clientE)

if __name__ == '__main__':
    client.write_users()
    client.predict()

Saas Content(Short-Video/Image/Doc) Example

from byteplus_rec.region.region import Region
from byteplus_rec.content.content_client import Client
from byteplus_rec.content.content_client_builder import ClientBuilder
from byteplus_rec_core.exception import BizException

log = logging.getLogger(__name__)

# A unique identity assigned by Bytedance.
PROJECT_ID = "***********"

# Unique id for this model.The saas model id that can be used to get rec results from predict api,
# which is need to fill in URL.
MODEL_ID = "***********"

# Required Param:
#       tenant_id
#       region
#       AK
#       SK
# Optional Param:
#       scheme
#       hosts
try:
    client: Client = ClientBuilder() \
        .account_id("***********") \
        .region(Region.SG) \
        .project_id(PROJECT_ID) \
        .auth_ak("***********") \
        .auth_sk("***********") \
        .build()
except BizException as clientE:
    log.error("fail to create byteplus rec client, msg:%s", clientE)

if __name__ == '__main__':
    client.write_users()
    client.predict()

How to run example

Take the E-commerce industry as an example:

  • clone the project.
  • install requirements.
  • add sdk root path to envs.
  • enter the example directory.
  • fill necessary parameters.
  • run main.py.
git clone https://github.com/byteplus-sdk/byteplus-sdk-python-rec.git
cd byteplus-sdk-python-rec
pip3 install -r requirements.txt
export PYTHONPATH=$PYTHONPATH:$PWD
cd byteplus_rec/retail/example
# fill in projectID, modelID, tenantID, AK, SK and other parameters.
python3 main.py

For more details

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

byteplus-rec-1.0.10.tar.gz (33.0 kB view details)

Uploaded Source

File details

Details for the file byteplus-rec-1.0.10.tar.gz.

File metadata

  • Download URL: byteplus-rec-1.0.10.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for byteplus-rec-1.0.10.tar.gz
Algorithm Hash digest
SHA256 ca8715b08213c8a8cc7d58c17504f96dd1bfb2c21edd44faac274ef807b4d3c2
MD5 535e2df0d677737c280e4224d59936c6
BLAKE2b-256 6f9304aad9fea7805d2a63d5a607cfb7468e915b09c2284b080a722c79a79396

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page