Skip to content
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

Merged
merged 19 commits into from
Oct 16, 2024

Conversation

laileni-aws
Copy link
Contributor

@laileni-aws laileni-aws commented Oct 10, 2024

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@laileni-aws
Copy link
Contributor Author

/retryBuilds

@laileni-aws laileni-aws marked this pull request as ready for review October 10, 2024 23:16
@laileni-aws laileni-aws requested review from a team as code owners October 10, 2024 23:16
@@ -143,6 +145,24 @@ class ChatPromptHandler(private val telemetryHelper: TelemetryHelper) {
}
}

private fun extractCodeBlockLanguage(message: String): String {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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
Copy link
Contributor

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("```")
Copy link
Contributor

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?

Copy link
Contributor Author

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

@laileni-aws
Copy link
Contributor Author

/retryBuilds

@laileni-aws laileni-aws merged commit bf33e46 into aws:main Oct 16, 2024
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants