Skip to content

Commit 1559ef1

Browse files
committed
Updated the server dependencies
1 parent 1c2d01b commit 1559ef1

File tree

18 files changed

+375
-217
lines changed

18 files changed

+375
-217
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ bin/
4040
.vscode/
4141

4242
### Mac OS ###
43-
.DS_Store
43+
.DS_Store
44+
.kotlin

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,61 @@
1-
# kotlin-sdk: The LMOS Kotlin SDK to devevlop WoT-enabled Agents.
1+
# LMOS Kotlin SDK
2+
3+
The LMOS Kotlin SDK allows you to connect to a Web of Things-enabled agents by pointing to its well-known Thing Description (TD). You can consume events and interact with the agent through chat.
4+
5+
```kotlin
6+
val agent = WotConversationalAgent
7+
.create("http://localhost:9080/weather-agent")
8+
9+
// Consuming an event from the agent
10+
agent.consumeEvent("agentEvent") {
11+
println("Event: $it")
12+
}
13+
14+
// Interacting with the agent via chat
15+
val answer = agent.chat("What is the weather in London?")
16+
```
17+
18+
## Adding the Library to Your Project
19+
20+
To use the `lmos-kotlin-sdk-client` in your project, include the following dependency in your build configuration.
21+
22+
### Gradle
23+
24+
Add the dependency to your `build.gradle.kts` file:
25+
```kotlin
26+
dependencies {
27+
implementation("org.eclipse.lmos:lmos-kotlin-sdk-client:0.1.0-SNAPSHOT")
28+
}
29+
```
30+
31+
Make sure to include the Sonatype Snapshots repository in your `repositories` block:
32+
```kotlin
33+
repositories {
34+
mavenCentral()
35+
maven {
36+
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
37+
}
38+
}
39+
```
40+
41+
### Maven
42+
Add the dependency to your `pom.xml` file:
43+
```xml
44+
<dependency>
45+
<groupId>org.eclipse.lmos</groupId>
46+
<artifactId>lmos-kotlin-sdk-client</artifactId>
47+
<version>0.1.0-SNAPSHOT</version>
48+
</dependency>
49+
```
50+
51+
Include the Sonatype Snapshots repository in your `<repositories>` section:
52+
```xml
53+
<repositories>
54+
<repository>
55+
<id>sonatype-snapshots</id>
56+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
57+
<snapshots>
58+
<enabled>true</enabled>
59+
</snapshots>
60+
</repository>
61+
```

gradlew

100755100644
File mode changed.

lmos-kotlin-sdk-base/src/main/kotlin/sdk/LMOSThingTypes.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
package org.eclipse.lmos.sdk
88

9-
import org.eclipse.thingweb.thing.schema.Type
10-
119
object LMOSThingTypes {
12-
val TOOL = Type("lmos:Tool")
13-
val AGENT = Type("lmos:Agent")
10+
const val TOOL = "lmos:Tool"
11+
const val AGENT = "lmos:Agent"
1412
}

lmos-kotlin-sdk-base/src/main/kotlin/sdk/LmosContext.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
package org.eclipse.lmos.sdk
88

