Skip to content

Commit 68a37d9

Browse files
committed
## Python SDK Changes:
* `glean.client.chat.create()`: `response.chat` **Added**
1 parent 5608e34 commit 68a37d9

14 files changed

Lines changed: 126 additions & 57 deletions

File tree

.speakeasy/gen.lock

Lines changed: 28 additions & 26 deletions
Large diffs are not rendered by default.

.speakeasy/gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ generation:
3434
generateNewTests: true
3535
skipResponseBodyAssertions: true
3636
python:
37-
version: 0.12.10
37+
version: 0.12.11
3838
additionalDependencies:
3939
dev: {}
4040
main: {}

.speakeasy/glean-merged-spec.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ openapi: 3.0.0
22
info:
33
version: 0.9.0
44
title: Glean API
5-
x-source-commit-sha: a5baf32ff20e181a9adf12f9b9eba1c2421e5024
5+
x-source-commit-sha: 6db2345944be553d6789c316b2758d1902adf02c
66
description: |
77
# Introduction
88
In addition to the data sources that Glean has built-in support for, Glean also provides a REST API that enables customers to put arbitrary content in the search index. This is useful, for example, for doing permissions-aware search over content in internal tools that reside on-prem as well as for searching over applications that Glean does not currently support first class. In addition these APIs allow the customer to push organization data (people info, organization structure etc) into Glean.
@@ -22,7 +22,7 @@ info:
2222
These API clients provide type-safe, idiomatic interfaces for working with Glean IndexingAPIs in your language of choice.
2323
x-logo:
2424
url: https://app.glean.com/images/glean-text2.svg
25-
x-open-api-commit-sha: 238bce820eef8f0f78d4793d3424d4e78944d066
25+
x-open-api-commit-sha: 51fb401eac030ac7b4b3dc748ac57407be45450c
2626
x-speakeasy-name: 'Glean API'
2727
servers:
2828
- url: https://{instance}-be.glean.com
@@ -6582,6 +6582,7 @@ components:
65826582
introduced: "2026-02-05"
65836583
message: Use 'text' field instead
65846584
removal: "2026-10-15"
6585+
x-includeEmpty: true
65856586
x-speakeasy-deprecation-message: "Deprecated on 2026-02-05, removal scheduled for 2026-10-15: Use 'text' field instead"
65866587
example:
65876588
snippet: snippet
@@ -8297,6 +8298,8 @@ components:
82978298
chatId:
82988299
type: string
82998300
description: The id of the associated Chat the messages belong to, if one exists.
8301+
chat:
8302+
$ref: "#/components/schemas/ChatMetadata"
83008303
followUpPrompts:
83018304
type: array
83028305
items:

.speakeasy/workflow.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
speakeasyVersion: 1.751.0
1+
speakeasyVersion: 1.752.0
22
sources:
33
Glean API:
44
sourceNamespace: glean-api-specs
5-
sourceRevisionDigest: sha256:f166c61c7e7a52f62d5ddcc80f0e1247867cfa9a89d6bdf2679daca84d0efadc
6-
sourceBlobDigest: sha256:a5efacbcf3c78ffd7268b357723e4892a115562dd5392fbcd6ab6141c014516f
5+
sourceRevisionDigest: sha256:44e27e7fb16d7be125cb2205f2d9b62646f50d106bc316f20e4b77beda183e9f
6+
sourceBlobDigest: sha256:1f7b9c41f3b5790254d7d23c37b259fe78bbd8922b8374e84b09a714d805650c
77
tags:
88
- latest
99
Glean Client API:
@@ -16,10 +16,10 @@ targets:
1616
glean:
1717
source: Glean API
1818
sourceNamespace: glean-api-specs
19-
sourceRevisionDigest: sha256:f166c61c7e7a52f62d5ddcc80f0e1247867cfa9a89d6bdf2679daca84d0efadc
20-
sourceBlobDigest: sha256:a5efacbcf3c78ffd7268b357723e4892a115562dd5392fbcd6ab6141c014516f
19+
sourceRevisionDigest: sha256:44e27e7fb16d7be125cb2205f2d9b62646f50d106bc316f20e4b77beda183e9f
20+
sourceBlobDigest: sha256:1f7b9c41f3b5790254d7d23c37b259fe78bbd8922b8374e84b09a714d805650c
2121
codeSamplesNamespace: glean-api-specs-python-code-samples
22-
codeSamplesRevisionDigest: sha256:dac0cc25e8448625efa55da8fa7c5d7da718e204f3c52763fe7bcce62d679838
22+
codeSamplesRevisionDigest: sha256:f4615b6dd347d241e08a8623565822a3000c595656b93a0b0b374f359e7693b6
2323
workflow:
2424
workflowVersion: 1.0.0
2525
speakeasyVersion: latest

