31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/legion/cli/chat/tools/ingest_knowledge.rb', line 31
def execute(content:, content_type: nil, tags: nil, knowledge_domain: nil)
content_type = sanitize_type(content_type)
tag_list = parse_tags(tags)
data = apollo_ingest(
content: content,
content_type: content_type,
tags: tag_list,
knowledge_domain: knowledge_domain
)
return "Failed to ingest: #{data[:error]}" if data[:error]
id = data[:id] || data[:entry_id]
"Saved to Apollo knowledge graph (id: #{id}, type: #{content_type}, tags: #{tag_list.join(', ')})"
rescue Errno::ECONNREFUSED
'Apollo unavailable (daemon not running). Knowledge was not saved.'
rescue StandardError => e
Legion::Logging.warn("IngestKnowledge#execute failed: #{e.message}") if defined?(Legion::Logging)
"Error saving to knowledge graph: #{e.message}"
end
|