Commit bb682ebe by Jonathan Thomas

Refactor of test modules, and adding a check for API_KEY env variable before each test.

parent 74dca102
Pipeline #12446 passed with stage
in 1 minute 45 seconds
package com.owlmaddie; package com.owlmaddie.tests;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
...@@ -7,6 +7,7 @@ import com.owlmaddie.chat.ChatGPTRequest; ...@@ -7,6 +7,7 @@ import com.owlmaddie.chat.ChatGPTRequest;
import com.owlmaddie.commands.ConfigurationHandler; import com.owlmaddie.commands.ConfigurationHandler;
import com.owlmaddie.message.MessageParser; import com.owlmaddie.message.MessageParser;
import com.owlmaddie.message.ParsedMessage; import com.owlmaddie.message.ParsedMessage;
import com.owlmaddie.utils.EntityTestData;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -27,14 +28,16 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; ...@@ -27,14 +28,16 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
/** /**
* The {@code PromptTests} class tests a variety of LLM prompts and expected outputs from specific characters * The {@code BehaviorTests} class tests a variety of LLM prompts and expected outputs from specific characters
* and personality types. For example, an aggressive character will attack, a nervous character will flee, etc... * and personality types. For example, an aggressive character will attack, a nervous character will flee, etc...
*/ */
public class PromptTests { public class BehaviorTests {
static String PROMPT_PATH = "src/main/resources/data/creaturechat/prompts/"; static String PROMPT_PATH = "src/main/resources/data/creaturechat/prompts/";
static String RESOURCE_PATH = "src/test/resources/data/creaturechat/"; static String RESOURCE_PATH = "src/test/resources/data/creaturechat/";
static String API_KEY = ""; static String API_KEY = "";
static String API_URL = ""; static String API_URL = "";
String NO_API_KEY = "No API_KEY environment variable has been set.";
ConfigurationHandler.Config config = null; ConfigurationHandler.Config config = null;
String systemChatContents = null; String systemChatContents = null;
...@@ -71,6 +74,8 @@ public class PromptTests { ...@@ -71,6 +74,8 @@ public class PromptTests {
if (API_URL != null && !API_URL.isEmpty()) { if (API_URL != null && !API_URL.isEmpty()) {
config.setUrl(API_URL); config.setUrl(API_URL);
} }
// Verify API key is set correctly
assertNotNull(API_KEY, NO_API_KEY);
// Load system chat prompt // Load system chat prompt
systemChatContents = readFileContents(systemChatPath); systemChatContents = readFileContents(systemChatPath);
......
package com.owlmaddie; package com.owlmaddie.utils;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment