Skip to content

Commit a7fb6ed

Browse files
authored
Merge pull request #9 from meta-llama/upgrade-sdk
Upgrade SDK to be compatible with 0.0.54 server version
2 parents 968dd49 + b37ef8f commit a7fb6ed

File tree

269 files changed

+5076
-3376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+5076
-3376
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ plugins {
44

55
allprojects {
66
group = "com.llama.llamastack"
7-
version = "0.0.1-alpha.1"
7+
version = "0.0.1-alpha.2"
88
}

llama-stack-client-kotlin-core/build.gradle.kts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ plugins {
44
}
55

66
dependencies {
7-
api("com.fasterxml.jackson.core:jackson-core:2.14.3")
8-
api("com.fasterxml.jackson.core:jackson-databind:2.14.3")
7+
api("com.fasterxml.jackson.core:jackson-core:2.18.1")
8+
api("com.fasterxml.jackson.core:jackson-databind:2.18.1")
99

10-
implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3")
11-
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3")
12-
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3")
13-
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3")
10+
implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1")
11+
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1")
12+
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1")
13+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1")
1414
implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4")
1515
implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1")
1616
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
@@ -21,4 +21,7 @@ dependencies {
2121
testImplementation("org.assertj:assertj-core:3.25.3")
2222
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
2323
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3")
24+
testImplementation("org.mockito:mockito-core:5.14.2")
25+
testImplementation("org.mockito:mockito-junit-jupiter:5.14.2")
26+
testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0")
2427
}

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/client/LlamaStackClientClient.kt

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

1212
fun agents(): AgentService
1313

14-
fun batchInferences(): BatchInferenceService
14+
fun batchInference(): BatchInferenceService
1515

1616
fun datasets(): DatasetService
1717

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/client/LlamaStackClientClientAsync.kt

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

1212
fun agents(): AgentServiceAsync
1313

14-
fun batchInferences(): BatchInferenceServiceAsync
14+
fun batchInference(): BatchInferenceServiceAsync
1515

1616
fun datasets(): DatasetServiceAsync
1717

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/client/LlamaStackClientClientAsyncImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ constructor(
2727
AgentServiceAsyncImpl(clientOptionsWithUserAgent)
2828
}
2929

30-
private val batchInferences: BatchInferenceServiceAsync by lazy {
30+
private val batchInference: BatchInferenceServiceAsync by lazy {
3131
BatchInferenceServiceAsyncImpl(clientOptionsWithUserAgent)
3232
}
3333

@@ -105,7 +105,7 @@ constructor(
105105

106106
override fun agents(): AgentServiceAsync = agents
107107

108-
override fun batchInferences(): BatchInferenceServiceAsync = batchInferences
108+
override fun batchInference(): BatchInferenceServiceAsync = batchInference
109109

110110
override fun datasets(): DatasetServiceAsync = datasets
111111

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/client/LlamaStackClientClientImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ constructor(
2727

2828
private val agents: AgentService by lazy { AgentServiceImpl(clientOptionsWithUserAgent) }
2929

30-
private val batchInferences: BatchInferenceService by lazy {
30+
private val batchInference: BatchInferenceService by lazy {
3131
BatchInferenceServiceImpl(clientOptionsWithUserAgent)
3232
}
3333

@@ -89,7 +89,7 @@ constructor(
8989

9090
override fun agents(): AgentService = agents
9191

92-
override fun batchInferences(): BatchInferenceService = batchInferences
92+
override fun batchInference(): BatchInferenceService = batchInference
9393

9494
override fun datasets(): DatasetService = datasets
9595

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/core/PhantomReachable.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,29 @@ internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable)
1414
check(observed !== closeable) {
1515
"`observed` cannot be the same object as `closeable` because it would never become phantom reachable"
1616
}
17-
closeWhenPhantomReachable?.let { it(observed, closeable::close) }
17+
closeWhenPhantomReachable(observed, closeable::close)
1818
}
1919

20-
private val closeWhenPhantomReachable: ((Any, AutoCloseable) -> Unit)? by lazy {
20+
/**
21+
* Calls [close] when [observed] becomes only phantom reachable.
22+
*
23+
* This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions.
24+
*/
25+
internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) {
26+
closeWhenPhantomReachable?.let { it(observed, close) }
27+
}
28+
29+
private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy {
2130
try {
2231
val cleanerClass = Class.forName("java.lang.ref.Cleaner")
2332
val cleanerCreate = cleanerClass.getMethod("create")
2433
val cleanerRegister =
2534
cleanerClass.getMethod("register", Any::class.java, Runnable::class.java)
2635
val cleanerObject = cleanerCreate.invoke(null);
2736

28-
{ observed, closeable ->
37+
{ observed, close ->
2938
try {
30-
cleanerRegister.invoke(cleanerObject, observed, Runnable { closeable.close() })
39+
cleanerRegister.invoke(cleanerObject, observed, Runnable { close() })
3140
} catch (e: ReflectiveOperationException) {
3241
if (e is InvocationTargetException) {
3342
when (val cause = e.cause) {

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/errors/LlamaStackClientError.kt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ private constructor(
1717
@JsonAnyGetter val additionalProperties: Map<String, JsonValue>,
1818
) {
1919

20-
override fun equals(other: Any?): Boolean {
21-
if (this === other) {
22-
return true
23-
}
24-
25-
return /* spotless:off */ other is LlamaStackClientError && this.additionalProperties == other.additionalProperties /* spotless:on */
26-
}
27-
28-
override fun hashCode(): Int {
29-
return /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */
30-
}
31-
32-
override fun toString() = "LlamaStackClientError{additionalProperties=$additionalProperties}"
33-
3420
fun toBuilder() = Builder().from(this)
3521

3622
companion object {
@@ -69,4 +55,16 @@ private constructor(
6955
fun build(): LlamaStackClientError =
7056
LlamaStackClientError(additionalProperties.toImmutable())
7157
}
58+
59+
override fun equals(other: Any?): Boolean {
60+
if (this === other) {
61+
return true
62+
}
63+
64+
return /* spotless:off */ other is LlamaStackClientError && additionalProperties == other.additionalProperties /* spotless:on */
65+
}
66+
67+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */
68+
69+
override fun toString() = "LlamaStackClientError{additionalProperties=$additionalProperties}"
7270
}

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/models/AgentConfig.kt

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private constructor(
307307
return true
308308
}
309309

310-
return /* spotless:off */ other is ToolChoice && this.value == other.value /* spotless:on */
310+
return /* spotless:off */ other is ToolChoice && value == other.value /* spotless:on */
311311
}
312312

313313
override fun hashCode() = value.hashCode()
@@ -364,7 +364,7 @@ private constructor(
364364
return true
365365
}
366366

367-
return /* spotless:off */ other is ToolPromptFormat && this.value == other.value /* spotless:on */
367+
return /* spotless:off */ other is ToolPromptFormat && value == other.value /* spotless:on */
368368
}
369369

370370
override fun hashCode() = value.hashCode()
@@ -520,15 +520,13 @@ private constructor(
520520
return true
521521
}
522522

523-
return /* spotless:off */ other is Tool && this.searchToolDefinition == other.searchToolDefinition && this.wolframAlphaToolDefinition == other.wolframAlphaToolDefinition && this.photogenToolDefinition == other.photogenToolDefinition && this.codeInterpreterToolDefinition == other.codeInterpreterToolDefinition && this.functionCallToolDefinition == other.functionCallToolDefinition && this.memoryToolDefinition == other.memoryToolDefinition /* spotless:on */
523+
return /* spotless:off */ other is Tool && searchToolDefinition == other.searchToolDefinition && wolframAlphaToolDefinition == other.wolframAlphaToolDefinition && photogenToolDefinition == other.photogenToolDefinition && codeInterpreterToolDefinition == other.codeInterpreterToolDefinition && functionCallToolDefinition == other.functionCallToolDefinition && memoryToolDefinition == other.memoryToolDefinition /* spotless:on */
524524
}
525525

526-
override fun hashCode(): Int {
527-
return /* spotless:off */ Objects.hash(searchToolDefinition, wolframAlphaToolDefinition, photogenToolDefinition, codeInterpreterToolDefinition, functionCallToolDefinition, memoryToolDefinition) /* spotless:on */
528-
}
526+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(searchToolDefinition, wolframAlphaToolDefinition, photogenToolDefinition, codeInterpreterToolDefinition, functionCallToolDefinition, memoryToolDefinition) /* spotless:on */
529527

530-
override fun toString(): String {
531-
return when {
528+
override fun toString(): String =
529+
when {
532530
searchToolDefinition != null -> "Tool{searchToolDefinition=$searchToolDefinition}"
533531
wolframAlphaToolDefinition != null ->
534532
"Tool{wolframAlphaToolDefinition=$wolframAlphaToolDefinition}"
@@ -542,7 +540,6 @@ private constructor(
542540
_json != null -> "Tool{_unknown=$_json}"
543541
else -> throw IllegalStateException("Invalid Tool")
544542
}
545-
}
546543

547544
companion object {
548545

@@ -661,17 +658,14 @@ private constructor(
661658
return true
662659
}
663660

664-
return /* spotless:off */ other is AgentConfig && this.enableSessionPersistence == other.enableSessionPersistence && this.inputShields == other.inputShields && this.instructions == other.instructions && this.maxInferIters == other.maxInferIters && this.model == other.model && this.outputShields == other.outputShields && this.samplingParams == other.samplingParams && this.toolChoice == other.toolChoice && this.toolPromptFormat == other.toolPromptFormat && this.tools == other.tools && this.additionalProperties == other.additionalProperties /* spotless:on */
661+
return /* spotless:off */ other is AgentConfig && enableSessionPersistence == other.enableSessionPersistence && inputShields == other.inputShields && instructions == other.instructions && maxInferIters == other.maxInferIters && model == other.model && outputShields == other.outputShields && samplingParams == other.samplingParams && toolChoice == other.toolChoice && toolPromptFormat == other.toolPromptFormat && tools == other.tools && additionalProperties == other.additionalProperties /* spotless:on */
665662
}
666663

667-
private var hashCode: Int = 0
664+
/* spotless:off */
665+
private val hashCode: Int by lazy { Objects.hash(enableSessionPersistence, inputShields, instructions, maxInferIters, model, outputShields, samplingParams, toolChoice, toolPromptFormat, tools, additionalProperties) }
666+
/* spotless:on */
668667

669-
override fun hashCode(): Int {
670-
if (hashCode == 0) {
671-
hashCode = /* spotless:off */ Objects.hash(enableSessionPersistence, inputShields, instructions, maxInferIters, model, outputShields, samplingParams, toolChoice, toolPromptFormat, tools, additionalProperties) /* spotless:on */
672-
}
673-
return hashCode
674-
}
668+
override fun hashCode(): Int = hashCode
675669

676670
override fun toString() =
677671
"AgentConfig{enableSessionPersistence=$enableSessionPersistence, inputShields=$inputShields, instructions=$instructions, maxInferIters=$maxInferIters, model=$model, outputShields=$outputShields, samplingParams=$samplingParams, toolChoice=$toolChoice, toolPromptFormat=$toolPromptFormat, tools=$tools, additionalProperties=$additionalProperties}"

llama-stack-client-kotlin-core/src/main/kotlin/com/llama/llamastack/models/AgentCreateParams.kt

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,28 @@ import java.util.Objects
1818
class AgentCreateParams
1919
constructor(
2020
private val agentConfig: AgentConfig,
21+
private val xLlamaStackProviderData: String?,
2122
private val additionalHeaders: Headers,
2223
private val additionalQueryParams: QueryParams,
2324
private val additionalBodyProperties: Map<String, JsonValue>,
2425
) {
2526

2627
fun agentConfig(): AgentConfig = agentConfig
2728

29+
fun xLlamaStackProviderData(): String? = xLlamaStackProviderData
30+
2831
internal fun getBody(): AgentCreateBody {
2932
return AgentCreateBody(agentConfig, additionalBodyProperties)
3033
}
3134

32-
internal fun getHeaders(): Headers = additionalHeaders
35+
internal fun getHeaders(): Headers {
36+
val headers = Headers.builder()
37+
this.xLlamaStackProviderData?.let {
38+
headers.put("X-LlamaStack-ProviderData", listOf(it.toString()))
39+
}
40+
headers.putAll(additionalHeaders)
41+
return headers.build()
42+
}
3343

3444
internal fun getQueryParams(): QueryParams = additionalQueryParams
3545

@@ -93,17 +103,14 @@ constructor(
93103
return true
94104
}
95105

96-
return /* spotless:off */ other is AgentCreateBody && this.agentConfig == other.agentConfig && this.additionalProperties == other.additionalProperties /* spotless:on */
106+
return /* spotless:off */ other is AgentCreateBody && agentConfig == other.agentConfig && additionalProperties == other.additionalProperties /* spotless:on */
97107
}
98108

99-
private var hashCode: Int = 0
109+
/* spotless:off */
110+
private val hashCode: Int by lazy { Objects.hash(agentConfig, additionalProperties) }
111+
/* spotless:on */
100112

101-
override fun hashCode(): Int {
102-
if (hashCode == 0) {
103-
hashCode = /* spotless:off */ Objects.hash(agentConfig, additionalProperties) /* spotless:on */
104-
}
105-
return hashCode
106-
}
113+
override fun hashCode(): Int = hashCode
107114

108115
override fun toString() =
109116
"AgentCreateBody{agentConfig=$agentConfig, additionalProperties=$additionalProperties}"
@@ -120,15 +127,13 @@ constructor(
120127
return true
121128
}
122129

123-
return /* spotless:off */ other is AgentCreateParams && this.agentConfig == other.agentConfig && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */
130+
return /* spotless:off */ other is AgentCreateParams && agentConfig == other.agentConfig && xLlamaStackProviderData == other.xLlamaStackProviderData && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */
124131
}
125132

126-
override fun hashCode(): Int {
127-
return /* spotless:off */ Objects.hash(agentConfig, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */
128-
}
133+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(agentConfig, xLlamaStackProviderData, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */
129134

130135
override fun toString() =
131-
"AgentCreateParams{agentConfig=$agentConfig, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}"
136+
"AgentCreateParams{agentConfig=$agentConfig, xLlamaStackProviderData=$xLlamaStackProviderData, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}"
132137

133138
fun toBuilder() = Builder().from(this)
134139

@@ -141,19 +146,25 @@ constructor(
141146
class Builder {
142147

143148
private var agentConfig: AgentConfig? = null
149+
private var xLlamaStackProviderData: String? = null
144150
private var additionalHeaders: Headers.Builder = Headers.builder()
145151
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
146152
private var additionalBodyProperties: MutableMap<String, JsonValue> = mutableMapOf()
147153

148154
internal fun from(agentCreateParams: AgentCreateParams) = apply {
149155
this.agentConfig = agentCreateParams.agentConfig
156+
this.xLlamaStackProviderData = agentCreateParams.xLlamaStackProviderData
150157
additionalHeaders(agentCreateParams.additionalHeaders)
151158
additionalQueryParams(agentCreateParams.additionalQueryParams)
152159
additionalBodyProperties(agentCreateParams.additionalBodyProperties)
153160
}
154161

155162
fun agentConfig(agentConfig: AgentConfig) = apply { this.agentConfig = agentConfig }
156163

164+
fun xLlamaStackProviderData(xLlamaStackProviderData: String) = apply {
165+
this.xLlamaStackProviderData = xLlamaStackProviderData
166+
}
167+
157168
fun additionalHeaders(additionalHeaders: Headers) = apply {
158169
this.additionalHeaders.clear()
159170
putAllAdditionalHeaders(additionalHeaders)
@@ -277,6 +288,7 @@ constructor(
277288
fun build(): AgentCreateParams =
278289
AgentCreateParams(
279290
checkNotNull(agentConfig) { "`agentConfig` is required but was not set" },
291+
xLlamaStackProviderData,
280292
additionalHeaders.build(),
281293
additionalQueryParams.build(),
282294
additionalBodyProperties.toImmutable(),

0 commit comments

Comments
 (0)