RELEASES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,4 +608,14 @@ Based on:
608608
### Generated
609609
- [python v0.12.10] .
610610
### Releases
611-
- [PyPI v0.12.10] https://pypi.org/project/glean-api-client/0.12.10 - .
611+
- [PyPI v0.12.10] https://pypi.org/project/glean-api-client/0.12.10 - .
612+
613+
## 2026-03-12 21:16:34
614+
### Changes
615+
Based on:
616+
- OpenAPI Doc
617+
- Speakeasy CLI 1.752.0 (2.859.2) https://github.com/speakeasy-api/speakeasy
618+
### Generated
619+
- [python v0.12.11] .
620+
### Releases
621+
- [PyPI v0.12.11] https://pypi.org/project/glean-api-client/0.12.11 - .

docs/models/chatresponse.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ A single response from the /chat backend.
55

66
## Fields
77

8-
| Field | Type | Required | Description | Example |
9-
| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- |
10-
| `messages` | List[[models.ChatMessage](../models/chatmessage.md)] | :heavy_minus_sign: | N/A | |
11-
| `chat_id` | *Optional[str]* | :heavy_minus_sign: | The id of the associated Chat the messages belong to, if one exists. | |
12-
| `follow_up_prompts` | List[*str*] | :heavy_minus_sign: | Follow-up prompts for the user to potentially use | |
13-
| `backend_time_millis` | *Optional[int]* | :heavy_minus_sign: | Time in milliseconds the backend took to respond to the request. | 1100 |
14-
| `chat_session_tracking_token` | *Optional[str]* | :heavy_minus_sign: | A token that is used to track the session. | |
8+
| Field | Type | Required | Description | Example |
9+
| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
10+
| `messages` | List[[models.ChatMessage](../models/chatmessage.md)] | :heavy_minus_sign: | N/A | |
11+
| `chat_id` | *Optional[str]* | :heavy_minus_sign: | The id of the associated Chat the messages belong to, if one exists. | |
12+
| `chat` | [Optional[models.ChatMetadata]](../models/chatmetadata.md) | :heavy_minus_sign: | Metadata of a Chat a user had with Glean Assistant. This contains no actual conversational content. | |
13+
| `follow_up_prompts` | List[*str*] | :heavy_minus_sign: | Follow-up prompts for the user to potentially use | |
14+
| `backend_time_millis` | *Optional[int]* | :heavy_minus_sign: | Time in milliseconds the backend took to respond to the request. | 1100 |
15+
| `chat_session_tracking_token` | *Optional[str]* | :heavy_minus_sign: | A token that is used to track the session. | |

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[project]
33
name = "glean-api-client"
4-
version = "0.12.10"
4+
version = "0.12.11"
55
description = "Python Client SDK Generated by Speakeasy."
66
authors = [{ name = "Glean Technologies, Inc." },]
77
readme = "README-PYPI.md"

src/glean/api_client/_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import importlib.metadata
44

55
__title__: str = "glean-api-client"
6-
__version__: str = "0.12.10"
6+
__version__: str = "0.12.11"
77
__openapi_doc_version__: str = "0.9.0"
8-
__gen_version__: str = "2.858.2"
9-
__user_agent__: str = "speakeasy-sdk/python 0.12.10 2.858.2 0.9.0 glean-api-client"
8+
__gen_version__: str = "2.859.2"
9+
__user_agent__: str = "speakeasy-sdk/python 0.12.11 2.859.2 0.9.0 glean-api-client"
1010

1111
try:
1212
if __package__ is not None:

src/glean/api_client/models/chatresponse.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44
from .chatmessage import ChatMessage, ChatMessageTypedDict
5+
from .chatmetadata import ChatMetadata, ChatMetadataTypedDict
56
from glean.api_client.types import BaseModel, UNSET_SENTINEL
67
import pydantic
78
from pydantic import model_serializer
@@ -15,6 +16,8 @@ class ChatResponseTypedDict(TypedDict):
1516
messages: NotRequired[List[ChatMessageTypedDict]]
1617
chat_id: NotRequired[str]
1718
r"""The id of the associated Chat the messages belong to, if one exists."""
19+
chat: NotRequired[ChatMetadataTypedDict]
20+
r"""Metadata of a Chat a user had with Glean Assistant. This contains no actual conversational content."""
1821
follow_up_prompts: NotRequired[List[str]]
1922
r"""Follow-up prompts for the user to potentially use"""
2023
backend_time_millis: NotRequired[int]
@@ -31,6 +34,9 @@ class ChatResponse(BaseModel):
3134
chat_id: Annotated[Optional[str], pydantic.Field(alias="chatId")] = None
3235
r"""The id of the associated Chat the messages belong to, if one exists."""
3336

