Skip to content

Commit

Permalink
test: add system prompt test
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangvvo committed Nov 8, 2024
1 parent 3047aca commit 10bbe11
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion javascript/test/test-language-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,31 @@ export function testLanguageModel(languageModel: LanguageModel) {
t.assert.equal((part as TextPart).text.length > 0, true);
});

test("generate with system prompt", async (t) => {
const response = await languageModel.generate({
messages: [
{
role: "user",
content: [
{
type: "text",
text: "Hello",
},
],
},
],
systemPrompt: 'You must always start your message with "🤖"',
});

log(response);

const part = response.content[0];

t.assert.equal(part?.type, "text");
t.assert.equal((part as TextPart).text.length > 0, true);
t.assert.equal((part as TextPart).text.startsWith("🤖"), true);
});

test("generate tool call", async (t) => {
const response = await languageModel.generate({
messages: [
Expand Down Expand Up @@ -359,7 +384,7 @@ export function testLanguageModel(languageModel: LanguageModel) {
content: [
{
type: "text",
text: "Register a user. You must always fill in random details for all fields.",
text: "Register a user. You must always fill in random details for all fields. Do not ask for real information.",
},
],
},
Expand Down

0 comments on commit 10bbe11

Please sign in to comment.