File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
amazonq/.changes/next-release
core/src/codewhispererChat/controllers/chat Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Bug Fix" ,
3
+ "description" : " Amazon Q chat: Improve responses for saved prompts and workspace rules"
4
+ }
Original file line number Diff line number Diff line change @@ -980,9 +980,15 @@ export class ChatController {
980
980
if ( Array . isArray ( prompts ) && prompts . length > 0 ) {
981
981
triggerPayload . additionalContextLengths = this . telemetryHelper . getContextLengths ( prompts )
982
982
for ( const prompt of prompts . slice ( 0 , 20 ) ) {
983
+ // Add system prompt for user prompts and workspace rules
984
+ const contextType = this . telemetryHelper . getContextType ( prompt )
985
+ const description =
986
+ contextType === 'rule' || contextType === 'prompt'
987
+ ? `You must follow the instructions in ${ prompt . relativePath } . Below are lines ${ prompt . startLine } -${ prompt . endLine } of this file:\n`
988
+ : prompt . description
983
989
const entry = {
984
990
name : prompt . name . substring ( 0 , aditionalContentNameLimit ) ,
985
- description : prompt . description . substring ( 0 , aditionalContentNameLimit ) ,
991
+ description : description . substring ( 0 , aditionalContentNameLimit ) ,
986
992
innerContext : prompt . content . substring ( 0 , additionalContentInnerContextLimit ) ,
987
993
}
988
994
// make sure the relevantDocument + additionalContext
@@ -994,7 +1000,6 @@ export class ChatController {
994
1000
break
995
1001
}
996
1002
997
- const contextType = this . telemetryHelper . getContextType ( prompt )
998
1003
if ( contextType === 'rule' ) {
999
1004
triggerPayload . truncatedAdditionalContextLengths . ruleContextLength += entry . innerContext . length
1000
1005
} else if ( contextType === 'prompt' ) {
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ import { AuthUtil } from '../../../codewhisperer/util/authUtil'
42
42
import { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil'
43
43
import { undefinedIfEmpty } from '../../../shared/utilities/textUtilities'
44
44
import { AdditionalContextPrompt } from '../../../amazonq/lsp/types'
45
- import { getUserPromptsDirectory } from '../../constants'
45
+ import { getUserPromptsDirectory , promptFileExtension } from '../../constants'
46
+ import { isInDirectory } from '../../../shared/filesystemUtilities'
46
47
47
48
export function logSendTelemetryEventFailure ( error : any ) {
48
49
let requestId : string | undefined
@@ -148,13 +149,14 @@ export class CWCTelemetryHelper {
148
149
}
149
150
150
151
public getContextType ( prompt : AdditionalContextPrompt ) : string {
151
- if ( prompt . relativePath . startsWith ( path . join ( '.amazonq' , 'rules' ) ) ) {
152
- return 'rule'
153
- } else if ( prompt . filePath . startsWith ( getUserPromptsDirectory ( ) ) ) {
154
- return ' prompt'
155
- } else {
156
- return 'file'
152
+ if ( prompt . filePath . endsWith ( promptFileExtension ) ) {
153
+ if ( isInDirectory ( path . join ( '.amazonq' , 'rules' ) , prompt . relativePath ) ) {
154
+ return 'rule'
155
+ } else if ( isInDirectory ( getUserPromptsDirectory ( ) , prompt . filePath ) ) {
156
+ return 'prompt'
157
+ }
157
158
}
159
+ return 'file'
158
160
}
159
161
160
162
public getContextLengths ( prompts : AdditionalContextPrompt [ ] ) : AdditionalContextLengths {
You can’t perform that action at this time.
0 commit comments