-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Ensure that templates don't cause CL issues during reload
- Loading branch information
Showing
9 changed files
with
193 additions
and
4 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
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,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.quarkiverse.langchain4j</groupId> | ||
<artifactId>quarkus-langchain4j-openai-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>quarkus-langchain4j-openai-devmode-tests</artifactId> | ||
<name>Quarkus LangChain4j - OpenAI - DevMode tests</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkiverse.langchain4j</groupId> | ||
<artifactId>quarkus-langchain4j-openai-deployment</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-jdbc-postgresql</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-hibernate-orm-panache</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5-internal</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wiremock</groupId> | ||
<artifactId>wiremock-standalone</artifactId> | ||
<version>${wiremock.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
21 changes: 21 additions & 0 deletions
21
...lla/devmode-tests/src/test/java/io/quarkiverse/langchain4j/openai/test/Configuration.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,21 @@ | ||
package io.quarkiverse.langchain4j.openai.test; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
|
||
import io.quarkus.hibernate.orm.panache.PanacheEntity; | ||
|
||
@Entity | ||
public class Configuration extends PanacheEntity { | ||
|
||
@Enumerated(EnumType.STRING) | ||
public ConfigurationKey key; | ||
|
||
public String value; | ||
|
||
public static boolean displayNewSpeakers() { | ||
Configuration config = Configuration.find("key", ConfigurationKey.DISPLAY_NEW_SPEAKERS).firstResult(); | ||
return config != null && config.value.equals("true"); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
.../devmode-tests/src/test/java/io/quarkiverse/langchain4j/openai/test/ConfigurationKey.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,5 @@ | ||
package io.quarkiverse.langchain4j.openai.test; | ||
|
||
public enum ConfigurationKey { | ||
DISPLAY_NEW_SPEAKERS, | ||
} |
45 changes: 45 additions & 0 deletions
45
...devmode-tests/src/test/java/io/quarkiverse/langchain4j/openai/test/PromptDevModeTest.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,45 @@ | ||
package io.quarkiverse.langchain4j.openai.test; | ||
|
||
import static io.restassured.RestAssured.get; | ||
|
||
import java.util.function.Function; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
|
||
public class PromptDevModeTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest devModeTest = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Service.class, Resource.class, Configuration.class, ConfigurationKey.class, | ||
Resource.ApplicationGlobals.class) | ||
.addAsResource( | ||
new StringAsset( | ||
"quarkus.langchain4j.openai.api-key=whatever\nquarkus.langchain4j.openai.base-url= https://mockgpt.wiremockapi.cloud/v1"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void test() { | ||
get("test") | ||
.then() | ||
.statusCode(200); | ||
|
||
devModeTest.modifySourceFile(Resource.class, new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return s.replace("java", "kotlin"); | ||
} | ||
}); | ||
|
||
get("test") | ||
.then() | ||
.statusCode(200); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...-vanilla/devmode-tests/src/test/java/io/quarkiverse/langchain4j/openai/test/Resource.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,29 @@ | ||
package io.quarkiverse.langchain4j.openai.test; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import io.quarkus.qute.TemplateGlobal; | ||
|
||
@Path("/test") | ||
public class Resource { | ||
|
||
private final Service service; | ||
|
||
public Resource(Service service) { | ||
this.service = service; | ||
} | ||
|
||
@GET | ||
public String hello() { | ||
return service.findTalks("java"); | ||
} | ||
|
||
@TemplateGlobal | ||
public static class ApplicationGlobals { | ||
|
||
public static boolean displayNewSpeakers() { | ||
return Configuration.displayNewSpeakers(); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...i-vanilla/devmode-tests/src/test/java/io/quarkiverse/langchain4j/openai/test/Service.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,15 @@ | ||
package io.quarkiverse.langchain4j.openai.test; | ||
|
||
import dev.langchain4j.service.SystemMessage; | ||
import dev.langchain4j.service.UserMessage; | ||
import io.quarkiverse.langchain4j.RegisterAiService; | ||
|
||
@RegisterAiService | ||
public interface Service { | ||
|
||
@SystemMessage("You are a computer science conference organiser") | ||
@UserMessage(""" | ||
Help me select talks that match my favorite topics: {topics}. Give me the list of talks. | ||
""") | ||
String findTalks(String topics); | ||
} |
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