prompt_navigator 0.2.0 → 0.3.0

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: e274278632397e1855b526f972b2fefe465b3fdb1d98aa58e21a66e4760f9ada
4
- data.tar.gz: 23b2c261efe6a2b83a3762891dd6e45c91c1df977820202a751de8f2f3a9d83b
3
+ metadata.gz: 5b2382f515204e007fd69b49339cc98afc15184c544a1dab7fc0b3957e18a220
4
+ data.tar.gz: 345a5c6c9e29695394cfb333a181cd6530a9697fe2b9a4b23bccb4ee1af910b6
5
5
  SHA512:
6
- metadata.gz: e61e66a4a8cb9dfdffccd40ea81a490e8d2bf79a174ecf9506988d4bc19dc000f3122dbce58c7b3021b5a0812286e863fb1a85da1bb4a061c65a97abc458b8d1
7
- data.tar.gz: 7c7d01998defac44429f0ced473d477c3aa33781af07ec5787f5f87a4d0b7c75c88fd50cac61512b350ce38781ab6add6c25ef0862032d5d84ce7ad20c3baa57
6
+ metadata.gz: cf0eebdf61457d792bca663deaaff47320aad9f97f53922d9b7dd22509b554d148adee965871145b398780d7ceef6a3e400bc0aa02ca40d35f7ad28080b2fb75
7
+ data.tar.gz: ebabe858fda114acc8a9b7c2066a91938807d72fe653a95a4d406f4d11abbf1017e8d66d30158db32d0bbb33553e8c8863bbbea0a5fce590fab8798e17b16a59
@@ -4,8 +4,31 @@ module PromptNavigator
4
4
 
5
5
  before_create :set_execution_id
6
6
 
7
+ # Builds a context array from the direct lineage for summarization.
8
+ # Each entry contains { prompt:, response: } from ancestor PromptExecutions.
9
+ # Optionally limit to the most recent N ancestors.
10
+ def build_context(limit: nil)
11
+ ancestors(limit: limit).map do
12
+ { prompt: it.prompt, response: it.response }
13
+ end
14
+ end
15
+
7
16
  private
8
17
 
18
+ # Returns ancestor PromptExecutions in chronological order (oldest first),
19
+ # excluding self. Optionally limit to the most recent N ancestors.
20
+ def ancestors(limit: nil)
21
+ chain = []
22
+ pe = previous
23
+
24
+ while pe
25
+ chain.unshift(pe)
26
+ pe = pe.previous
27
+ end
28
+
29
+ limit ? chain.last(limit) : chain
30
+ end
31
+
9
32
  def set_execution_id
10
33
  self.execution_id ||= SecureRandom.uuid
11
34
  end
@@ -1,3 +1,3 @@
1
1
  module PromptNavigator
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prompt_navigator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dhq_boiler