cpee-llm-documents 1.0.0 → 1.0.1
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/cpee-llm-documents.gemspec +1 -1
- data/lib/cpee-llm-documents/implementation.rb +9 -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: b8efea7f137dc7da910bcac3986bbaa9a5071c8b8b7b0de3ea2e5e36432d76a7
|
|
4
|
+
data.tar.gz: 92983ab0a6aab26c33491fcda3f713530e89875e9c5d57a0e61319ca3f3604b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c3bc4fb184d3b84801fe057c86d89ca8846d0352d4355a63a8159a6f2d564ff13de4a51891e00aca91f1965015e7cdc667f35756e8f79d7e8c8631008be7abb
|
|
7
|
+
data.tar.gz: 64bbc1685ca954cd3875eddacdedc02e745e379b6b6c2375e4fceb1258d52b5b067ab7ca2088b27816712fb312aa451e4b7710e65b5228bbfc937c1207831baa
|
data/cpee-llm-documents.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "cpee-llm-documents"
|
|
3
|
-
s.version = "1.0.
|
|
3
|
+
s.version = "1.0.1"
|
|
4
4
|
s.platform = Gem::Platform::RUBY
|
|
5
5
|
s.license = "GPL-3.0-or-later"
|
|
6
6
|
s.summary = "LLM document processing service for the cloud process execution engine (cpee.org)"
|
|
@@ -26,8 +26,15 @@ module CPEE
|
|
|
26
26
|
module LLM
|
|
27
27
|
module Documents
|
|
28
28
|
SERVER = File.expand_path(File.join(__dir__,'implementation.xml'))
|
|
29
|
+
USED_TOKENS_HEADER = 'CPEE-LLM-Used-Tokens'
|
|
29
30
|
|
|
30
31
|
class DoDocument < Riddl::Implementation #{{{
|
|
32
|
+
def used_tokens(tokens)
|
|
33
|
+
t = Array(tokens).first.to_s
|
|
34
|
+
@headers << Riddl::Header.new(USED_TOKENS_HEADER, "input=#{t[/input=(\d+)/,1].to_i}, output=#{t[/output=(\d+)/,1].to_i}")
|
|
35
|
+
@headers << Riddl::Header.new('Access-Control-Expose-Headers', USED_TOKENS_HEADER)
|
|
36
|
+
end
|
|
37
|
+
|
|
31
38
|
OFFICE_EXTENSIONS = {
|
|
32
39
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => '.docx',
|
|
33
40
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => '.xlsx',
|
|
@@ -98,12 +105,13 @@ module CPEE
|
|
|
98
105
|
concepts wherever applicable.
|
|
99
106
|
PROMPT
|
|
100
107
|
|
|
101
|
-
status, res = Riddl::Client.new(@a[0][:generic_endpoint]).post([
|
|
108
|
+
status, res, rheaders = Riddl::Client.new(@a[0][:generic_endpoint]).post([
|
|
102
109
|
Riddl::Parameter::Complex.new('llm', 'text/plain', llm),
|
|
103
110
|
Riddl::Parameter::Complex.new('user_input', 'text/plain', user_input),
|
|
104
111
|
Riddl::Parameter::Complex.new('system_prompt', 'text/plain', system_prompt),
|
|
105
112
|
Riddl::Parameter::Complex.new('format', 'text/plain', 'false')
|
|
106
113
|
] + documents)
|
|
114
|
+
used_tokens((rheaders || {})['CPEE_LLM_USED_TOKENS'])
|
|
107
115
|
|
|
108
116
|
raw = res.first.value
|
|
109
117
|
raw = raw.read if raw.respond_to?(:read)
|