(container.completions)
Generate text based on the given text prompt.
import os
from friendli import SyncFriendli
with SyncFriendli(
token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
res = friendli.container.completions.complete(
request={
"prompt": "Say this is a test!",
"stream": False,
}
)
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.ContainerCompletionsBody | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] | ➖ | An optional server URL to use. |
models.ContainerCompletionsSuccess
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |
Generate text based on the given text prompt.
import os
from friendli import SyncFriendli
with SyncFriendli(
token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
res = friendli.container.completions.stream(
request={
"prompt": "Say this is a test!",
"stream": True,
}
)
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.ContainerCompletionsStreamBody | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
server_url |
Optional[str] | ➖ | An optional server URL to use. |
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |