luo 0.1.22 → 0.1.24

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: 88bde636d015458883a5e90dc2e1303b47843740c9c46aec01fc4805ed324a47
4
- data.tar.gz: 1a6342aa5c4fc95af0334a393a86ff096209d605c2b4c26a039754a2ca37c2ac
3
+ metadata.gz: da7e7e0df02d38335512659fd3318128d4301348de6672b98856f89d75b1226e
4
+ data.tar.gz: 44709abe694e80b8bc5917a2a28221fca9f0f5ce94e1a2e3930158ff10efe75b
5
5
  SHA512:
6
- metadata.gz: 4d6c1b65328aab12bb181dbe4aa9c075469a721b2b402b1a11323a2e21271452052da3f88423627f0ce37a01928bab5a1086d0eb11e1704ef0d362903791610a
7
- data.tar.gz: 1722fa1125d04b9e0ac977465099d932a79347a39467c52f809a1194b9d11954448fcee9cfd8d782544bcc406e41bd590d3837e7116a216482edfdeac3abea43
6
+ metadata.gz: 95125f5f27fea04c632280849c3e278729359c9bd95f943fe2f3cd09884443bb6e8a70d5ff5330a77c173837b59a828fd9a582947cade2805e62f26612663e9c
7
+ data.tar.gz: 76e510443ed91db9a617274c58914950796bf979da2974ef72e4af37a4b35e478bc3b6e8887d1c7330ad1c8fb598cc75d5058cfd584b278ef7020c4823856474
@@ -0,0 +1,7 @@
1
+ <component name="ProjectDictionaryState">
2
+ <dictionary name="mj">
3
+ <words>
4
+ <w>marqo</w>
5
+ </words>
6
+ </dictionary>
7
+ </component>
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luo (0.1.22)
4
+ luo (0.1.24)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  dry-cli (~> 1.0)
7
7
  dry-configurable (~> 1.0, >= 1.0.1)
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Luo
4
4
  module HttpClient
5
- def self.init_client
5
+ def self.init_client(options={})
6
6
  Module.new do
7
7
  define_method :client do
