You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromglean.api_clientimportGlean, modelsimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
res=glean.client.chat.create(messages=[
{
"fragments": [
models.ChatMessageFragment(
text="What are the company holidays this year?",
),
],
},
], timeout_millis=30000)
# Handle responseprint(res)
Example Usage: gptAgentExample
fromglean.api_clientimportGlean, modelsimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
res=glean.client.chat.create(messages=[
{
"fragments": [
models.ChatMessageFragment(
text="Who was the first person to land on the moon?",
),
],
},
], agent_config={
"agent": models.AgentEnum.GPT,
}, timeout_millis=30000)
# Handle responseprint(res)
A list of chat messages, from most recent to least recent. At least one message must specify a USER author.
locale
Optional[str]
➖
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
Save the current interaction as a Chat for the user to access and potentially continue later.
chat_id
Optional[str]
➖
The id of the Chat that context should be retrieved from and messages added to. An empty id starts a new Chat, and the Chat is saved if saveChat is true.
Timeout in milliseconds for the request. A 408 error will be returned if handling the request takes longer.
30000
application_id
Optional[str]
➖
The ID of the application this request originates from, used to determine the configuration of underlying chat processes. This should correspond to the ID set during admin setup. If not specified, the default chat experience will be used.
agent_id
Optional[str]
➖
The ID of the Agent that should process this chat request. Only Agents with trigger set to 'User chat message' are invokable through this API. If not specified, the default chat experience will be used.
stream
Optional[bool]
➖
If set, response lines will be streamed one-by-one as they become available. Each will be a ChatResponse, formatted as JSON, and separated by a new line. If false, the entire response will be returned at once. Note that if this is set and the model being used does not support streaming, the model's response will not be streamed, but other messages from the endpoint still will be.
Deletes all saved Chats a user has had and all their contained conversational content.
Example Usage
fromglean.api_clientimportGleanimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
glean.client.chat.delete_all()
# Use the SDK ...
Parameters
Parameter
Type
Required
Description
locale
Optional[str]
➖
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
Configuration to override the default retry behavior of the client.
Errors
Error Type
Status Code
Content Type
errors.GleanError
4XX, 5XX
*/*
delete
Deletes saved Chats and all their contained conversational content.
Example Usage
fromglean.api_clientimportGleanimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
glean.client.chat.delete(ids=[])
# Use the SDK ...
Parameters
Parameter
Type
Required
Description
ids
List[str]
✔️
A non-empty list of ids of the Chats to be deleted.
locale
Optional[str]
➖
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
Raw files to be uploaded for chat in binary format.
locale
Optional[str]
➖
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
fromglean.api_clientimportGleanimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
glean.client.chat.delete_files(file_ids=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Use the SDK ...
Parameters
Parameter
Type
Required
Description
file_ids
List[str]
✔️
IDs of files to delete.
locale
Optional[str]
➖
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en.
timezone_offset
Optional[int]
➖
The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC.
fromglean.api_clientimportGlean, modelsimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
res=glean.client.chat.create_stream(messages=[
{
"fragments": [
models.ChatMessageFragment(
text="What are the company holidays this year?",
),
],
},
], timeout_millis=30000)
# Handle responseprint(res)
Example Usage: gptAgentExample
fromglean.api_clientimportGlean, modelsimportoswithGlean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) asglean:
res=glean.client.chat.create_stream(messages=[
{
"fragments": [
models.ChatMessageFragment(
text="Who was the first person to land on the moon?",
),
],
},
], agent_config={
"agent": models.AgentEnum.GPT,
}, timeout_millis=30000)
# Handle responseprint(res)
Save the current interaction as a Chat for the user to access and potentially continue later.
chat_id
Optional[str]
➖
The id of the Chat that context should be retrieved from and messages added to. An empty id starts a new Chat, and the Chat is saved if saveChat is true.
Timeout in milliseconds for the request. A 408 error will be returned if handling the request takes longer.
30000
application_id
Optional[str]
➖
The ID of the application this request originates from, used to determine the configuration of underlying chat processes. This should correspond to the ID set during admin setup. If not specified, the default chat experience will be used.
agent_id
Optional[str]
➖
The ID of the Agent that should process this chat request. Only Agents with trigger set to 'User chat message' are invokable through this API. If not specified, the default chat experience will be used.
stream
Optional[bool]
➖
If set, response lines will be streamed one-by-one as they become available. Each will be a ChatResponse, formatted as JSON, and separated by a new line. If false, the entire response will be returned at once. Note that if this is set and the model being used does not support streaming, the model's response will not be streamed, but other messages from the endpoint still will be.