-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set default description for assistant tools (#777)
* feat: set tool description if available for assistant tool * style: spotless
- Loading branch information
1 parent
7295e6c
commit f741c95
Showing
2 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
core/src/commonTest/kotlin/com/xebia/functional/xef/assistants/ToolDescriptionTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.xebia.functional.xef.assistants | ||
|
||
import com.xebia.functional.xef.llm.assistants.Tool | ||
import com.xebia.functional.xef.llm.defaultFunctionDescription | ||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.shouldBe | ||
import kotlinx.serialization.Serializable | ||
|
||
class ToolDescriptionTests : | ||
StringSpec({ | ||
"Tool has tool name and default description" { | ||
val tool = TestTool() | ||
val toolConfig = Tool.toolOf(tool) | ||
val function = toolConfig.functionObject | ||
val fnName = tool::class.simpleName ?: error("unnamed class") | ||
function.name shouldBe fnName | ||
function.description shouldBe defaultFunctionDescription(fnName) | ||
} | ||
}) { | ||
|
||
@Serializable data class Request(val input: String) | ||
|
||
@Serializable data class Response(val output: String = "Test response") | ||
|
||
class TestTool : Tool<Request, Response> { | ||
override suspend fun invoke(input: Request): Response = Response() | ||
} | ||
} |