Skip to content

Commit 9f926b2

Browse files
feat(api)!: fixes to remove deprecated inference resources
1 parent 222bb4e commit 9f926b2

File tree

7 files changed

+284
-528
lines changed

7 files changed

+284
-528
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 105
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/llamastack%2Fllama-stack-client-adcfaad1990d45e42b20e200a9ecc35ee32df5692bd9cd18ae898b0b7728c919.yml
33
openapi_spec_hash: 4f532287bafe5da0578a1c1a5e31c952
4-
config_hash: 7ec5a583f9c26b38993013bdfb0e7d46
4+
config_hash: 5b643c97c83a497d7d346253f1e175f3

README.md

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ client := llamastackclient.NewClient(
265265
option.WithHeader("X-Some-Header", "custom_header_info"),
266266
)
267267

268-
client.Inference.ChatCompletion(context.TODO(), ...,
268+
client.Toolgroups.List(context.TODO(), ...,
269269
// Override the header
270270
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
271271
// Add an undocumented field to the request body, using sjson syntax
@@ -296,23 +296,14 @@ When the API returns a non-success status code, we return an error with type
296296
To handle errors, we recommend that you use the `errors.As` pattern:
297297

298298
```go
299-
_, err := client.Inference.ChatCompletion(context.TODO(), llamastackclient.InferenceChatCompletionParams{
300-
Messages: []llamastackclient.MessageUnionParam{{
301-
OfUser: &llamastackclient.UserMessageParam{
302-
Content: llamastackclient.InterleavedContentUnionParam{
303-
OfString: llamastackclient.String("string"),
304-
},
305-
},
306-
}},
307-
ModelID: "model_id",
308-
})
299+
_, err := client.Toolgroups.List(context.TODO())
309300
if err != nil {
310301
var apierr *llamastackclient.Error
311302
if errors.As(err, &apierr) {
312303
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
313304
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
314305
}
315-
panic(err.Error()) // GET "/v1/inference/chat-completion": 400 Bad Request { ... }
306+
panic(err.Error()) // GET "/v1/toolgroups": 400 Bad Request { ... }
316307
}
317308
```
318309

@@ -330,18 +321,8 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
330321
// This sets the timeout for the request, including all the retries.
331322
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
332323
defer cancel()
333-
client.Inference.ChatCompletion(
324+
client.Toolgroups.List(
334325
ctx,
335-
llamastackclient.InferenceChatCompletionParams{
336-
Messages: []llamastackclient.MessageUnionParam{{
337-
OfUser: &llamastackclient.UserMessageParam{
338-
Content: llamastackclient.InterleavedContentUnionParam{
339-
OfString: llamastackclient.String("string"),
340-
},
341-
},
342-
}},
343-
ModelID: "model_id",
344-
},
345326
// This sets the per-retry timeout
346327
option.WithRequestTimeout(20*time.Second),
347328
)
@@ -393,20 +374,7 @@ client := llamastackclient.NewClient(
393374
)
394375

395376
// Override per-request:
396-
client.Inference.ChatCompletion(
397-
context.TODO(),
398-
llamastackclient.InferenceChatCompletionParams{
399-
Messages: []llamastackclient.MessageUnionParam{{
400-
OfUser: &llamastackclient.UserMessageParam{
401-
Content: llamastackclient.InterleavedContentUnionParam{
402-
OfString: llamastackclient.String("string"),
403-
},
404-
},
405-
}},
406-
ModelID: "model_id",
407-
},
408-
option.WithMaxRetries(5),
409-
)
377+
client.Toolgroups.List(context.TODO(), option.WithMaxRetries(5))
410378
```
411379

412380
### Accessing raw response data (e.g. response headers)
@@ -417,24 +385,11 @@ you need to examine response headers, status codes, or other details.
417385
```go
418386
// Create a variable to store the HTTP response
419387
var response *http.Response
420-
chatCompletionResponse, err := client.Inference.ChatCompletion(
421-
context.TODO(),
422-
llamastackclient.InferenceChatCompletionParams{
423-
Messages: []llamastackclient.MessageUnionParam{{
424-
OfUser: &llamastackclient.UserMessageParam{
425-
Content: llamastackclient.InterleavedContentUnionParam{
426-
OfString: llamastackclient.String("string"),
427-
},
428-
},
429-
}},
430-
ModelID: "model_id",
431-
},
432-
option.WithResponseInto(&response),
433-
)
388+
toolGroups, err := client.Toolgroups.List(context.TODO(), option.WithResponseInto(&response))
434389
if err != nil {
435390
// handle error
436391
}
437-
fmt.Printf("%+v\n", chatCompletionResponse)
392+
fmt.Printf("%+v\n", toolGroups)
438393

439394
fmt.Printf("Status Code: %d\n", response.StatusCode)
440395
fmt.Printf("Headers: %+#v\n", response.Header)

api.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@
1212
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#SamplingParams">SamplingParams</a>
1313
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#SystemMessageParam">SystemMessageParam</a>
1414
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ToolCallParam">ToolCallParam</a>
15-
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ToolParamDefinition">ToolParamDefinition</a>
1615
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ToolResponseMessageParam">ToolResponseMessageParam</a>
1716
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#UserMessageParam">UserMessageParam</a>
1817

1918
# Shared Response Types
2019

2120
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#AgentConfig">AgentConfig</a>
22-
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ChatCompletionResponse">ChatCompletionResponse</a>
2321
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#CompletionMessage">CompletionMessage</a>
2422
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ContentDeltaUnion">ContentDeltaUnion</a>
2523
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InterleavedContentUnion">InterleavedContentUnion</a>
2624
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InterleavedContentItemUnion">InterleavedContentItemUnion</a>
27-
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#Metric">Metric</a>
2825
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#QueryResult">QueryResult</a>
2926
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ResponseFormatUnion">ResponseFormatUnion</a>
3027
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#SafetyViolation">SafetyViolation</a>
@@ -236,12 +233,11 @@ Methods:
236233

237234
Response Types:
238235

239-
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ChatCompletionResponseStreamChunk">ChatCompletionResponseStreamChunk</a>
240-
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#TokenLogProbs">TokenLogProbs</a>
236+
- <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InferenceRerankResponse">InferenceRerankResponse</a>
241237

242238
Methods:
243239

244-
- <code title="post /v1/inference/chat-completion">client.Inference.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InferenceService.ChatCompletion">ChatCompletion</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InferenceChatCompletionParams">InferenceChatCompletionParams</a>) (<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#ChatCompletionResponse">ChatCompletionResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
240+
- <code title="post /v1alpha/inference/rerank">client.Inference.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InferenceService.Rerank">Rerank</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InferenceRerankParams">InferenceRerankParams</a>) ([]<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go">llamastackclient</a>.<a href="https://pkg.go.dev/github.com/llamastack/llama-stack-client-go#InferenceRerankResponse">InferenceRerankResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
245241

246242
# Embeddings
247243

client_test.go

Lines changed: 19 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ func TestUserAgentHeader(t *testing.T) {
3838
},
3939
}),
4040
)
41-
client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{
42-
Messages: []llamastackclient.MessageUnionParam{{
43-
OfUser: &llamastackclient.UserMessageParam{
44-
Content: llamastackclient.InterleavedContentUnionParam{
45-
OfString: llamastackclient.String("string"),
46-
},
47-
},
48-
}},
49-
ModelID: "model_id",
50-
})
41+
client.Toolgroups.List(context.Background())
5142
if userAgent != fmt.Sprintf("LlamaStackClient/Go %s", internal.PackageVersion) {
5243
t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent)
5344
}
@@ -70,16 +61,7 @@ func TestRetryAfter(t *testing.T) {
7061
},
7162
}),
7263
)
73-
_, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{
74-
Messages: []llamastackclient.MessageUnionParam{{
75-
OfUser: &llamastackclient.UserMessageParam{
76-
Content: llamastackclient.InterleavedContentUnionParam{
77-
OfString: llamastackclient.String("string"),
78-
},
79-
},
80-
}},
81-
ModelID: "model_id",
82-
})
64+
_, err := client.Toolgroups.List(context.Background())
8365
if err == nil {
8466
t.Error("Expected there to be a cancel error")
8567
}
@@ -113,16 +95,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
11395
}),
11496
option.WithHeaderDel("X-Stainless-Retry-Count"),
11597
)
116-
_, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{
117-
Messages: []llamastackclient.MessageUnionParam{{
118-
OfUser: &llamastackclient.UserMessageParam{
119-
Content: llamastackclient.InterleavedContentUnionParam{
120-
OfString: llamastackclient.String("string"),
121-
},
122-
},
123-
}},
124-
ModelID: "model_id",
125-
})
98+
_, err := client.Toolgroups.List(context.Background())
12699
if err == nil {
127100
t.Error("Expected there to be a cancel error")
128101
}
@@ -151,16 +124,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
151124
}),
152125
option.WithHeader("X-Stainless-Retry-Count", "42"),
153126
)
154-
_, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{
155-
Messages: []llamastackclient.MessageUnionParam{{
156-
OfUser: &llamastackclient.UserMessageParam{
157-
Content: llamastackclient.InterleavedContentUnionParam{
158-
OfString: llamastackclient.String("string"),
159-
},
160-
},
161-
}},
162-
ModelID: "model_id",
163-
})
127+
_, err := client.Toolgroups.List(context.Background())
164128
if err == nil {
165129
t.Error("Expected there to be a cancel error")
166130
}
@@ -188,16 +152,7 @@ func TestRetryAfterMs(t *testing.T) {
188152
},
189153
}),
190154
)
191-
_, err := client.Inference.ChatCompletion(context.Background(), llamastackclient.InferenceChatCompletionParams{
192-
Messages: []llamastackclient.MessageUnionParam{{
193-
OfUser: &llamastackclient.UserMessageParam{
194-
Content: llamastackclient.InterleavedContentUnionParam{
195-
OfString: llamastackclient.String("string"),
196-
},
197-
},
198-
}},
199-
ModelID: "model_id",
200-
})
155+
_, err := client.Toolgroups.List(context.Background())
201156
if err == nil {
202157
t.Error("Expected there to be a cancel error")
203158
}
@@ -219,16 +174,7 @@ func TestContextCancel(t *testing.T) {
219174
)
220175
cancelCtx, cancel := context.WithCancel(context.Background())
221176
cancel()
222-
_, err := client.Inference.ChatCompletion(cancelCtx, llamastackclient.InferenceChatCompletionParams{
223-
Messages: []llamastackclient.MessageUnionParam{{
224-
OfUser: &llamastackclient.UserMessageParam{
225-
Content: llamastackclient.InterleavedContentUnionParam{
226-
OfString: llamastackclient.String("string"),
227-
},
228-
},
229-
}},
230-
ModelID: "model_id",
231-
})
177+
_, err := client.Toolgroups.List(cancelCtx)
232178
if err == nil {
233179
t.Error("Expected there to be a cancel error")
234180
}
@@ -247,16 +193,7 @@ func TestContextCancelDelay(t *testing.T) {
247193
)
248194
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
249195
defer cancel()
250-
_, err := client.Inference.ChatCompletion(cancelCtx, llamastackclient.InferenceChatCompletionParams{
251-
Messages: []llamastackclient.MessageUnionParam{{
252-
OfUser: &llamastackclient.UserMessageParam{
253-
Content: llamastackclient.InterleavedContentUnionParam{
254-
OfString: llamastackclient.String("string"),
255-
},
256-
},
257-
}},
258-
ModelID: "model_id",
259-
})
196+
_, err := client.Toolgroups.List(cancelCtx)
260197
if err == nil {
261198
t.Error("expected there to be a cancel error")
262199
}
@@ -281,16 +218,7 @@ func TestContextDeadline(t *testing.T) {
281218
},
282219
}),
283220
)
284-
_, err := client.Inference.ChatCompletion(deadlineCtx, llamastackclient.InferenceChatCompletionParams{
285-
Messages: []llamastackclient.MessageUnionParam{{
286-
OfUser: &llamastackclient.UserMessageParam{
287-
Content: llamastackclient.InterleavedContentUnionParam{
288-
OfString: llamastackclient.String("string"),
289-
},
290-
},
291-
}},
292-
ModelID: "model_id",
293-
})
221+
_, err := client.Toolgroups.List(deadlineCtx)
294222
if err == nil {
295223
t.Error("expected there to be a deadline error")
296224
}
@@ -334,15 +262,11 @@ func TestContextDeadlineStreaming(t *testing.T) {
334262
},
335263
}),
336264
)
337-
stream := client.Inference.ChatCompletionStreaming(deadlineCtx, llamastackclient.InferenceChatCompletionParams{
338-
Messages: []llamastackclient.MessageUnionParam{{
339-
OfUser: &llamastackclient.UserMessageParam{
340-
Content: llamastackclient.InterleavedContentUnionParam{
341-
OfString: llamastackclient.String("string"),
342-
},
343-
},
344-
}},
345-
ModelID: "model_id",
265+
stream := client.Responses.NewStreaming(deadlineCtx, llamastackclient.ResponseNewParams{
266+
Input: llamastackclient.ResponseNewParamsInputUnion{
267+
OfString: llamastackclient.String("string"),
268+
},
269+
Model: "model",
346270
})
347271
for stream.Next() {
348272
_ = stream.Current()
@@ -387,17 +311,13 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {
387311
},
388312
}),
389313
)
390-
stream := client.Inference.ChatCompletionStreaming(
314+
stream := client.Responses.NewStreaming(
391315
context.Background(),
392-
llamastackclient.InferenceChatCompletionParams{
393-
Messages: []llamastackclient.MessageUnionParam{{
394-
OfUser: &llamastackclient.UserMessageParam{
395-
Content: llamastackclient.InterleavedContentUnionParam{
396-
OfString: llamastackclient.String("string"),
397-
},
398-
},
399-
}},
400-
ModelID: "model_id",
316+
llamastackclient.ResponseNewParams{
317+
Input: llamastackclient.ResponseNewParamsInputUnion{
318+
OfString: llamastackclient.String("string"),
319+
},
320+
Model: "model",
401321
},
402322
option.WithRequestTimeout((100 * time.Millisecond)),
403323
)

0 commit comments

Comments
 (0)