8
- @client ||= Faraday.new(self.class.config.host) { |conn|
8
+ @client ||= Faraday.new(self.class.config.host, options) { |conn|
9
9
  conn.request :authorization, 'Bearer', self.class.config.access_token if self.class.config.respond_to?(:access_token) && !self.class.config.access_token.nil?
10
10
  conn.request :retry, max: (self.class.config.retries || 3), interval: 0.05,
11
11
  interval_randomness: 0.5, backoff_factor: 2,
data/lib/luo/marqo.rb ADDED
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Luo
4
+ class Marqo
5
+ include Configurable
6
+ setting :host, default: "http://localhost:8882"
7
+ setting :x_api_key, default: nil
8
+ setting :retries, default: ENV.fetch('OPENAI_REQUEST_RETRIES', 3).to_i
9
+
10
+ include HttpClient.init_client(headers: { 'X-API-KEY' => config.x_api_key })
11
+
12
+ SEARCH_PARAMS = Dry::Schema.Params do
13
+ required(:q).filled(:string)
14
+ optional(:limit).maybe(:integer)
15
+ optional(:offset).maybe(:integer)
16
+ optional(:filter).maybe(:string)
17
+ optional(:searchableAttributes).maybe(:array)
18
+ optional(:showHighlights).maybe(:bool)
19
+ optional(:searchMethod).value(included_in?: %w[TENSOR LEXICAL])
20
+ optional(:attributesToRetrieve).maybe(:array)
21
+ optional(:reRanker).maybe(:string)
22
+ optional(:boost).maybe(:hash)
23
+ optional(:image_download_headers).maybe(:hash)
24
+ optional(:context).maybe(:hash)
25
+ optional(:scoreModifiers).maybe(:hash)
26
+ optional(:modelAuth).maybe(:hash)
27
+ end
28
+
29
+ def index(index_name)
30
+ @index_name = index_name
31
+ self
32
+ end
33
+
34
+ ##
35
+ # 添加文档到向量数据库
36
+ def add_documents(hash, non_tensor_fields: nil)
37
+ client.post("/indexes/#{@index_name}/documents") do |req|
38
+ req.params[:non_tensor_fields] = non_tensor_fields unless non_tensor_fields.nil?
39
+ req.body = hash
40
+ end
41
+ end
42
+
43
+ def refresh
44
+ client.post("/indexes/#{@index_name}/refresh")
45
+ end
46
+
47
+ def search(params)
48
+ params = SEARCH_PARAMS.call(params)
49
+ return params.errors unless params.success?
50
+ client.post("/indexes/#{@index_name}/search", params.to_h)
51
+ end
52
+
53
+ def delete(id_or_ids)
54
+ id_or_ids = [id_or_ids] if id_or_ids.is_a?(String)
55
+ client.post("/indexes/#{@index_name}/documents/delete-batch", id_or_ids)
56
+ end
57
+
58
+ def remove
59
+ client.delete("/indexes/#{@index_name}")
60
+ end
61
+ end
62
+ end
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.1.22"
4
+ VERSION = "0.1.24"
5
5
  end
data/lib/luo.rb CHANGED
@@ -14,6 +14,7 @@ require 'yaml'
14
14
  require 'tty-markdown'
15
15
  require 'fileutils'
16
16
  require 'dry-initializer'
17
+ require 'uri'
17
18
 
18
19
  require "zeitwerk"
19
20
  loader = Zeitwerk::Loader.for_gem
data/luo.ps1 ADDED
@@ -0,0 +1,31 @@
1
+ function Get-ScriptRoot {
2
+ $result = $PSScriptRoot
3
+ if ($result.Length -eq 0) {
4
+ $result = split-path -parent $MyInvocation.MyCommand.Definition
5
+ }
6
+ return $result
7
+ }
8
+
9
+ function Set-LuoPath {
10
+ $test_path = ([System.Environment]::GetEnvironmentVariable('PATH') | findstr (Get-ScriptRoot)).Length
11
+ if ($test_path -eq 0) {
12
+ [System.Environment]::SetEnvironmentVariable('PATH', "${Env:PATH};" + (Get-ScriptRoot))
13
+ $Env:PATH += ";" + (Get-ScriptRoot)
14
+ Write-Host "=== PATH set for Luo ==="
15
+ }
16
+ }
17
+
18
+ Set-LuoPath
19
+
20
+ if ($args[0] -eq "update") {
21
+ Write-Host "Pulling the latest Docker image..."
22
+ docker pull ghcr.io/mjason/luo:latest
23
+ }
24
+
25
+ Write-Host "Running the Docker container..."
26
+
27
+ docker run --rm -it `
28
+ -p 8888:8888 `
29
+ -v "${PWD}:/workdir" `
30
+ ghcr.io/mjason/luo:latest `
31
+ $args
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.22
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - MJ
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2023-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -175,6 +175,7 @@ extensions: []
175
175
  extra_rdoc_files: []
176
176
  files:
177
177
  - ".idea/.gitignore"
178
+ - ".idea/dictionaries/mj.xml"
178
179
  - ".idea/inspectionProfiles/Project_Default.xml"
179
180
  - ".idea/luo.iml"
180
181
  - ".idea/misc.xml"
@@ -201,6 +202,7 @@ files:
201
202
  - lib/luo/http_client.rb
202
203
  - lib/luo/init_project.rb
203
204
  - lib/luo/loader.rb
205
+ - lib/luo/marqo.rb
204
206
  - lib/luo/memory_history.rb
205
207
  - lib/luo/messages.rb
206
208
  - lib/luo/open_ai.rb
@@ -233,6 +235,7 @@ files:
233
235
  - luo
234
236
  - luo.gemspec
235
237
  - luo.ipynb
238
+ - luo.ps1
236
239
  - sig/luo.rbs
237
240
  - sig/luo/agent.rbs
238
241
  - sig/luo/agent_runner_base.rbs