Skip to content

Commit 96fd98b

Browse files
authored
Update dependencies
1 parent a10443f commit 96fd98b

File tree

10 files changed

+405
-456
lines changed

10 files changed

+405
-456
lines changed

pyproject.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "uv_build"
55
[project]
66
name = "draive"
77
description = "Framework designed to simplify and accelerate the development of LLM-based applications."
8-
version = "0.95.1"
8+
version = "0.96.0"
99
readme = "README.md"
1010
maintainers = [
1111
{ name = "Kacper Kaliński", email = "[email protected]" },
@@ -24,25 +24,25 @@ classifiers = [
2424
"Topic :: Software Development :: Libraries :: Application Frameworks",
2525
]
2626
license = { file = "LICENSE" }
27-
dependencies = ["numpy~=2.3", "haiway~=0.40.2"]
27+
dependencies = ["numpy~=2.3", "haiway~=0.42"]
2828

2929
[project.urls]
3030
Homepage = "https://miquido.com"
3131
Repository = "https://github.com/miquido/draive.git"
3232

3333
[project.optional-dependencies]
34-
cohere = ["cohere~=5.18"]
35-
cohere_bedrock = ["cohere~=5.18", "boto3~=1.40"]
36-
openai = ["openai~=2.8"]
37-
openai_realtime = ["openai[realtime]~=2.8"]
38-
anthropic = ["anthropic~=0.72"]
39-
anthropic_bedrock = ["anthropic[bedrock]~=0.72"]
40-
mistral = ["mistralai~=1.9"]
34+
cohere = ["cohere~=5.20"]
35+
cohere_bedrock = ["cohere~=5.20", "boto3~=1.41"]
36+
openai = ["openai~=2.9"]
37+
openai_realtime = ["openai[realtime]~=2.9"]
38+
anthropic = ["anthropic~=0.75"]
39+
anthropic_bedrock = ["anthropic[bedrock]~=0.75"]
40+
mistral = ["mistralai~=1.10"]
4141
gemini = ["google-genai~=1.50", "google-api-core"]
42-
ollama = ["ollama~=0.6.0"]
43-
bedrock = ["boto3~=1.40"]
44-
aws = ["boto3~=1.40"]
45-
vllm = ["openai~=2.8"]
42+
ollama = ["ollama~=0.6.1"]
43+
bedrock = ["boto3~=1.41"]
44+
aws = ["boto3~=1.41"]
45+
vllm = ["openai~=2.9"]
4646
mcp = ["mcp~=1.21"]
4747
opentelemetry = [
4848
"haiway[opentelemetry]",

src/draive/__init__.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
ConfigurationInvalid,
1313
ConfigurationMissing,
1414
ConfigurationRepository,
15-
ContextPreset,
15+
ContextIdentifier,
16+
ContextMissing,
17+
ContextPresets,
18+
ContextStateMissing,
1619
Default,
1720
DefaultValue,
1821
Description,
1922
Disposable,
20-
Disposables,
21-
EventSubscription,
2223
File,
2324
FileAccess,
2425
HTTPClient,
@@ -34,17 +35,11 @@
3435
MetaTags,
3536
MetaValues,
3637
Missing,
37-
MissingContext,
38-
MissingState,
3938
Observability,
4039
ObservabilityAttribute,
41-
ObservabilityContext,
4240
ObservabilityLevel,
43-
ScopeContext,
44-
ScopeIdentifier,
4541
Specification,
4642
State,
47-
StateContext,
4843
TypeSpecification,
4944
Validating,
5045
ValidationError,
@@ -227,7 +222,10 @@
227222
"ConfigurationInvalid",
228223
"ConfigurationMissing",
229224
"ConfigurationRepository",
230-
"ContextPreset",
225+
"ContextIdentifier",
226+
"ContextMissing",
227+
"ContextPresets",
228+
"ContextStateMissing",
231229
"Conversation",
232230
"ConversationEvent",
233231
"ConversationInputChunk",
@@ -238,9 +236,7 @@
238236
"DefaultValue",
239237
"Description",
240238
"Disposable",
241-
"Disposables",
242239
"Embedded",
243-
"EventSubscription",
244240
"File",
245241
"FileAccess",
246242
"FunctionTool",
@@ -275,8 +271,6 @@
275271
"MetaValues",
276272
"MimeType",
277273
"Missing",
278-
"MissingContext",
279-
"MissingState",
280274
"ModelContext",
281275
"ModelContextElement",
282276
"ModelException",
@@ -320,7 +314,6 @@
320314
"MultimodalTag",
321315
"Observability",
322316
"ObservabilityAttribute",
323-
"ObservabilityContext",
324317
"ObservabilityLevel",
325318
"RealtimeConversation",
326319
"RealtimeConversationSession",
@@ -339,14 +332,11 @@
339332
"ResourceTemplate",
340333
"ResourceUploading",
341334
"ResourcesRepository",
342-
"ScopeContext",
343-
"ScopeIdentifier",
344335
"Specification",
345336
"Stage",
346337
"StageException",
347338
"StageState",
348339
"State",
349-
"StateContext",
350340
"Template",
351341
"TemplateDeclaration",
352342
"TemplateMissing",

src/draive/mcp/server.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,26 @@ def __init__(
3636
name: str,
3737
version: str | None = None,
3838
instructions: str | None = None,
39-
resources: Iterable[ResourceTemplate[Any] | Resource] | None = None,
40-
tools: Toolbox | Iterable[Tool] | None = None,
41-
disposables: Disposables | Collection[Disposable] | None = None,
39+
resources: Iterable[ResourceTemplate[Any] | Resource] = (),
40+
tools: Toolbox | Iterable[Tool] = (),
41+
disposables: Collection[Disposable] = (),
4242
) -> None:
43-
disposable: Disposables
44-
if disposables is None:
45-
disposable = Disposables(())
46-
47-
elif isinstance(disposables, Disposables):
48-
disposable = disposables
49-
50-
else:
51-
disposable = Disposables(disposables)
52-
5343
@asynccontextmanager
5444
async def lifspan(server: Server) -> AsyncGenerator[Iterable[State]]:
55-
state: Iterable[State] = await disposable.prepare()
56-
try:
45+
async with Disposables(disposables) as state:
5746
yield state
5847

59-
finally:
60-
await disposable.dispose()
61-
6248
self._server = Server[Iterable[State]](
6349
name=name,
6450
version=version,
6551
instructions=instructions,
6652
lifespan=lifspan,
6753
)
6854

69-
if resources is not None:
55+
if resources:
7056
self._expose_resources(resources)
7157

72-
if tools is not None:
58+
if tools:
7359
self._expose_tools(tools)
7460

7561
async def run_stdio(

src/draive/resources/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def http_resource_fetching(
4242
await response.body(),
4343
mime_type=response.headers.get(
4444
"Content-Type",
45-
default="application/octet-stream",
45+
"application/octet-stream",
4646
),
4747
)
4848

src/draive/stages/stage.py

Lines changed: 21 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ def with_ctx(
14671467
self,
14681468
/,
14691469
*,
1470-
disposables: Disposables | Collection[Disposable],
1470+
disposables: Collection[Disposable],
14711471
) -> Self: ...
14721472

14731473
@overload
@@ -1478,12 +1478,12 @@ def with_ctx(
14781478
*state: State,
14791479
) -> Self: ...
14801480

1481-
def with_ctx( # noqa: C901
1481+
def with_ctx(
14821482
self,
14831483
state: State | None = None,
14841484
/,
14851485
*states: State,
1486-
disposables: Disposables | Collection[Disposable] | None = None,
1486+
disposables: Collection[Disposable] = (),
14871487
) -> Self:
14881488
"""
14891489
Apply the specified state context to this stage.
@@ -1502,7 +1502,7 @@ def with_ctx( # noqa: C901
15021502
Optional additional `State` objects to include in the state context.
15031503
Only applicable when `state_context` is a `State`.
15041504
1505-
disposables: Disposables | Collection[Disposable] | None
1505+
disposables: Collection[Disposable]
15061506
Optional Disposables which will be used for execution of this stage.
15071507
State produced by disposables will be used within the context state.
15081508
@@ -1513,47 +1513,17 @@ def with_ctx( # noqa: C901
15131513
"""
15141514
execution: StageExecution = self._execution
15151515

1516-
resolved_disposables: Disposables | None
1517-
if disposables is None:
1518-
resolved_disposables = None
1519-
1520-
elif isinstance(disposables, Disposables):
1521-
resolved_disposables = disposables
1522-
1523-
else:
1524-
resolved_disposables = Disposables(disposables)
1525-
1526-
match (state, resolved_disposables):
1527-
case (None, None):
1528-
assert not states # nosec: B101
1529-
return self # nothing to change...
1530-
1531-
case (None, ctx_disposables):
1532-
assert not states # nosec: B101
1516+
if ctx_state := state:
1517+
if disposables:
15331518

15341519
async def stage(
15351520
*,
15361521
state: StageState,
15371522
) -> StageState:
1538-
result_state: StageState
1539-
try:
1540-
with ctx.updated(*await ctx_disposables.prepare()):
1541-
result_state = await execution(state=state)
1542-
1543-
except BaseException as exc:
1544-
await ctx_disposables.dispose(
1545-
exc_type=type(exc),
1546-
exc_val=exc,
1547-
exc_tb=exc.__traceback__,
1548-
)
1549-
raise exc
1550-
1551-
else:
1552-
await ctx_disposables.dispose()
1553-
1554-
return result_state
1555-
1556-
case (ctx_state, None):
1523+
async with Disposables(disposables) as disposable_state:
1524+
with ctx.updated(*disposable_state, ctx_state, *states):
1525+
return await execution(state=state)
1526+
else:
15571527

15581528
async def stage(
15591529
*,
@@ -1562,30 +1532,18 @@ async def stage(
15621532
with ctx.updated(ctx_state, *states):
15631533
return await execution(state=state)
15641534

1565-
case (ctx_state, ctx_disposables):
1566-
1567-
async def stage(
1568-
*,
1569-
state: StageState,
1570-
) -> StageState:
1571-
disposables_state: Iterable[State] = await ctx_disposables.prepare()
1572-
result_state: StageState
1573-
try:
1574-
with ctx.updated(ctx_state, *disposables_state, *states):
1575-
result_state = await execution(state=state)
1576-
1577-
except BaseException as exc:
1578-
await ctx_disposables.dispose(
1579-
exc_type=type(exc),
1580-
exc_val=exc,
1581-
exc_tb=exc.__traceback__,
1582-
)
1583-
raise exc
1584-
1585-
else:
1586-
await ctx_disposables.dispose()
1535+
elif disposables:
1536+
assert not states # nosec: B101
15871537

1588-
return result_state
1538+
async def stage(
1539+
*,
1540+
state: StageState,
1541+
) -> StageState:
1542+
async with ctx.disposables(*disposables):
1543+
return await execution(state=state)
1544+
else:
1545+
assert not states # nosec: B101
1546+
return self # nothing to change...
15891547

15901548
return self.__class__(
15911549
stage,

src/draive/stages/types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections.abc import Mapping, Sequence
22
from typing import Any, Literal, Protocol, Self, cast, final, overload, runtime_checkable
33

4-
from haiway import Meta, MetaValues, MissingState, State
4+
from haiway import ContextStateMissing, Meta, MetaValues, State
55

66
from draive.models import ModelContext, ModelOutput
77
from draive.multimodal import Multimodal, MultimodalContent
@@ -179,7 +179,7 @@ def get[StateType: DataModel | State](
179179
default : StateType | None
180180
Default value to return if the state is not found.
181181
required : bool
182-
If True, raises MissingState when the state is not found.
182+
If True, raises ContextStateMissing when the state is not found.
183183
184184
Returns
185185
-------
@@ -188,7 +188,7 @@ def get[StateType: DataModel | State](
188188
189189
Raises
190190
------
191-
MissingState
191+
ContextStateMissing
192192
When required=True and the state is not found.
193193
"""
194194

@@ -200,7 +200,7 @@ def get[StateType: DataModel | State](
200200
return default
201201

202202
elif required:
203-
raise MissingState(f"{state.__qualname__} is not available within stage state")
203+
raise ContextStateMissing(f"{state.__qualname__} is not available within stage state")
204204

205205
else:
206206
return None

0 commit comments

Comments
 (0)