File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
packages/sdk/server-ai/examples Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,13 @@ async function main() {
6161 myVariable : 'My User Defined Variable' ,
6262 } ,
6363 ) ;
64- const { tracker } = aiConfig ;
6564
66- const completion = tracker . trackBedrockConverseMetrics (
65+ if ( ! aiConfig . enabled || ! aiConfig . tracker ) {
66+ console . log ( '*** AI configuration is not enabled' ) ;
67+ process . exit ( 0 ) ;
68+ }
69+
70+ const completion = aiConfig . tracker . trackBedrockConverseMetrics (
6771 await awsClient . send (
6872 new ConverseCommand ( {
6973 modelId : aiConfig . model ?. name ?? 'no-model' ,
Original file line number Diff line number Diff line change @@ -58,8 +58,12 @@ async function main(): Promise<void> {
5858 { myVariable : 'My User Defined Variable' } ,
5959 ) ;
6060
61- const { tracker } = aiConfig ;
62- const completion = await tracker . trackOpenAIMetrics ( async ( ) =>
61+ if ( ! aiConfig . enabled || ! aiConfig . tracker ) {
62+ console . log ( '*** AI configuration is not enabled' ) ;
63+ process . exit ( 0 ) ;
64+ }
65+
66+ const completion = await aiConfig . tracker . trackOpenAIMetrics ( async ( ) =>
6367 client . chat . completions . create ( {
6468 messages : aiConfig . messages || [ ] ,
6569 model : aiConfig . model ?. name || 'gpt-4' ,
You can’t perform that action at this time.
0 commit comments