Skip to content

Commit c33aaaa

Browse files
committed
Add pre-implementation test case of InvokeModel
1 parent b8e3c16 commit c33aaaa

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

plugins/node/opentelemetry-instrumentation-aws-sdk/test/bedrock-runtime.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
BedrockRuntimeClient,
3838
ConverseCommand,
3939
ConversationRole,
40+
InvokeModelCommand,
4041
} from '@aws-sdk/client-bedrock-runtime';
4142
import * as path from 'path';
4243
import { Definition, back as nockBack } from 'nock';
@@ -146,4 +147,41 @@ describe('Bedrock', () => {
146147
});
147148
});
148149
});
150+
151+
// TODO: Instrument InvokeModel
152+
describe('InvokeModel', () => {
153+
it('does not currently add genai conventions', async () => {
154+
const modelId = 'amazon.titan-text-express-v1';
155+
const inputText = 'Say this is a test';
156+
const textGenerationConfig = {
157+
maxTokenCount: 10,
158+
temperature: 0.8,
159+
topP: 1,
160+
stopSequences: ['|'],
161+
};
162+
const body: any = {
163+
inputText,
164+
textGenerationConfig,
165+
};
166+
167+
const command = new InvokeModelCommand({
168+
modelId,
169+
body: JSON.stringify(body),
170+
});
171+
const response = await client.send(command);
172+
const output = JSON.parse(response.body.transformToString());
173+
expect(output.results[0].outputText).toBe(
174+
'\nHello! I am a computer program designed to'
175+
);
176+
177+
const testSpans: ReadableSpan[] = getTestSpans();
178+
const converseSpans: ReadableSpan[] = testSpans.filter(
179+
(s: ReadableSpan) => {
180+
return s.name === 'BedrockRuntime.InvokeModel';
181+
}
182+
);
183+
expect(converseSpans.length).toBe(1);
184+
expect(converseSpans[0].attributes[ATTR_GEN_AI_SYSTEM]).toBeUndefined();
185+
});
186+
});
149187
});

0 commit comments

Comments
 (0)