Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
fix anthropic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
patcher9 committed Mar 24, 2024
1 parent 76d0be3 commit 3ca9733
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions tests/anthropic.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,37 @@ describe('Anthropic Test', () => {
// Non-streaming messages
it('should return a response with type as "message"', async () => {
DokuMetry.init({llm: anthropic, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
const message = await anthropic.messages.create({
model: "claude-3-opus-20240229",
max_tokens: 100,
messages: [{ role: "user", content: "How to monitor LLM Applications in one sentence?" }],
});

expect(message.type).to.equal('message');
try {
const message = await anthropic.messages.create({
model: "claude-3-opus-20240229",
max_tokens: 10,
messages: [{ role: "user", content: "How to monitor LLM Applications in one sentence?" }],
});
expect(message.type).to.equal('message');
} catch (error) {
console.log(error);
}
}).timeout(30000);

it('should return a response with type as "message"', async () => {
DokuMetry.init({llm: anthropic, dokuUrl: process.env.DOKU_URL, apiKey: process.env.DOKU_TOKEN, environment: "dokumetry-testing", applicationName: "dokumetry-node-test", skipResp: false});
var stream = await anthropic.messages.create({
max_tokens: 100,
messages: [{ role: 'user', content: 'How to monitor LLM Applications in one sentence?' }],
model: 'claude-3-opus-20240229',
stream: true,
});
for await (const messageStreamEvent of stream) {
if (messageStreamEvent.type === 'message_start') {
expect(messageStreamEvent.type).to.equal('message_start');
}
if (messageStreamEvent.type === 'content_block_delta') {
expect(messageStreamEvent.type).to.equal('content_block_delta');
try {
var stream = await anthropic.messages.create({
max_tokens: 10,
messages: [{ role: 'user', content: 'How to monitor LLM Applications in one sentence?' }],
model: 'claude-3-opus-20240229',
stream: true,
});
for await (const messageStreamEvent of stream) {
if (messageStreamEvent.type === 'message_start') {
expect(messageStreamEvent.type).to.equal('message_start');
}
if (messageStreamEvent.type === 'content_block_delta') {
expect(messageStreamEvent.type).to.equal('content_block_delta');
}
}
} catch (error) {
console.log(error);
}
}).timeout(30000);
});

0 comments on commit 3ca9733

Please sign in to comment.