Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 5.2 KB

File metadata and controls

53 lines (34 loc) · 5.2 KB

Chat

Overview

Available Operations

  • create - Create a chat response

create

Run an assistant turn. Set stream to true to receive server-sent events; otherwise the response is a typed JSON response object.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.chat.create(input="<value>", stream=False, store=True)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
input models.Input ✔️ Either a plain string (single user turn) or a chronological array of user/assistant messages. The final array message must be user.
stream Optional[bool] When true, respond with text/event-stream. When false or omitted, respond with application/json.
store Optional[bool] When true (default), persist the interaction and return a conversation_id. When false, run ephemerally with no persistence.
conversation_id Optional[str] Continue an existing stored conversation. Incompatible with message-array input and with store: false.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformChatCreateResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 413, 422, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*