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

Extend Chat and Completion Telemetry with Customization #493

Merged
merged 7 commits into from
Oct 14, 2024

Conversation

ege0zcan
Copy link
Contributor

Description

Update the chat and completion telemetry to contain customization information.

For chat we need to be careful to preserve the correct customization associated with a message, this PR introduces logic into the chat telemetry controller

Tested using the sample extension with IDC login. Verified that customization information is correctly preserved for past messages that were obtained by using customizations and verified that setting a new customization after receiving a response doesn't cause wrong telemetry for current or past chat messages.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ege0zcan ege0zcan requested review from a team as code owners October 10, 2024 14:23
Copy link
Contributor

@Jurredr Jurredr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Good stuff.

@@ -54,13 +55,15 @@ export class ChatTelemetryController {
#activeTabId?: string
#tabTelemetryInfoByTabId: { [tabId: string]: ConversationTriggerInfo }
#currentTriggerByTabId: { [tabId: string]: TriggerType } = {}
#customizationInfoByTabAndMessageId: { [tabId: string]: { [messageId: 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.

Would be using only messageId to store this value be enough? If messageId is unique uuid across all tabs, then grouping per tab is redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good question, I also considered that but storing by message id means we have no way of knowing when a message is no longer active/relevant.

When we store messages inside their respective tabs, then we can safely clean up all the messages that are no longer active by deleting the tab entry. So this is to ensure the customizationInfoByTabAndMessageId doesn't keep growing infinitely

)
const customizationValue = undefinedIfEmpty(qConfig.customization)
codeWhispererService.customizationArn = customizationValue
sessionManager.getCurrentSession()?.setCustomizationArn(customizationValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if customisation changes for inflight requests for current session? Can it result in new value being passed for the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given sessions are very short lived I was not able to trigger such a scenario in my testing. After some testing I will actually remove this line so that we get set customization arn on the sessions at creation time only

// Store the customization value associated with the message
if (metric.cwsprChatMessageId && metric.codewhispererCustomizationArn) {
this.#customizationInfoByTabAndMessageId[tabId] = {
...this.#customizationInfoByTabAndMessageId[tabId],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: destructing assignment is not needed here. If treating object as set, you can just assign new value for metric.cwsprChatMessageId in this.#customizationInfoByTabAndMessageId[tabId] directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to do this.#customizationInfoByTabAndMessageId[tabId][metric.cwsprChatMessageId] = metric.codewhispererCustomizationArn because that doesn't work when this.#customizationInfoByTabAndMessageId[tabId] doesn't exist yet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yeah, either create new array or push to existing one

@ege0zcan ege0zcan merged commit a96137c into main Oct 14, 2024
5 checks passed
@ege0zcan ege0zcan deleted the customizationTelemetry branch October 14, 2024 13:29
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.

3 participants