@@ -133,17 +133,20 @@ def perform(_message_id)
133133
134134 # QUIP Doc
135135 if assistant . quip_url . present?
136- quip_client = Quip ::Client . new ( access_token : ENV . fetch ( 'QUIP_TOKEN' ) )
137-
138136 uri = URI . parse ( assistant . quip_url )
139- path = uri . path . sub ( %r{^/} , '' ) # Removes the leading /
140- quip_thread = quip_client . get_thread ( path )
141-
142- prompt += "# QUIP DOCUMENT\n \n "
143- # The quip api only returns html which has too much extra junk.
144- # Convert to md for smaller size
145- markdown_quip = ReverseMarkdown . convert quip_thread [ 'html' ]
146- prompt += markdown_quip
137+ # Some quip_urls have google and other things in the host. skip this if it doesn't have quip.com in the host
138+ if uri . host &.include? ( 'quip.com' )
139+ quip_client = Quip ::Client . new ( access_token : ENV . fetch ( 'QUIP_TOKEN' ) )
140+ path = uri . path . sub ( %r{^/} , '' ) # Removes the leading /
141+
142+ quip_thread = quip_client . get_thread ( path )
143+
144+ prompt += "# QUIP DOCUMENT\n \n "
145+ # The quip api only returns html which has too much extra junk.
146+ # Convert to md for smaller size
147+ markdown_quip = ReverseMarkdown . convert quip_thread [ 'html' ]
148+ prompt += markdown_quip
149+ end
147150 end
148151
149152 if assistant . confluence_spaces . present?
@@ -164,7 +167,11 @@ def perform(_message_id)
164167 salesforce_client = Salesforce ::Client . new
165168
166169 salesforce_results = salesforce_client . query ( assistant . soql )
167- prompt += JSON . pretty_generate ( salesforce_results . map ( &:to_h ) )
170+ prompt += if salesforce_results &.any?
171+ JSON . pretty_generate ( salesforce_results . map ( &:to_h ) )
172+ else
173+ 'No results from query.'
174+ end
168175 prompt += '</SOQL>'
169176 end
170177
@@ -217,12 +224,8 @@ def perform(_message_id)
217224 llm_message . from = :assistant
218225
219226 begin
220- start_time = Time . now
221227 llm_message . generating!
222228 llm_message . content = get_generation ( llm_message . prompt )
223- end_time = Time . now
224-
225- generation_time = end_time - start_time
226229
227230 llm_message . save
228231 llm_message . ready!
0 commit comments