Skip to content

Latest commit

 

History

History
100 lines (71 loc) · 10 KB

File metadata and controls

100 lines (71 loc) · 10 KB

FriendliCoreServerlessToken

(serverless.token)

Overview

Available Operations

tokenization

By giving a text input, generate a tokenized output of token IDs.

Example Usage

import os

from friendli import SyncFriendli

with SyncFriendli(
    token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
    res = friendli.serverless.token.tokenization(
        model="meta-llama-3.1-8b-instruct", prompt="What is generative AI?"
    )

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
model str ✔️ Code of the model to use. See available model list. meta-llama-3.1-8b-instruct
prompt str ✔️ Input text prompt to tokenize. What is generative AI?
x_friendli_team OptionalNullable[str] ID of team to run requests as (optional parameter).
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ServerlessTokenizationSuccess

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*

detokenization

By giving a list of tokens, generate a detokenized output text string.

Example Usage

import os

from friendli import SyncFriendli

with SyncFriendli(
    token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
    res = friendli.serverless.token.detokenization(
        model="meta-llama-3.1-8b-instruct",
        tokens=[
            128000,
            3923,
            374,
            1803,
            1413,
            15592,
            30,
        ],
    )

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
model str ✔️ Code of the model to use. See available model list. meta-llama-3.1-8b-instruct
tokens List[int] ✔️ A token sequence to detokenize. [
128000,
3923,
374,
1803,
1413,
15592,
30
]
x_friendli_team OptionalNullable[str] ID of team to run requests as (optional parameter).
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ServerlessDetokenizationSuccess

Errors

Error Type Status Code Content Type
models.SDKError 4XX, 5XX */*