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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fd182ae9e62062885029871229627ea000712c81e679434b39d3b9bdabec560
4
- data.tar.gz: 270f57af59b4576b592c298288ff2f65a6817bf6dc46125b98c75c9d05dcce03
3
+ metadata.gz: b8efea7f137dc7da910bcac3986bbaa9a5071c8b8b7b0de3ea2e5e36432d76a7
4
+ data.tar.gz: 92983ab0a6aab26c33491fcda3f713530e89875e9c5d57a0e61319ca3f3604b6
5
5
  SHA512:
6
- metadata.gz: 386ae38c68cc567f8603f7fb12f99c76c5230e247f2a27cec68e56de1b75e0646b2c3e9fc5a1d9f5ebc082435585158e834d8c2ec0c25b5f8ce0db50c5ccd613
7
- data.tar.gz: 8a1e108a7c9501ddcf7da0811d3fda841e75712e84ead1c07c0fc42ad7b587ec5dbf4697f4856a70914597c69094fb5cf6b030248874d90b8812bd34918c13b4
6
+ metadata.gz: 4c3bc4fb184d3b84801fe057c86d89ca8846d0352d4355a63a8159a6f2d564ff13de4a51891e00aca91f1965015e7cdc667f35756e8f79d7e8c8631008be7abb
7
+ data.tar.gz: 64bbc1685ca954cd3875eddacdedc02e745e379b6b6c2375e4fceb1258d52b5b067ab7ca2088b27816712fb312aa451e4b7710e65b5228bbfc937c1207831baa
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-llm-documents"
3
- s.version = "1.0.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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-llm-documents
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler