diff --git a/src/commonMain/kotlin/tool/Tools.kt b/src/commonMain/kotlin/tool/Tools.kt index adb4781..649f0af 100644 --- a/src/commonMain/kotlin/tool/Tools.kt +++ b/src/commonMain/kotlin/tool/Tools.kt @@ -63,7 +63,10 @@ inline fun toolOf( serializer() } catch (e: SerializationException) { throw SerializationException( - nonAnnotatedToolMessage(), e + "Cannot find serializer for class ${T::class.qualifiedName}, " + + "make sure that it is annotated with @AnthropicTool and " + + "kotlin.serialization plugin is enabled for the project", + e ) } @@ -72,7 +75,7 @@ inline fun toolOf( .annotations .filterIsInstance() .firstOrNull() ?: throw SerializationException( - nonAnnotatedToolMessage() + "The class ${T::class.qualifiedName} must be annotated with @AnthropicTool" ) return Tool( @@ -82,7 +85,3 @@ inline fun toolOf( cacheControl = cacheControl ) } - -@PublishedApi -internal inline fun nonAnnotatedToolMessage() = - "The class ${T::class.qualifiedName} must be annotated with @AnthropicTool" diff --git a/src/commonTest/kotlin/tool/UsableToolTest.kt b/src/commonTest/kotlin/tool/UsableToolTest.kt index c585edb..cd1b6d4 100644 --- a/src/commonTest/kotlin/tool/UsableToolTest.kt +++ b/src/commonTest/kotlin/tool/UsableToolTest.kt @@ -68,7 +68,8 @@ class UsableToolTest { @Test fun shouldFailToCreateToolWithoutAnthropicToolAnnotation() { shouldThrowWithMessage( - "The class com.xemantic.anthropic.tool.UsableToolTest.NoAnnotationTool must be annotated with @AnthropicTool" + "Cannot find serializer for class com.xemantic.anthropic.tool.UsableToolTest.NoAnnotationTool, " + + "make sure that it is annotated with @AnthropicTool and kotlin.serialization plugin is enabled for the project" ) { toolOf() }