@@ -12,7 +12,7 @@ import {
12
12
MessageType ,
13
13
} from '../types'
14
14
import { ChatSession } from '../../codewhispererChat/clients/chat/v0/chat'
15
- import { AuthUtil , getChatAuthState } from '../../codewhisperer/util/authUtil'
15
+ import { AuthUtil } from '../../codewhisperer/util/authUtil'
16
16
import globals from '../../shared/extensionGlobals'
17
17
import { getLogger } from '../../shared/logger/logger'
18
18
@@ -80,8 +80,7 @@ async function generateResource(prompt: string) {
80
80
// TODO-STARLING - Revisit to see if timeout still needed prior to launch
81
81
const data = await timeout ( chatSession . chat ( request ) , TIMEOUT )
82
82
const initialResponseTime = globals . clock . Date . now ( ) - startTime
83
- getLogger ( ) . debug ( `CW Chat initial response time: ${ initialResponseTime } ms` )
84
- getLogger ( ) . debug ( `CW Chat initial response: ${ JSON . stringify ( data , undefined , 2 ) } ` )
83
+ getLogger ( ) . debug ( `CW Chat initial response: ${ JSON . stringify ( data , undefined , 2 ) } , ${ initialResponseTime } ms` )
85
84
if ( data [ '$metadata' ] ) {
86
85
metadata = data [ '$metadata' ]
87
86
}
@@ -133,21 +132,17 @@ async function generateResource(prompt: string) {
133
132
134
133
const elapsedTime = globals . clock . Date . now ( ) - startTime
135
134
136
- // TODO-STARLING: Reduce/remove below
137
- getLogger ( ) . debug ( `===== CW Chat prompt start ====` )
138
- getLogger ( ) . debug ( prompt )
139
- getLogger ( ) . debug ( `===== CW Chat prompt end ======` )
140
- getLogger ( ) . debug ( `===== CW Chat metadata start ======` )
141
- getLogger ( ) . debug ( `CW Chat conversationId = ${ conversationId } ` )
142
- getLogger ( ) . debug ( `CW Chat metadata = \n${ JSON . stringify ( metadata , undefined , 2 ) } ` )
143
- getLogger ( ) . debug ( `CW Chat supplementaryWebLinks = \n${ JSON . stringify ( supplementaryWebLinks , undefined , 2 ) } ` )
144
- getLogger ( ) . debug ( `CW Chat references = \n${ JSON . stringify ( references , undefined , 2 ) } ` )
145
- getLogger ( ) . debug ( `===== CW Chat metadata end ======` )
146
- getLogger ( ) . debug ( `===== CW Chat raw response start ======` )
147
- getLogger ( ) . debug ( `${ response } ` )
148
- getLogger ( ) . debug ( `===== CW Chat raw response end ======` )
149
- getLogger ( ) . debug ( `CW Chat initial response time = ${ initialResponseTime } ms` )
150
- getLogger ( ) . debug ( `CW Chat elapsed time = ${ elapsedTime } ms` )
135
+ getLogger ( ) . debug (
136
+ `CW Chat Debug message:
137
+ prompt = "${ prompt } ",
138
+ conversationId = ${ conversationId } ,
139
+ metadata = \n${ JSON . stringify ( metadata , undefined , 2 ) } ,
140
+ supplementaryWebLinks = \n${ JSON . stringify ( supplementaryWebLinks , undefined , 2 ) } ,
141
+ references = \n${ JSON . stringify ( references , undefined , 2 ) } ,
142
+ response = "${ response } ",
143
+ initialResponse = ${ initialResponseTime } ms,
144
+ elapsed time = ${ elapsedTime } ms`
145
+ )
151
146
152
147
return {
153
148
chatResponse : response ,
@@ -161,7 +156,6 @@ async function generateResource(prompt: string) {
161
156
}
162
157
} catch ( error : any ) {
163
158
getLogger ( ) . debug ( `CW Chat error: ${ error . name } - ${ error . message } ` )
164
- await debugConnection ( )
165
159
if ( error . $metadata ) {
166
160
const { requestId, cfId, extendedRequestId } = error . $metadata
167
161
getLogger ( ) . debug ( JSON . stringify ( { requestId, cfId, extendedRequestId } , undefined , 2 ) )
@@ -179,20 +173,3 @@ function timeout<T>(promise: Promise<T>, ms: number, timeoutError = new Error('P
179
173
} )
180
174
return Promise . race < T > ( [ promise , _timeout ] )
181
175
}
182
-
183
- // TODO-STARLING
184
- // Temporary function to assist with debug as Starling is coded
185
- // This will likely be removed prior to launch
186
- async function debugConnection ( ) {
187
- const isConnected = AuthUtil . instance . isConnected ( )
188
- const isValid = AuthUtil . instance . isConnectionValid ( )
189
- const isExpired = AuthUtil . instance . isConnectionExpired ( )
190
- const authState = await getChatAuthState ( AuthUtil . instance )
191
- const isConnectedToCodeWhisperer =
192
- authState . codewhispererChat === 'connected' || authState . codewhispererChat === 'expired'
193
-
194
- getLogger ( ) . debug ( `DEBUG: debugConnection - isConnected = ${ isConnected } ` )
195
- getLogger ( ) . debug ( `DEBUG: debugConnection - isValid = ${ isValid } ` )
196
- getLogger ( ) . debug ( `DEBUG: debugConnection - isExpired = ${ isExpired } ` )
197
- getLogger ( ) . debug ( `DEBUG: debugConnection - isConnectedToCodeWhisperer = ${ isConnectedToCodeWhisperer } ` )
198
- }
0 commit comments