lex-knowledge 0.6.5 → 0.6.7

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: 70a69a9c3412559375829cb915fef22403720a86c4641e60d999ab90e6bd477f
4
- data.tar.gz: ed3e0c10d03222a5c63b9dab8dd8cb16cd6b7bf706e9d273fb62e0627d3ac770
3
+ metadata.gz: 67be6d2627f0f84483f91a633fc2c8dc97f9af000400a1c54e6c33a0a2ae9186
4
+ data.tar.gz: 375d0d0b11130acc23be20b1f7211900c885a72d2d74e0f61971e15512a29ddb
5
5
  SHA512:
6
- metadata.gz: d17f409fc6647d7e607fb460655c6dbbc9fdc60868771e67c6bdbb87a7c3ae7bf19891bdd8c8d91b5e966499d2ed5703a041bb3098c9fdfc1934267bcfd4275a
7
- data.tar.gz: 46753c59a30027af49957779cfce75135acf6c9ca241a6d88ad10906af26ac67b37794a9bb90098a69026e02fe748ae5cbf71d15a18bd2551e3891df27330f8e
6
+ metadata.gz: fb8d27cbfb9ea975cd3a50b52d63a819a7ddd437b71bb44035edb8a422605758a7618830aec9034d79f9b26b873eb9319dac059041087a7aa71f1021de977e87
7
+ data.tar.gz: '08341ac36efb14a6cd8a5d08db64917f824946e7b26a34318e56372f87feedf0ff87c061a9b98a9d11ace2404b46cf5a8c703e5a55c9b11da289e08e65ed5e0c'
@@ -223,8 +223,7 @@ module Legion
223
223
  return false unless defined?(Legion::Data::Model::ApolloEntry)
224
224
 
225
225
  Legion::Data::Model::ApolloEntry
226
- .where(Sequel.like(:tags, '%document_chunk%'))
227
- .where(Sequel.like(:content, "%#{content_hash}%"))
226
+ .where(content_hash: content_hash)
228
227
  .any?
229
228
  rescue StandardError => e
230
229
  log.warn(e.message)
@@ -47,16 +47,19 @@ module Legion
47
47
  end
48
48
 
49
49
  def health(path:)
50
- scan_entries = Helpers::Manifest.scan(path: path)
51
- store_path = Helpers::ManifestStore.store_path(corpus_path: path)
50
+ resolved = path || (Legion::Settings.dig(:knowledge, :corpus_path) if defined?(Legion::Settings))
51
+ return { success: false, error: 'corpus_path is required' } if resolved.nil? || resolved.to_s.empty?
52
+
53
+ scan_entries = Helpers::Manifest.scan(path: resolved)
54
+ store_path = Helpers::ManifestStore.store_path(corpus_path: resolved)
52
55
  manifest_file = ::File.exist?(store_path)
53
56
  last_ingest = manifest_file ? ::File.mtime(store_path).iso8601 : nil
54
57
 
55
58
  {
56
59
  success: true,
57
- local: build_local_stats(path, scan_entries, manifest_file, last_ingest),
60
+ local: build_local_stats(resolved, scan_entries, manifest_file, last_ingest),
58
61
  apollo: build_apollo_stats,
59
- sync: build_sync_stats(path, scan_entries)
62
+ sync: build_sync_stats(resolved, scan_entries)
60
63
  }
61
64
  rescue StandardError => e
62
65
  { success: false, error: e.message }
@@ -69,11 +69,12 @@ module Legion
69
69
  def retrieve_chunks(question, top_k)
70
70
  return [] unless defined?(Legion::Extensions::Apollo)
71
71
 
72
- Legion::Extensions::Apollo::Runners::Knowledge.retrieve_relevant(
72
+ result = Legion::Extensions::Apollo::Runners::Knowledge.retrieve_relevant(
73
73
  query: question,
74
74
  limit: top_k,
75
75
  tags: ['document_chunk']
76
76
  )
77
+ result.is_a?(Hash) && result[:success] ? Array(result[:entries]) : []
77
78
  rescue StandardError => _e
78
79
  []
79
80
  end
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Knowledge
6
- VERSION = '0.6.5'
6
+ VERSION = '0.6.7'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-knowledge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Iverson