Skip to content

Commit 433a996

Browse files
feat(api): updating post /v1/files to have correct multipart/form-data
1 parent f10ead0 commit 433a996

19 files changed

+335
-284
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 105
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-adcfaad1990d45e42b20e200a9ecc35ee32df5692bd9cd18ae898b0b7728c919.yml
3-
openapi_spec_hash: 4f532287bafe5da0578a1c1a5e31c952
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-d7bea816190382a93511491e33d1f37f707620926ab133ae8ce0883d763df741.yml
3+
openapi_spec_hash: f73b3af77108625edae3f25972b9e665
44
config_hash: 5b643c97c83a497d7d346253f1e175f3

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ client = LlamaStackClient()
146146

147147
client.files.create(
148148
file=Path("/path/to/file"),
149+
purpose="assistants",
149150
)
150151
```
151152

api.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ from llama_stack_client.types import (
55
AgentConfig,
66
ChatCompletionResponse,
77
CompletionMessage,
8-
ContentDelta,
98
Document,
109
InterleavedContent,
1110
InterleavedContentItem,
1211
Message,
1312
Metric,
1413
ParamType,
1514
QueryConfig,
16-
QueryGeneratorConfig,
1715
QueryResult,
1816
ResponseFormat,
1917
SafetyViolation,
@@ -163,12 +161,7 @@ Methods:
163161
Types:
164162

165163
```python
166-
from llama_stack_client.types.agents import (
167-
AgentTurnResponseStreamChunk,
168-
Turn,
169-
TurnResponseEvent,
170-
TurnResponseEventPayload,
171-
)
164+
from llama_stack_client.types.agents import AgentTurnResponseStreamChunk, Turn, TurnResponseEvent
172165
```
173166

174167
Methods:
@@ -205,7 +198,7 @@ Methods:
205198
Types:
206199

207200
```python
208-
from llama_stack_client.types import BenchmarkConfig, EvalCandidate, EvaluateResponse, Job
201+
from llama_stack_client.types import BenchmarkConfig, EvaluateResponse, Job
209202
```
210203

211204
Methods:

src/llama_stack_client/resources/files.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ def create(
5050
self,
5151
*,
5252
file: FileTypes,
53+
purpose: Literal["assistants", "batch"],
54+
expires_after: file_create_params.ExpiresAfter | Omit = omit,
5355
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5456
# The extra values given here take precedence over values defined on the client or passed to this method.
5557
extra_headers: Headers | None = None,
@@ -67,6 +69,14 @@ def create(
6769
- expires_after: Optional form values describing expiration for the file.
6870
6971
Args:
72+
purpose: Valid purpose values for OpenAI Files API.
73+
74+
expires_after:
75+
Control expiration of uploaded files. Params:
76+
77+
- anchor, must be "created_at"
78+
- seconds, must be int between 3600 and 2592000 (1 hour to 30 days)
79+
7080
extra_headers: Send extra headers
7181
7282
extra_query: Add additional query parameters to the request
@@ -75,7 +85,13 @@ def create(
7585
7686
timeout: Override the client-level default timeout for this request, in seconds
7787
"""
78-
body = deepcopy_minimal({"file": file})
88+
body = deepcopy_minimal(
89+
{
90+
"file": file,
91+
"purpose": purpose,
92+
"expires_after": expires_after,
93+
}
94+
)
7995
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
8096
# It should be noted that the actual Content-Type header that will be
8197
# sent to the server will contain a `boundary` parameter, e.g.
@@ -275,6 +291,8 @@ async def create(
275291
self,
276292
*,
277293
file: FileTypes,
294+
purpose: Literal["assistants", "batch"],
295+
expires_after: file_create_params.ExpiresAfter | Omit = omit,
278296
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
279297
# The extra values given here take precedence over values defined on the client or passed to this method.
280298
extra_headers: Headers | None = None,
@@ -292,6 +310,14 @@ async def create(
292310
- expires_after: Optional form values describing expiration for the file.
293311
294312
Args:
313+
purpose: Valid purpose values for OpenAI Files API.
314+
315+
expires_after:
316+
Control expiration of uploaded files. Params:
317+
318+
- anchor, must be "created_at"
319+
- seconds, must be int between 3600 and 2592000 (1 hour to 30 days)
320+
295321
extra_headers: Send extra headers
296322
297323
extra_query: Add additional query parameters to the request
@@ -300,7 +326,13 @@ async def create(
300326
301327
timeout: Override the client-level default timeout for this request, in seconds
302328
"""
303-
body = deepcopy_minimal({"file": file})
329+
body = deepcopy_minimal(
330+
{
331+
"file": file,
332+
"purpose": purpose,
333+
"expires_after": expires_after,
334+
}
335+
)
304336
files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
305337
# It should be noted that the actual Content-Type header that will be
306338
# sent to the server will contain a `boundary` parameter, e.g.

src/llama_stack_client/types/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
QueryConfig as QueryConfig,
1818
QueryResult as QueryResult,
1919
UserMessage as UserMessage,
20-
ContentDelta as ContentDelta,
2120
ScoringResult as ScoringResult,
2221
SystemMessage as SystemMessage,
2322
ResponseFormat as ResponseFormat,
@@ -27,7 +26,6 @@
2726
InterleavedContent as InterleavedContent,
2827
ToolParamDefinition as ToolParamDefinition,
2928
ToolResponseMessage as ToolResponseMessage,
30-
QueryGeneratorConfig as QueryGeneratorConfig,
3129
ChatCompletionResponse as ChatCompletionResponse,
3230
InterleavedContentItem as InterleavedContentItem,
3331
)
@@ -67,7 +65,6 @@
6765
from .tool_execution_step import ToolExecutionStep as ToolExecutionStep
6866
from .tool_response_param import ToolResponseParam as ToolResponseParam
6967
from .delete_file_response import DeleteFileResponse as DeleteFileResponse
70-
from .eval_candidate_param import EvalCandidateParam as EvalCandidateParam
7168
from .eval_run_eval_params import EvalRunEvalParams as EvalRunEvalParams
7269
from .list_models_response import ListModelsResponse as ListModelsResponse
7370
from .list_routes_response import ListRoutesResponse as ListRoutesResponse

src/llama_stack_client/types/agents/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313
from .step_retrieve_response import StepRetrieveResponse as StepRetrieveResponse
1414
from .session_create_response import SessionCreateResponse as SessionCreateResponse
1515
from .session_retrieve_params import SessionRetrieveParams as SessionRetrieveParams
16-
from .turn_response_event_payload import TurnResponseEventPayload as TurnResponseEventPayload
1716
from .agent_turn_response_stream_chunk import AgentTurnResponseStreamChunk as AgentTurnResponseStreamChunk
Lines changed: 152 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,160 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3+
from typing import Dict, List, Union, Optional
4+
from typing_extensions import Literal, Annotated, TypeAlias
5+
6+
from .turn import Turn
7+
from ..._utils import PropertyInfo
38
from ..._models import BaseModel
4-
from .turn_response_event_payload import TurnResponseEventPayload
9+
from ..inference_step import InferenceStep
10+
from ..shared.tool_call import ToolCall
11+
from ..shield_call_step import ShieldCallStep
12+
from ..tool_execution_step import ToolExecutionStep
13+
from ..memory_retrieval_step import MemoryRetrievalStep
14+
15+
__all__ = [
16+
"TurnResponseEvent",
17+
"Payload",
18+
"PayloadAgentTurnResponseStepStartPayload",
19+
"PayloadAgentTurnResponseStepProgressPayload",
20+
"PayloadAgentTurnResponseStepProgressPayloadDelta",
21+
"PayloadAgentTurnResponseStepProgressPayloadDeltaTextDelta",
22+
"PayloadAgentTurnResponseStepProgressPayloadDeltaImageDelta",
23+
"PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDelta",
24+
"PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDeltaToolCall",
25+
"PayloadAgentTurnResponseStepCompletePayload",
26+
"PayloadAgentTurnResponseStepCompletePayloadStepDetails",
27+
"PayloadAgentTurnResponseTurnStartPayload",
28+
"PayloadAgentTurnResponseTurnCompletePayload",
29+
"PayloadAgentTurnResponseTurnAwaitingInputPayload",
30+
]
31+
32+
33+
class PayloadAgentTurnResponseStepStartPayload(BaseModel):
34+
event_type: Literal["step_start"]
35+
"""Type of event being reported"""
36+
37+
step_id: str
38+
"""Unique identifier for the step within a turn"""
39+
40+
step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"]
41+
"""Type of step being executed"""
42+
43+
metadata: Optional[Dict[str, Union[bool, float, str, List[object], object, None]]] = None
44+
"""(Optional) Additional metadata for the step"""
45+
46+
47+
class PayloadAgentTurnResponseStepProgressPayloadDeltaTextDelta(BaseModel):
48+
text: str
49+
"""The incremental text content"""
50+
51+
type: Literal["text"]
52+
"""Discriminator type of the delta. Always "text" """
53+
54+
55+
class PayloadAgentTurnResponseStepProgressPayloadDeltaImageDelta(BaseModel):
56+
image: str
57+
"""The incremental image data as bytes"""
58+
59+
type: Literal["image"]
60+
"""Discriminator type of the delta. Always "image" """
61+
62+
63+
PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDeltaToolCall: TypeAlias = Union[str, ToolCall]
64+
65+
66+
class PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDelta(BaseModel):
67+
parse_status: Literal["started", "in_progress", "failed", "succeeded"]
68+
"""Current parsing status of the tool call"""
69+
70+
tool_call: PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDeltaToolCall
71+
"""Either an in-progress tool call string or the final parsed tool call"""
72+
73+
type: Literal["tool_call"]
74+
"""Discriminator type of the delta. Always "tool_call" """
75+
76+
77+
PayloadAgentTurnResponseStepProgressPayloadDelta: TypeAlias = Annotated[
78+
Union[
79+
PayloadAgentTurnResponseStepProgressPayloadDeltaTextDelta,
80+
PayloadAgentTurnResponseStepProgressPayloadDeltaImageDelta,
81+
PayloadAgentTurnResponseStepProgressPayloadDeltaToolCallDelta,
82+
],
83+
PropertyInfo(discriminator="type"),
84+
]
85+
86+
87+
class PayloadAgentTurnResponseStepProgressPayload(BaseModel):
88+
delta: PayloadAgentTurnResponseStepProgressPayloadDelta
89+
"""Incremental content changes during step execution"""
90+
91+
event_type: Literal["step_progress"]
92+
"""Type of event being reported"""
93+
94+
step_id: str
95+
"""Unique identifier for the step within a turn"""
96+
97+
step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"]
98+
"""Type of step being executed"""
99+
100+
101+
PayloadAgentTurnResponseStepCompletePayloadStepDetails: TypeAlias = Annotated[
102+
Union[InferenceStep, ToolExecutionStep, ShieldCallStep, MemoryRetrievalStep],
103+
PropertyInfo(discriminator="step_type"),
104+
]
105+
106+
107+
class PayloadAgentTurnResponseStepCompletePayload(BaseModel):
108+
event_type: Literal["step_complete"]
109+
"""Type of event being reported"""
110+
111+
step_details: PayloadAgentTurnResponseStepCompletePayloadStepDetails
112+
"""Complete details of the executed step"""
113+
114+
step_id: str
115+
"""Unique identifier for the step within a turn"""
116+
117+
step_type: Literal["inference", "tool_execution", "shield_call", "memory_retrieval"]
118+
"""Type of step being executed"""
119+
120+
121+
class PayloadAgentTurnResponseTurnStartPayload(BaseModel):
122+
event_type: Literal["turn_start"]
123+
"""Type of event being reported"""
124+
125+
turn_id: str
126+
"""Unique identifier for the turn within a session"""
127+
128+
129+
class PayloadAgentTurnResponseTurnCompletePayload(BaseModel):
130+
event_type: Literal["turn_complete"]
131+
"""Type of event being reported"""
132+
133+
turn: Turn
134+
"""Complete turn data including all steps and results"""
135+
136+
137+
class PayloadAgentTurnResponseTurnAwaitingInputPayload(BaseModel):
138+
event_type: Literal["turn_awaiting_input"]
139+
"""Type of event being reported"""
140+
141+
turn: Turn
142+
"""Turn data when waiting for external tool responses"""
143+
5144

6-
__all__ = ["TurnResponseEvent"]
145+
Payload: TypeAlias = Annotated[
146+
Union[
147+
PayloadAgentTurnResponseStepStartPayload,
148+
PayloadAgentTurnResponseStepProgressPayload,
149+
PayloadAgentTurnResponseStepCompletePayload,
150+
PayloadAgentTurnResponseTurnStartPayload,
151+
PayloadAgentTurnResponseTurnCompletePayload,
152+
PayloadAgentTurnResponseTurnAwaitingInputPayload,
153+
],
154+
PropertyInfo(discriminator="event_type"),
155+
]
7156

8157

9158
class TurnResponseEvent(BaseModel):
10-
payload: TurnResponseEventPayload
159+
payload: Payload
11160
"""Event-specific payload containing event data"""

0 commit comments

Comments
 (0)