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 +4 -4
- data/app/models/prompt_navigator/prompt_execution.rb +23 -0
- data/lib/prompt_navigator/version.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: 5b2382f515204e007fd69b49339cc98afc15184c544a1dab7fc0b3957e18a220
|
|
4
|
+
data.tar.gz: 345a5c6c9e29695394cfb333a181cd6530a9697fe2b9a4b23bccb4ee1af910b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|