fix: no method error when conversation is nil (#7566)
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="label-suggestion--container">
|
<div class="label-suggestion--container">
|
||||||
<h6 class="label-suggestion--title">Suggested labels</h6>
|
<h6 class="label-suggestion--title">Suggested labels</h6>
|
||||||
<div v-if="!fetchingSuggestions" class="label-suggestion--options">
|
<div class="label-suggestion--options">
|
||||||
<button
|
<button
|
||||||
v-for="label in preparedLabels"
|
v-for="label in preparedLabels"
|
||||||
:key="label.title"
|
:key="label.title"
|
||||||
@@ -123,7 +123,6 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isDismissed: false,
|
isDismissed: false,
|
||||||
fetchingSuggestions: false,
|
|
||||||
isHovered: false,
|
isHovered: false,
|
||||||
selectedLabels: [],
|
selectedLabels: [],
|
||||||
};
|
};
|
||||||
@@ -160,11 +159,7 @@ export default {
|
|||||||
if (this.isDismissed) return false;
|
if (this.isDismissed) return false;
|
||||||
if (!this.isAIIntegrationEnabled) return false;
|
if (!this.isAIIntegrationEnabled) return false;
|
||||||
|
|
||||||
return (
|
return this.preparedLabels.length && this.chatLabels.length === 0;
|
||||||
!this.fetchingSuggestions &&
|
|
||||||
this.preparedLabels.length &&
|
|
||||||
this.chatLabels.length === 0
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async fetchLabelSuggestions({ conversationId }) {
|
async fetchLabelSuggestions({ conversationId }) {
|
||||||
|
if (!conversationId) return [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await OpenAPI.processEvent({
|
const result = await OpenAPI.processEvent({
|
||||||
type: 'label_suggestion',
|
type: 'label_suggestion',
|
||||||
|
|||||||
@@ -23,14 +23,17 @@ module Enterprise::Integrations::OpenaiProcessorService
|
|||||||
end
|
end
|
||||||
|
|
||||||
def labels_with_messages
|
def labels_with_messages
|
||||||
labels = hook.account.labels.pluck(:title).join(', ')
|
|
||||||
|
|
||||||
character_count = labels.length
|
|
||||||
conversation = find_conversation
|
conversation = find_conversation
|
||||||
|
|
||||||
|
# return nil if conversation is not present
|
||||||
|
return nil if conversation.nil?
|
||||||
|
|
||||||
# return nil if conversation has less than 3 incoming messages
|
# return nil if conversation has less than 3 incoming messages
|
||||||
return nil if conversation.messages.incoming.count < 3
|
return nil if conversation.messages.incoming.count < 3
|
||||||
|
|
||||||
|
labels = hook.account.labels.pluck(:title).join(', ')
|
||||||
|
character_count = labels.length
|
||||||
|
|
||||||
messages = init_messages_body(false)
|
messages = init_messages_body(false)
|
||||||
add_messages_until_token_limit(conversation, messages, false, character_count)
|
add_messages_until_token_limit(conversation, messages, false, character_count)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user