99
object LMOSContext {
10-
const val prefix = "lmos"
11-
const val url = "https://eclipse.dev/lmos/protocol/v1"
10+
const val prefix = "lmos"
11+
const val url = "https://eclipse.dev/lmos/protocol/v1"
1212
}
Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1+
plugins {
2+
kotlin("plugin.spring") version "1.9.10"
3+
id("org.springframework.boot") version "3.1.5" // Use the latest compatible version
4+
id("io.spring.dependency-management") version "1.1.3"
5+
}
6+
17
dependencies {
2-
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
8+
api("org.eclipse.thingweb:kotlin-wot-spring-boot-starter:0.1.0-SNAPSHOT")
39
api(project(":lmos-kotlin-sdk-base"))
4-
implementation("org.slf4j:slf4j-api:2.0.16")
510

611
testImplementation(platform("io.ktor:ktor-bom:3.1.0"))
12+
testImplementation("org.eclipse.lmos:arc-spring-boot-starter:0.122.0-M2")
13+
testImplementation("org.eclipse.lmos:arc-azure-client:0.122.0-M2")
14+
15+
testImplementation(project(":lmos-kotlin-sdk-client"))
716
testImplementation("org.eclipse.thingweb:kotlin-wot-binding-http:0.1.0-SNAPSHOT")
817
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0")
9-
testImplementation("io.ktor:ktor-client-okhttp")
10-
testImplementation("io.ktor:ktor-client-json")
11-
testImplementation("io.ktor:ktor-client-jackson")
12-
testImplementation("io.ktor:ktor-client-serialization")
13-
testImplementation("io.ktor:ktor-client-content-negotiation")
14-
testImplementation("io.ktor:ktor-serialization-jackson")
15-
testImplementation("org.assertj:assertj-core:3.24.2")
16-
}
17-
18-
tasks.register("listConfigurations") {
19-
doLast {
20-
configurations.forEach { config ->
21-
println("Configuration: ${config.name}")
22-
println(" Can be resolved: ${config.isCanBeResolved}")
23-
println(" Can be consumed: ${config.isCanBeConsumed}")
24-
println(" Extends from: ${config.extendsFrom.joinToString { it.name }}")
25-
println()
26-
}
27-
}
28-
}
18+
testImplementation("org.springframework.boot:spring-boot-starter-test")
19+
}

lmos-kotlin-sdk-server/src/main/kotlin/server/LmosAgent.kt

Lines changed: 0 additions & 19 deletions
This file was deleted.

lmos-kotlin-sdk-server/src/main/kotlin/server/LmosRuntime.kt

Lines changed: 0 additions & 81 deletions
This file was deleted.

lmos-kotlin-sdk-server/src/test/kotlin/ai/ancf/lmos/kotlinsdk/server/LmosRuntimeTest.kt

Lines changed: 0 additions & 87 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-FileCopyrightText: Robert Winkler
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package org.eclipse.lmos.sdk.server
8+
9+
import org.eclipse.thingweb.spring.ServientAutoConfiguration
10+
import org.springframework.boot.autoconfigure.SpringBootApplication
11+
import org.springframework.boot.runApplication
12+
import org.springframework.context.annotation.Import
13+
14+
15+
fun main(args: Array<String>) {
16+
runApplication<AgentApplication>(*args)
17+
}
18+
19+
@SpringBootApplication
20+
@Import(ServientAutoConfiguration::class)
21+
class AgentApplication {
22+
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.eclipse.lmos.sdk.server
2+
3+
import kotlinx.coroutines.runBlocking
4+
import org.eclipse.lmos.sdk.agents.WotConversationalAgent
5+
import org.eclipse.lmos.sdk.agents.lastMessage
6+
import org.eclipse.lmos.sdk.agents.toAgentRequest
7+
import org.eclipse.thingweb.Wot
8+
import org.slf4j.LoggerFactory
9+
import org.springframework.beans.factory.annotation.Autowired
10+
import org.springframework.beans.factory.annotation.Value
11+
import org.springframework.boot.test.context.SpringBootTest
12+
import kotlin.test.Test
13+
14+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
15+
class AgentApplicationTest {
16+
17+
private val logger = LoggerFactory.getLogger("AgentApplicationTest")
18+
19+
@Value("\${wot.servient.http.server.port}")
20+
private var port: Int = 0
21+
22+
@Autowired
23+
private lateinit var wot: Wot
24+
25+
// @Test
26+
// fun testChat() = runBlocking {
27+
// val agent = WotConversationalAgent.create(wot, "http://localhost:$port/chatagent")
28+
// val answer = agent.chat("What is london?".toAgentRequest())
29+
// logger.info(answer.lastMessage())
30+
// }
31+
}

0 commit comments

Comments
 (0)