forked from gleanwork/api-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_example.py
More file actions
30 lines (26 loc) · 753 Bytes
/
Copy pathchat_example.py
File metadata and controls
30 lines (26 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# To run the example:
# poetry install
# poetry run python examples/ask_example.py
from glean.api_client import Glean, errors, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
domain="customerName"
) as glean:
try:
res = glean.client.chat.start(messages=[
{
"fragments": [
models.ChatMessageFragment(
text="What are the company holidays this year?",
),
],
},
], timeout_millis=30000)
# Handle response
print(res)
except errors.GleanError as e:
print(e.message)
print(e.status_code)
print(e.raw_response)
print(e.body)