-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
telemetry(amazonq): Adding cwsprChatProgrammingLanguage parameter to insertAtCursor and CopyAtClipboard events #4959
Conversation
/retryBuilds |
plugins/core/jetbrains-community/resources/telemetryOverride.json
Outdated
Show resolved
Hide resolved
.../software/aws/toolkits/jetbrains/services/cwc/controller/chat/messenger/ChatPromptHandler.kt
Outdated
Show resolved
Hide resolved
@@ -143,6 +145,24 @@ class ChatPromptHandler(private val telemetryHelper: TelemetryHelper) { | |||
} | |||
} | |||
|
|||
private fun extractCodeBlockLanguage(message: String): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved extractCodeBlockLanguage
to shared/TextUtils
file and added test cases.
plugins/core/core/src/software/aws/toolkits/core/utils/TextUtils.kt
Outdated
Show resolved
Hide resolved
fun extractCodeBlockLanguage(message: String): String { | ||
// This fulfills both the cases of unit test generation(java, python) and general use case(Non java and Non python) languages. | ||
val defaultTestGenResponseLanguage: String = "plaintext" | ||
val indexStart: Int = 3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 is a property of '```', shouldn't we key off of that instead?
// This fulfills both the cases of unit test generation(java, python) and general use case(Non java and Non python) languages. | ||
val defaultTestGenResponseLanguage: String = "plaintext" | ||
val indexStart: Int = 3 | ||
val codeBlockStart = message.indexOf("```") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there any other edge cases with this we need to worry about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If we use this
extractCodeBlokLanguage
, we assume code generated should start or at-least will have 3 backticks with language name. - So If generated code doesn't provide language after ``` we assume the language to be
plaintext
- Even for counting number of code blocks, we are implementing this approach for recognizing code blocks with 3 backticks, until backend provide IDE this data.
- Right now this is used only for telemetry purposes
/retryBuilds |
Types of changes
Description
interactWithMessage
is missingcwsprChatProgrammingLanguage
parameter which helps to understand the language of generated code.cwsprChatProgrammingLanguage
parameter for insertAtCursor and CopyAtClipboard events.cwsprChatProgrammingLanguage
in commons package: telemetry: Adding cwsprChatProgrammingLanguage aws-toolkit-common#883cwsprChatHasProjectContext and cwsprChatTotalCodeBlocks
in in commons package: telemetry: cwsprChatHasProjectContext and cwsprChatTotalCodeBlocks aws-toolkit-common#884Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.