Skip to content

Commit 5a53f31

Browse files
committed
Release 0.7.0b1
1 parent 1a591e3 commit 5a53f31

File tree

5 files changed

+183
-2
lines changed

5 files changed

+183
-2
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@ except ApiError as e:
6868
print(e.body)
6969
```
7070

71+
## Streaming
72+
73+
The SDK supports streaming responses, as well, the response will be a generator that you can loop over.
74+
75+
```python
76+
from letta import Letta, MessageCreate
77+
78+
client = Letta(
79+
token="YOUR_TOKEN",
80+
)
81+
response = client.agents.stream_message(
82+
agent_id="agent_id",
83+
messages=[
84+
MessageCreate(
85+
role="user",
86+
text="text",
87+
)
88+
],
89+
)
90+
for chunk in response:
91+
yield chunk
92+
```
93+
7194
## Advanced
7295

7396
### Retries

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "letta"
3-
version = "0.7.0b0"
3+
version = "0.7.0b1"
44
description = ""
55
readme = "README.md"
66
authors = []

reference.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,6 +3836,118 @@ client.agents.update_message(
38363836
</dl>
38373837

38383838

3839+
</dd>
3840+
</dl>
3841+
</details>
3842+
3843+
<details><summary><code>client.agents.<a href="src/letta/agents/client.py">stream_message</a>(...)</code></summary>
3844+
<dl>
3845+
<dd>
3846+
3847+
#### 📝 Description
3848+
3849+
<dl>
3850+
<dd>
3851+
3852+
<dl>
3853+
<dd>
3854+
3855+
Process a user message and return the agent's response.
3856+
This endpoint accepts a message from a user and processes it through the agent.
3857+
It will stream the steps of the response always, and stream the tokens if 'stream_tokens' is set to True.
3858+
</dd>
3859+
</dl>
3860+
</dd>
3861+
</dl>
3862+
3863+
#### 🔌 Usage
3864+
3865+
<dl>
3866+
<dd>
3867+
3868+
<dl>
3869+
<dd>
3870+
3871+
```python
3872+
from letta import Letta, MessageCreate
3873+
3874+
client = Letta(
3875+
token="YOUR_TOKEN",
3876+
)
3877+
response = client.agents.stream_message(
3878+
agent_id="agent_id",
3879+
messages=[
3880+
MessageCreate(
3881+
role="user",
3882+
text="text",
3883+
)
3884+
],
3885+
)
3886+
for chunk in response:
3887+
yield chunk
3888+
3889+
```
3890+
</dd>
3891+
</dl>
3892+
</dd>
3893+
</dl>
3894+
3895+
#### ⚙️ Parameters
3896+
3897+
<dl>
3898+
<dd>
3899+
3900+
<dl>
3901+
<dd>
3902+
3903+
**agent_id:** `str`
3904+
3905+
</dd>
3906+
</dl>
3907+
3908+
<dl>
3909+
<dd>
3910+
3911+
**messages:** `LettaStreamingRequestMessages` — The messages to be sent to the agent.
3912+
3913+
</dd>
3914+
</dl>
3915+
3916+
<dl>
3917+
<dd>
3918+
3919+
**assistant_message_tool_name:** `typing.Optional[str]` — The name of the designated message tool.
3920+
3921+
</dd>
3922+
</dl>
3923+
3924+
<dl>
3925+
<dd>
3926+
3927+
**assistant_message_tool_kwarg:** `typing.Optional[str]` — The name of the message argument in the designated message tool.
3928+
3929+
</dd>
3930+
</dl>
3931+
3932+
<dl>
3933+
<dd>
3934+
3935+
**stream_tokens:** `typing.Optional[bool]` — Flag to determine if individual tokens should be streamed. Set to True for token streaming (requires stream_steps = True).
3936+
3937+
</dd>
3938+
</dl>
3939+
3940+
<dl>
3941+
<dd>
3942+
3943+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
3944+
3945+
</dd>
3946+
</dl>
3947+
</dd>
3948+
</dl>
3949+
3950+
38393951
</dd>
38403952
</dl>
38413953
</details>

src/letta/agents/client.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,25 @@ def stream_message(
18881888
------
18891889
typing.Iterator[LettaStreamingResponse]
18901890
Successful response
1891+
1892+
Examples
1893+
--------
1894+
from letta import Letta, MessageCreate
1895+
1896+
client = Letta(
1897+
token="YOUR_TOKEN",
1898+
)
1899+
response = client.agents.stream_message(
1900+
agent_id="agent_id",
1901+
messages=[
1902+
MessageCreate(
1903+
role="user",
1904+
text="text",
1905+
)
1906+
],
1907+
)
1908+
for chunk in response:
1909+
yield chunk
18911910
"""
18921911
with self._client_wrapper.httpx_client.stream(
18931912
f"v1/agents/{jsonable_encoder(agent_id)}/messages/stream",
@@ -4165,6 +4184,33 @@ async def stream_message(
41654184
------
41664185
typing.AsyncIterator[LettaStreamingResponse]
41674186
Successful response
4187+
4188+
Examples
4189+
--------
4190+
import asyncio
4191+
4192+
from letta import AsyncLetta, MessageCreate
4193+
4194+
client = AsyncLetta(
4195+
token="YOUR_TOKEN",
4196+
)
4197+
4198+
4199+
async def main() -> None:
4200+
response = await client.agents.stream_message(
4201+
agent_id="agent_id",
4202+
messages=[
4203+
MessageCreate(
4204+
role="user",
4205+
text="text",
4206+
)
4207+
],
4208+
)
4209+
async for chunk in response:
4210+
yield chunk
4211+
4212+
4213+
asyncio.run(main())
41684214
"""
41694215
async with self._client_wrapper.httpx_client.stream(
41704216
f"v1/agents/{jsonable_encoder(agent_id)}/messages/stream",

src/letta/core/client_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def get_headers(self) -> typing.Dict[str, str]:
2222
headers: typing.Dict[str, str] = {
2323
"X-Fern-Language": "Python",
2424
"X-Fern-SDK-Name": "letta",
25-
"X-Fern-SDK-Version": "0.7.0b0",
25+
"X-Fern-SDK-Version": "0.7.0b1",
2626
}
2727
headers["Authorization"] = f"Bearer {self._get_token()}"
2828
return headers

0 commit comments

Comments
 (0)