37+
chat: Optional[ChatMetadata] = None
38+
r"""Metadata of a Chat a user had with Glean Assistant. This contains no actual conversational content."""
39+
3440
follow_up_prompts: Annotated[
3541
Optional[List[str]], pydantic.Field(alias="followUpPrompts")
3642
] = None
@@ -52,6 +58,7 @@ def serialize_model(self, handler):
5258
[
5359
"messages",
5460
"chatId",
61+
"chat",
5562
"followUpPrompts",
5663
"backendTimeMillis",
5764
"chatSessionTrackingToken",

src/glean/api_client/utils/eventstreaming.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ def __init__(
3232
decoder: Callable[[str], T],
3333
sentinel: Optional[str] = None,
3434
client_ref: Optional[object] = None,
35+
data_required: bool = True,
3536
):
3637
self.response = response
37-
self.generator = stream_events(response, decoder, sentinel)
38+
self.generator = stream_events(
39+
response, decoder, sentinel, data_required=data_required
40+
)
3841
self.client_ref = client_ref
3942
self._closed = False
4043

@@ -68,9 +71,12 @@ def __init__(
6871
decoder: Callable[[str], T],
6972
sentinel: Optional[str] = None,
7073
client_ref: Optional[object] = None,
74+
data_required: bool = True,
7175
):
7276
self.response = response
73-
self.generator = stream_events_async(response, decoder, sentinel)
77+
self.generator = stream_events_async(
78+
response, decoder, sentinel, data_required=data_required
79+
)
7480
self.client_ref = client_ref
7581
self._closed = False
7682

@@ -116,6 +122,7 @@ async def stream_events_async(
116122
response: httpx.Response,
117123
decoder: Callable[[str], T],
118124
sentinel: Optional[str] = None,
125+
data_required: bool = True,
119126
) -> AsyncGenerator[T, None]:
120127
buffer = bytearray()
121128
position = 0
@@ -138,7 +145,11 @@ async def stream_events_async(
138145
block = buffer[position:i]
139146
position = i + len(seq)
140147
event, discard, event_id = _parse_event(
141-
raw=block, decoder=decoder, sentinel=sentinel, event_id=event_id
148+
raw=block,
149+
decoder=decoder,
150+
sentinel=sentinel,
151+
event_id=event_id,
152+
data_required=data_required,
142153
)
143154
if event is not None:
144155
yield event
@@ -151,7 +162,11 @@ async def stream_events_async(
151162
position = 0
152163

153164
event, discard, _ = _parse_event(
154-
raw=buffer, decoder=decoder, sentinel=sentinel, event_id=event_id
165+
raw=buffer,
166+
decoder=decoder,
167+
sentinel=sentinel,
168+
event_id=event_id,
169+
data_required=data_required,
155170
)
156171
if event is not None:
157172
yield event
@@ -161,6 +176,7 @@ def stream_events(
161176
response: httpx.Response,
162177
decoder: Callable[[str], T],
163178
sentinel: Optional[str] = None,
179+
data_required: bool = True,
164180
) -> Generator[T, None, None]:
165181
buffer = bytearray()
166182
position = 0
@@ -183,7 +199,11 @@ def stream_events(
183199
block = buffer[position:i]
184200
position = i + len(seq)
185201
event, discard, event_id = _parse_event(
186-
raw=block, decoder=decoder, sentinel=sentinel, event_id=event_id
202+
raw=block,
203+
decoder=decoder,
204+
sentinel=sentinel,
205+
event_id=event_id,
206+
data_required=data_required,
187207
)
188208
if event is not None:
189209
yield event
@@ -196,7 +216,11 @@ def stream_events(
196216
position = 0
197217

198218
event, discard, _ = _parse_event(
199-
raw=buffer, decoder=decoder, sentinel=sentinel, event_id=event_id
219+
raw=buffer,
220+
decoder=decoder,
221+
sentinel=sentinel,
222+
event_id=event_id,
223+
data_required=data_required,
200224
)
201225
if event is not None:
202226
yield event
@@ -208,6 +232,7 @@ def _parse_event(
208232
decoder: Callable[[str], T],
209233
sentinel: Optional[str] = None,
210234
event_id: Optional[str] = None,
235+
data_required: bool = True,
211236
) -> Tuple[Optional[T], bool, Optional[str]]:
212237
block = raw.decode()
213238
lines = re.split(r"\r?\n|\r", block)
@@ -250,6 +275,10 @@ def _parse_event(
250275
if sentinel and data == f"{sentinel}\n":
251276
return None, True, event_id
252277

278+
# Skip data-less events when data is required
279+
if not data and publish and data_required:
280+
return None, False, event_id
281+
253282
if data:
254283
data = data[:-1]
255284
try:

0 commit comments

Comments
 (0)