luo 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d99e88006e5445420b8659fd680122ca1b047e15d9e97e7b62b6fd2144930b9
4
- data.tar.gz: e7b6e686e73e1daa3bc3d345e8a1523267220e768bdd474d345dc263f2e9ab6b
3
+ metadata.gz: 4569a6fd6ae87797597f59bc73f8c1b6ac8d805f3410ecc716ffc7e1ddf428c1
4
+ data.tar.gz: 9695305bfe27cec9708fbc6fea8d1b000ff8450b17befdaa1a0c822da815f157
5
5
  SHA512:
6
- metadata.gz: 20eafa8f4fafc7483e3acf28f532729eb6a993dad888d93f5c28d7bd7608643909d7fe771db4772c0e896658d9c3a6587760c9e85c115e81e7d29ea4813afc7a
7
- data.tar.gz: 0b6cf883f769c6cbad3a178faa16ae6cd02dc7f240335e2b17b30f096b1d4f2b126a07cde18ecf8b5dacf4d8ead7d7a0add0f308abbeb4dd406f818c9778fe68
6
+ metadata.gz: 281fca6621c8aaccc3c21559c4a0e8ef80738fdf648bb5db68fd639b3692bb4a5f5890c5ad20b94dab9159ae27a5569b99c1a3cf1408603af5894be76f315586
7
+ data.tar.gz: 80a2b4894e507b1874e21ba0928bc8b5c16cc88fda9870e5ee2c8b333dd1dcc0e2d80c3d5f954ce6abf8f35b56f93127d1aad1ebca34278c7d7427241429c904
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luo (0.2.6)
4
+ luo (0.2.7)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  dry-configurable (~> 1.0, >= 1.0.1)
7
7
  dry-schema (~> 1.13, >= 1.13.1)
data/lib/luo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Luo
4
- VERSION = "0.2.6"
4
+ VERSION = "0.2.7"
5
5
  end
data/lib/luo/xinghuo.rb CHANGED
@@ -26,12 +26,31 @@ module Luo
26
26
  optional(:stream).maybe(:bool)
27
27
  end
28
28
 
29
+ EMBEDDING_PARAMS = Dry::Schema.Params do
30
+ required(:input).filled(:string)
31
+ end
32
+
29
33
  # header uid max length is 32 todo
30
34
 
31
35
  def request_chat(params, &block)
32
36
  client.post('/v1/spark/completions', params.to_h, &block)
33
37
  end
34
38
 
39
+ def embedding(params)
40
+ client.post('/v1/embedding', params.to_h)
41
+ end
42
+
43
+ def create_embedding(text, model: 'text-embedding-ada-002')
44
+ params = EMBEDDING_PARAMS.call(input: text)
45
+ return params.errors unless params.success?
46
+ response = embedding(params)
47
+ if response.success?
48
+ response.body.dig("data")
49
+ else
50
+ raise "create_embeddings failed: #{response.body}"
51
+ end
52
+ end
53
+
35
54
  def chat(messages, random_threshold: nil, &block)
36
55
  if messages.is_a?(Messages)
37
56
  messages = messages.to_a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - MJ