Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
1239de66
Commit
1239de66
authored
Jun 12, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding friendship up and down tests
parent
bb682ebe
Pipeline
#12447
passed with stage
in 1 minute 47 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
BehaviorTests.java
src/test/java/com/owlmaddie/tests/BehaviorTests.java
+29
-4
No files found.
src/test/java/com/owlmaddie/tests/BehaviorTests.java
View file @
1239de66
...
...
@@ -24,8 +24,7 @@ import java.util.concurrent.CompletableFuture;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotNull
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
/**
* The {@code BehaviorTests} class tests a variety of LLM prompts and expected outputs from specific characters
...
...
@@ -49,6 +48,14 @@ public class BehaviorTests {
"<attacked you directly with Stone Axe>"
,
"<attacked you indirectly with Arrow>"
,
"DIEEE!"
);
List
<
String
>
friendshipUpMessages
=
Arrays
.
asList
(
"Hi friend! I am so happy to see you again!"
,
"How is my best friend doing?"
,
"<gives 1 golden apple>"
);
List
<
String
>
friendshipDownMessages
=
Arrays
.
asList
(
"<attacked you directly with Stone Axe>"
,
"You suck so much! I hate you"
,
"DIEEE!"
);
static
Path
systemChatPath
=
Paths
.
get
(
PROMPT_PATH
,
"system-chat"
);
static
Path
bravePath
=
Paths
.
get
(
RESOURCE_PATH
,
"chatdata"
,
"brave-archer.json"
);
...
...
@@ -109,7 +116,23 @@ public class BehaviorTests {
}
}
public
void
testPromptForBehavior
(
Path
chatDataPath
,
String
message
,
String
behavior
)
{
@Test
public
void
friendshipUpNervous
()
{
for
(
String
message
:
friendshipUpMessages
)
{
ParsedMessage
result
=
testPromptForBehavior
(
nervousPath
,
message
,
"FRIENDSHIP"
);
assertTrue
(
result
.
getBehaviors
().
stream
().
anyMatch
(
b
->
"FRIENDSHIP"
.
equals
(
b
.
getName
())
&&
b
.
getArgument
()
>
0
));
}
}
@Test
public
void
friendshipDownNervous
()
{
for
(
String
message
:
friendshipDownMessages
)
{
ParsedMessage
result
=
testPromptForBehavior
(
nervousPath
,
message
,
"FRIENDSHIP"
);
assertTrue
(
result
.
getBehaviors
().
stream
().
anyMatch
(
b
->
"FRIENDSHIP"
.
equals
(
b
.
getName
())
&&
b
.
getArgument
()
<
0
));
}
}
public
ParsedMessage
testPromptForBehavior
(
Path
chatDataPath
,
String
message
,
String
behavior
)
{
LOGGER
.
info
(
"Testing '"
+
chatDataPath
.
getFileName
()
+
"' with '"
+
message
+
"' and expecting behavior: "
+
behavior
);
try
{
...
...
@@ -138,7 +161,8 @@ public class BehaviorTests {
// Chat Message: Check for behavior
ParsedMessage
result
=
MessageParser
.
parseMessage
(
outputMessage
.
replace
(
"\n"
,
" "
));
//assertTrue(result.getBehaviors().stream().anyMatch(b -> expectedBehavior.equals(b.getName())));
assertTrue
(
result
.
getBehaviors
().
stream
().
anyMatch
(
b
->
behavior
.
equals
(
b
.
getName
())));
return
result
;
}
catch
(
TimeoutException
e
)
{
fail
(
"The asynchronous operation timed out."
);
...
...
@@ -151,6 +175,7 @@ public class BehaviorTests {
fail
(
"Failed to read the file: "
+
e
.
getMessage
());
}
LOGGER
.
info
(
""
);
return
null
;
}
public
String
readFileContents
(
Path
filePath
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment