lex-pilot-knowledge-assist 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b76d59fb124ac0122c3d6cccf00435df8adba1dd958ee10567e99925d6399c8a
4
- data.tar.gz: ac9e56379a0872d0b563775f03e8e8478388f5c5ceffcde0fb0233007ffd98a9
3
+ metadata.gz: 5f249541eda884a54e5cf95a669185f0debaace3837b8694d5e01ea158c13190
4
+ data.tar.gz: 5935081f590b0642bcdc0bc0bd1a3390d95e2dc9d70563e0fc91e4e45357a15d
5
5
  SHA512:
6
- metadata.gz: a5590e7e84dcb7887a1f8bfca98f9b1d35481cc7384ba87d60499d7245bcbe690ae6eee183159ead76bedfa107b305bd7927a321c45244664f45b16e2a007ac3
7
- data.tar.gz: 9f17b9442d70e74fb7a1d07d7a4f87f09ee8571216037a8fd154f84eeabd7f56aa2f61bc9752bdba1cd1ec5e48c412ce9e23048e944cc01b5fba48491311f16f
6
+ metadata.gz: 99a6af6777efbe509a7ddb2624a8bf43a9c78768de5fcc14828377ab68a069c1fbbe8f25f8cae9cb6cdc41dec29f94aa486df4a61402e5767a21d54b247d2911
7
+ data.tar.gz: 8b97fd123fed59d8f715602fb1fa11ec77c6344ae8b7ae02cecd6ff6ae67baf806079628ee66b5124b5471a6b042f67275fd57e48c251b78ce8d1d07d3be7593
@@ -11,10 +11,10 @@ module Legion
11
11
  ESCALATION_THRESHOLD = 0.2
12
12
  DISCLAIMER_PREFIX = "I'm not fully certain about this answer -- please verify:\n\n"
13
13
  INTENT_ANSWERS = {
14
- greeting: 'Hello! I can help with Grid documentation and support questions.',
14
+ greeting: 'Hello! I can help with Grid documentation and support questions.',
15
15
  out_of_scope: 'I can only help with Grid infrastructure and documentation questions.',
16
- ops_request: 'I can answer documentation questions but cannot perform operations. ' \
17
- 'Please contact the Grid team.'
16
+ ops_request: 'I can answer documentation questions but cannot perform operations. ' \
17
+ 'Please contact the Grid team.'
18
18
  }.freeze
19
19
 
20
20
  def answer_question(question:, agent_id: 'knowledge-assist')
@@ -64,7 +64,7 @@ module Legion
64
64
 
65
65
  client = Legion::Extensions::Apollo::Client.new(agent_id: agent_id)
66
66
  client.query_knowledge(query: question, limit: 5)
67
- rescue StandardError
67
+ rescue StandardError => _e
68
68
  []
69
69
  end
70
70
 
@@ -78,7 +78,7 @@ module Legion
78
78
  "Context:\n#{context_text}\n\nQuestion: #{question}"
79
79
  end
80
80
 
81
- result = Legion::LLM.chat(message: prompt, caller: { extension: 'lex-pilot-knowledge-assist' })
81
+ result = Legion::LLM.chat(message: prompt, caller: { extension: 'lex-pilot-knowledge-assist' }) # rubocop:disable Legion/HelperMigration/DirectLlm
82
82
  result.is_a?(Hash) ? result[:content] : result.to_s
83
83
  rescue StandardError => e
84
84
  "Error: #{e.message}"
@@ -93,7 +93,7 @@ module Legion
93
93
  message = "Knowledge assist escalation:\n*Question:* #{question}\n*Confidence:* #{confidence}"
94
94
  Legion::Extensions::Slack::Client.new.send_webhook(message: message, webhook: webhook)
95
95
  rescue StandardError => e
96
- Legion::Logging::Logger.warn("Escalation failed: #{e.message}") if defined?(Legion::Logging)
96
+ Legion::Logging.warn("Escalation failed: #{e.message}") # rubocop:disable Legion/HelperMigration/DirectLogging
97
97
  end
98
98
 
99
99
  def escalation_webhook
@@ -21,15 +21,14 @@ module Legion
21
21
  return { intent: :doc_question, method: :default } unless llm_available?
22
22
 
23
23
  prompt = format(CLASSIFY_PROMPT, message: message)
24
- response = Legion::LLM.chat(
25
- message: prompt,
26
- caller: { extension: 'lex-pilot-knowledge-assist', function: 'classify_intent' }
27
- )
24
+ response = Legion::LLM.chat(message: prompt, # rubocop:disable Legion/HelperMigration/DirectLlm
25
+ caller: { extension: 'lex-pilot-knowledge-assist',
26
+ function: 'classify_intent' })
28
27
  intent = response.to_s.strip.downcase.to_sym
29
28
  intent = :doc_question unless VALID_INTENTS.include?(intent)
30
29
 
31
30
  { intent: intent, method: :llm }
32
- rescue StandardError
31
+ rescue StandardError => _e
33
32
  { intent: :doc_question, method: :fallback }
34
33
  end
35
34
 
@@ -39,12 +39,12 @@ module Legion
39
39
  return unless defined?(Legion::Extensions::Apollo::Client)
40
40
 
41
41
  Legion::Extensions::Apollo::Client.new.handle_ingest(
42
- content: "Q: #{question}\nA: #{answer}",
42
+ content: "Q: #{question}\nA: #{answer}",
43
43
  content_type: 'qa_pair',
44
- confidence: 0.5,
45
- tags: %w[knowledge_assist qa_pair]
44
+ confidence: 0.5,
45
+ tags: %w[knowledge_assist qa_pair]
46
46
  )
47
- rescue StandardError
47
+ rescue StandardError => _e
48
48
  nil
49
49
  end
50
50
  end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module PilotKnowledgeAssist
6
- VERSION = '0.2.1'
6
+ VERSION = '0.2.2'
7
7
  end
8
8
  end
9
9
  end
@@ -5,7 +5,7 @@ require_relative 'pilot_knowledge_assist/runners/classifier'
5
5
  require_relative 'pilot_knowledge_assist/runners/assistant'
6
6
  require_relative 'pilot_knowledge_assist/runners/feedback'
7
7
 
8
- require_relative 'pilot_knowledge_assist/actors/question_subscriber' if defined?(Legion::Extensions::Actors::Subscription)
8
+ require_relative 'pilot_knowledge_assist/actors/question_subscriber'
9
9
 
10
10
  module Legion
11
11
  module Extensions
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-pilot-knowledge-assist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity