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 +4 -4
- data/lib/legion/extensions/pilot_knowledge_assist/runners/assistant.rb +6 -6
- data/lib/legion/extensions/pilot_knowledge_assist/runners/classifier.rb +4 -5
- data/lib/legion/extensions/pilot_knowledge_assist/runners/feedback.rb +4 -4
- data/lib/legion/extensions/pilot_knowledge_assist/version.rb +1 -1
- data/lib/legion/extensions/pilot_knowledge_assist.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5f249541eda884a54e5cf95a669185f0debaace3837b8694d5e01ea158c13190
|
|
4
|
+
data.tar.gz: 5935081f590b0642bcdc0bc0bd1a3390d95e2dc9d70563e0fc91e4e45357a15d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:
|
|
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:
|
|
17
|
-
|
|
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
|
|
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
|
-
|
|
26
|
-
|
|
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:
|
|
42
|
+
content: "Q: #{question}\nA: #{answer}",
|
|
43
43
|
content_type: 'qa_pair',
|
|
44
|
-
confidence:
|
|
45
|
-
tags:
|
|
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
|
|
@@ -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'
|
|
8
|
+
require_relative 'pilot_knowledge_assist/actors/question_subscriber'
|
|
9
9
|
|
|
10
10
|
module Legion
|
|
11
11
|
module Extensions
|