-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail at build time when tools set and no memory provided
Closes: #86
- Loading branch information
Showing
3 changed files
with
69 additions
and
14 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
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
52 changes: 52 additions & 0 deletions
52
...c/test/java/io/quarkiverse/langchain4j/openai/test/AiServiceWithToolsAndNoMemoryTest.java
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,52 @@ | ||
package io.quarkiverse.langchain4j.openai.test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import jakarta.enterprise.inject.spi.DeploymentException; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import dev.langchain4j.agent.tool.Tool; | ||
import io.quarkiverse.langchain4j.RegisterAiService; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class AiServiceWithToolsAndNoMemoryTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest unitTest = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses()) | ||
.assertException(t -> { | ||
assertThat(t) | ||
.isInstanceOf(DeploymentException.class) | ||
.hasMessageContaining("ChatMemoryProvider"); | ||
}); | ||
|
||
@RegisterAiService(tools = CustomTool.class) | ||
interface Assistant { | ||
|
||
String chat(String input); | ||
} | ||
|
||
@Singleton | ||
static class CustomTool { | ||
|
||
@Tool | ||
void doSomething() { | ||
|
||
} | ||
} | ||
|
||
@Inject | ||
Assistant assistant; | ||
|
||
@Test | ||
void test() { | ||
fail("Should not be called"); | ||
} | ||
} |